Fixed the numchunks console command.
Added some form of reference counting to cChunk to make sure it's not referenced when deleting it. Right now it's only needed due to the generation of chunks in a separate thread and adding it to the spread light list in cWorld git-svn-id: http://mc-server.googlecode.com/svn/trunk@161 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -462,7 +462,7 @@ void cChunkMap::UnloadUnusedChunks()
|
||||
for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i )
|
||||
{
|
||||
cChunk* Chunk = Layer.m_Chunks[i].m_LiveChunk;
|
||||
if( Chunk && Chunk->GetClients().size() == 0 )
|
||||
if( Chunk && Chunk->GetClients().size() == 0 && Chunk->GetReferenceCount() <= 0 )
|
||||
{
|
||||
Chunk->SaveToDisk();
|
||||
World->RemoveSpread( Chunk );
|
||||
@@ -716,3 +716,13 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cChunkMap::GetNumChunks()
|
||||
{
|
||||
int NumChunks = 0;
|
||||
for( int i = 0; i < m_NumLayers; ++i )
|
||||
{
|
||||
NumChunks += m_Layers[i].m_NumChunksLoaded;
|
||||
}
|
||||
return NumChunks;
|
||||
}
|
||||
Reference in New Issue
Block a user