From 01398f84244c0f4f06c8edb1e741937792f53eb2 Mon Sep 17 00:00:00 2001 From: faketruth Date: Sun, 1 Jan 2012 16:20:52 +0000 Subject: 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 --- source/cChunkMap.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source/cChunkMap.cpp') diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp index 90b3258e7..d05fd4a43 100644 --- a/source/cChunkMap.cpp +++ b/source/cChunkMap.cpp @@ -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; +} \ No newline at end of file -- cgit v1.2.3