Added a true "all chunks saved" message for the save-all console command (FS #215)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@738 0a769ca7-a7f5-676a-18bf-c427514a06d6
master
madmaxoft@gmail.com 2012-08-15 11:54:13 +00:00
parent d58db08c1b
commit b687be9e44
4 changed files with 32 additions and 3 deletions

View File

@ -19,6 +19,13 @@
/// If a chunk with this Y coord is de-queued, it is a signal to emit the saved-all message (cWorldStorage::QueueSavedMessage())
#define CHUNK_Y_MESSAGE 2
/// Example storage schema - forgets all chunks ;)
class cWSSForgetful :
public cWSSchema
@ -175,6 +182,20 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
void cWorldStorage::QueueSavedMessage(void)
{
// Pushes a special coord pair into the queue, signalizing a message instead:
{
cCSLock Lock(m_CSQueues);
m_SaveQueue.push_back(cChunkCoords(0, CHUNK_Y_MESSAGE, 0));
}
m_Event.Set();
}
void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
cCSLock Lock(m_CSQueues);
@ -323,6 +344,11 @@ bool cWorldStorage::SaveOneChunk(void)
}
HasMore = !m_SaveQueue.empty();
}
if (Save.m_ChunkY == CHUNK_Y_MESSAGE)
{
LOGINFO("Saved all chunks in world %s", m_World->GetName().c_str());
return HasMore;
}
if (ShouldSave && m_World->IsChunkValid(Save.m_ChunkX, Save.m_ChunkY, Save.m_ChunkZ))
{
m_World->MarkChunkSaving(Save.m_ChunkX, Save.m_ChunkY, Save.m_ChunkZ);

View File

@ -65,6 +65,9 @@ public:
void QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate); // Queues the chunk for loading; if not loaded, the chunk will be generated if a_Generate is true
void QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
/// Signals that a message should be output to the console when all the chunks have been saved
void QueueSavedMessage(void);
/// Loads the chunk specified; returns true on success, false on failure
bool LoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ);

View File

@ -498,7 +498,7 @@ void cServer::ServerCommand( const char * a_Cmd )
}
if( split[0].compare( "save-all" ) == 0 )
{
cRoot::Get()->SaveAllChunks(); // TODO - Force ALL worlds to save their chunks
cRoot::Get()->SaveAllChunks();
return;
}
if (split[0].compare("unload") == 0)

View File

@ -1769,10 +1769,10 @@ bool cWorld::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunk
void cWorld::SaveAllChunks(void)
{
LOG("Saving all chunks...");
LOGINFO("Saving all chunks...");
m_LastSave = m_Time;
m_ChunkMap->SaveAllChunks();
LOG("All chunks saved.");
m_Storage.QueueSavedMessage();
}