From b687be9e44bc232b063365235541f871beeabfac Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 15 Aug 2012 11:54:13 +0000 Subject: 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 --- source/WorldStorage.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/WorldStorage.cpp') diff --git a/source/WorldStorage.cpp b/source/WorldStorage.cpp index ce1c11322..b75520448 100644 --- a/source/WorldStorage.cpp +++ b/source/WorldStorage.cpp @@ -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); -- cgit v1.2.3