summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-15 13:54:13 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-15 13:54:13 +0200
commitb687be9e44bc232b063365235541f871beeabfac (patch)
treef4cca078204a26171382ec7aba087a2e7a256c60
parentFix torches broken in rev 724 (diff)
downloadcuberite-b687be9e44bc232b063365235541f871beeabfac.tar
cuberite-b687be9e44bc232b063365235541f871beeabfac.tar.gz
cuberite-b687be9e44bc232b063365235541f871beeabfac.tar.bz2
cuberite-b687be9e44bc232b063365235541f871beeabfac.tar.lz
cuberite-b687be9e44bc232b063365235541f871beeabfac.tar.xz
cuberite-b687be9e44bc232b063365235541f871beeabfac.tar.zst
cuberite-b687be9e44bc232b063365235541f871beeabfac.zip
-rw-r--r--source/WorldStorage.cpp26
-rw-r--r--source/WorldStorage.h3
-rw-r--r--source/cServer.cpp2
-rw-r--r--source/cWorld.cpp4
4 files changed, 32 insertions, 3 deletions
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);
diff --git a/source/WorldStorage.h b/source/WorldStorage.h
index b2daba059..48036ed11 100644
--- a/source/WorldStorage.h
+++ b/source/WorldStorage.h
@@ -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);
diff --git a/source/cServer.cpp b/source/cServer.cpp
index 15f19eeed..78bfc8953 100644
--- a/source/cServer.cpp
+++ b/source/cServer.cpp
@@ -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)
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 54931d104..5bb1e8094 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -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();
}