diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-08 20:49:57 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-08 20:49:57 +0100 |
commit | 10752d2f35b729b1e84219b4075c9e77727ab1b4 (patch) | |
tree | 7d72b9c260a876ecda99bb458d0a75d34858beb4 /source/cChunkMap.cpp | |
parent | Added total chunk count to webadmin (diff) | |
download | cuberite-10752d2f35b729b1e84219b4075c9e77727ab1b4.tar cuberite-10752d2f35b729b1e84219b4075c9e77727ab1b4.tar.gz cuberite-10752d2f35b729b1e84219b4075c9e77727ab1b4.tar.bz2 cuberite-10752d2f35b729b1e84219b4075c9e77727ab1b4.tar.lz cuberite-10752d2f35b729b1e84219b4075c9e77727ab1b4.tar.xz cuberite-10752d2f35b729b1e84219b4075c9e77727ab1b4.tar.zst cuberite-10752d2f35b729b1e84219b4075c9e77727ab1b4.zip |
Diffstat (limited to 'source/cChunkMap.cpp')
-rw-r--r-- | source/cChunkMap.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp index 424b26b5f..2d3aabd7b 100644 --- a/source/cChunkMap.cpp +++ b/source/cChunkMap.cpp @@ -59,6 +59,7 @@ cChunkMap::cChunkMap(cWorld* a_World ) cChunkMap::~cChunkMap()
{
+ // TODO: delete layers
}
@@ -127,11 +128,6 @@ cChunkMap::cChunkLayer* cChunkMap::AddLayer( const cChunkLayer & a_Layer ) void cChunkMap::AddChunk( cChunk* a_Chunk )
{
- /* // OLD
- m_Nodes[ MakeHash( a_Chunk->GetPosX(), a_Chunk->GetPosZ() ) ].push_back( a_Chunk );
- */
-
- // NEW
const int LayerX = (int)(floorf((float)a_Chunk->GetPosX() / (float)(LAYER_SIZE)));
const int LayerZ = (int)(floorf((float)a_Chunk->GetPosZ() / (float)(LAYER_SIZE)));
cChunkLayer* FoundLayer = GetLayer( LayerX, LayerZ );
@@ -141,16 +137,20 @@ void cChunkMap::AddChunk( cChunk* a_Chunk ) NewLayer.m_X = LayerX;
NewLayer.m_Z = LayerZ;
FoundLayer = AddLayer( NewLayer );
- LOGWARN("Created new layer %i %i (total layers %i)", LayerX, LayerZ, m_NumLayers );
+ LOG("Created new layer [%i %i] (total layers %i)", LayerX, LayerZ, m_NumLayers );
}
//Get local coordinates in layer
const int LocalX = a_Chunk->GetPosX() - LayerX * LAYER_SIZE;
const int LocalZ = a_Chunk->GetPosZ() - LayerZ * LAYER_SIZE;
if( FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_LiveChunk )
+ {
LOGWARN("WARNING: Added chunk to layer while it was already loaded!");
+ }
if( FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_Compressed )
+ {
LOGWARN("WARNING: Added chunk to layer while a compressed version exists!");
+ }
FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_LiveChunk = a_Chunk;
FoundLayer->m_NumChunksLoaded++;
}
@@ -161,11 +161,6 @@ void cChunkMap::AddChunk( cChunk* a_Chunk ) void cChunkMap::RemoveChunk( cChunk* a_Chunk )
{
- /* // OLD
- m_Nodes[ MakeHash( a_Chunk->GetPosX(), a_Chunk->GetPosZ() ) ].erase( a_Chunk );
- */
-
- // NEW
cChunkLayer* Layer = GetLayerForChunk( a_Chunk->GetPosX(), a_Chunk->GetPosZ() );
if( Layer )
{
@@ -392,10 +387,8 @@ void cChunkMap::UnloadUnusedChunks() SaveLayer( &Layer );
for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i ) // Free all chunk data for layer
{
- if( Layer.m_Chunks[i].m_Compressed )
- delete [] Layer.m_Chunks[i].m_Compressed;
- if( Layer.m_Chunks[i].m_LiveChunk )
- delete Layer.m_Chunks[i].m_LiveChunk;
+ delete [] Layer.m_Chunks[i].m_Compressed;
+ delete Layer.m_Chunks[i].m_LiveChunk;
}
if( RemoveLayer( &Layer ) ) l--;
}
|