1
0

Chunks are properly saved before being unloaded now

numchunks server command works again

git-svn-id: http://mc-server.googlecode.com/svn/trunk@272 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth 2012-02-16 13:23:54 +00:00
parent 1b60fe14f8
commit 1c4122313f
2 changed files with 11 additions and 1 deletions

View File

@ -287,11 +287,14 @@ void cChunkMap::cChunkLayer::Save(void)
void cChunkMap::cChunkLayer::UnloadUnusedChunks(void)
{
cWorld * World = m_Parent->GetWorld();
for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++)
{
if ((m_Chunks[i] != NULL) && (m_Chunks[i]->CanUnload()))
{
// TODO: Save the chunk if it was changed
World->GetStorage().QueueSaveChunk(m_Chunks[i]); // _FT: FIXME: Right now it saves chunks even though it might not have changed.
// Also I'm not sure what's going on when I queue this chunks and the next line says reset the pointer.. =/
m_Chunks[i].reset();
}
} // for i - m_Chunks[]

View File

@ -84,7 +84,14 @@ private:
int GetX(void) const {return m_LayerX; }
int GetZ(void) const {return m_LayerZ; }
int GetNumChunksLoaded(void) const {return m_NumChunksLoaded; }
int GetNumChunksLoaded(void) const
{
int NumChunks = 0;
for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i )
if( m_Chunks[i].get() )
NumChunks++;
return NumChunks;
}
void Save(void);
void UnloadUnusedChunks(void);