summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorLane Kolbly <lane@rscheme.org>2017-09-07 14:41:16 +0200
committerAlexander Harkness <me@bearbin.net>2017-09-07 14:41:16 +0200
commitb12f4ef7d58cfe4d815feb2db1f88f223c7f2a61 (patch)
treec7e2a8db5676c8599ce76b212491dd35fd883c1c /src/World.cpp
parentLighting now generally consistent with vanilla (#3988) (diff)
downloadcuberite-b12f4ef7d58cfe4d815feb2db1f88f223c7f2a61.tar
cuberite-b12f4ef7d58cfe4d815feb2db1f88f223c7f2a61.tar.gz
cuberite-b12f4ef7d58cfe4d815feb2db1f88f223c7f2a61.tar.bz2
cuberite-b12f4ef7d58cfe4d815feb2db1f88f223c7f2a61.tar.lz
cuberite-b12f4ef7d58cfe4d815feb2db1f88f223c7f2a61.tar.xz
cuberite-b12f4ef7d58cfe4d815feb2db1f88f223c7f2a61.tar.zst
cuberite-b12f4ef7d58cfe4d815feb2db1f88f223c7f2a61.zip
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/World.cpp b/src/World.cpp
index f610d4d2e..e2ac24e71 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -120,16 +120,18 @@ void cWorld::cTickThread::Execute(void)
////////////////////////////////////////////////////////////////////////////////
// cWorld:
-cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_LinkedOverworldName) :
+cWorld::cWorld(const AString & a_WorldName, const AString & a_DataPath, eDimension a_Dimension, const AString & a_LinkedOverworldName) :
m_WorldName(a_WorldName),
+ m_DataPath(a_DataPath),
m_LinkedOverworldName(a_LinkedOverworldName),
- m_IniFileName(m_WorldName + "/world.ini"),
+ m_IniFileName(m_DataPath + "/world.ini"),
m_StorageSchema("Default"),
#ifdef __arm__
m_StorageCompressionFactor(0),
#else
m_StorageCompressionFactor(6),
#endif
+ m_IsSavingEnabled(true),
m_Dimension(a_Dimension),
m_IsSpawnExplicitlySet(false),
m_SpawnX(0),
@@ -194,10 +196,10 @@ cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AStrin
{
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
- cFile::CreateFolder(FILE_IO_PREFIX + m_WorldName);
+ cFile::CreateFolderRecursive(FILE_IO_PREFIX + m_DataPath);
// Load the scoreboard
- cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard);
+ cScoreboardSerializer Serializer(m_DataPath, &m_Scoreboard);
Serializer.Load();
}
@@ -213,11 +215,14 @@ cWorld::~cWorld()
m_Storage.WaitForFinish();
- // Unload the scoreboard
- cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard);
- Serializer.Save();
+ if (IsSavingEnabled())
+ {
+ // Unload the scoreboard
+ cScoreboardSerializer Serializer(m_DataPath, &m_Scoreboard);
+ Serializer.Save();
- m_MapManager.SaveMapData();
+ m_MapManager.SaveMapData();
+ }
// Explicitly destroy the chunkmap, so that it's guaranteed to be destroyed before the other internals
// This fixes crashes on stopping the server, because chunk destructor deletes entities and those access the world.
@@ -2965,7 +2970,9 @@ void cWorld::SetChunkData(cSetChunkData & a_SetChunkData)
);
// Save the chunk right after generating, so that we don't have to generate it again on next run
- if (a_SetChunkData.ShouldMarkDirty())
+ // If saving is disabled, then the chunk was marked dirty so it will get
+ // saved if saving is later enabled.
+ if (a_SetChunkData.ShouldMarkDirty() && IsSavingEnabled())
{
m_Storage.QueueSaveChunk(ChunkX, ChunkZ);
}
@@ -3629,8 +3636,11 @@ bool cWorld::ForEachLoadedChunk(std::function<bool(int, int)> a_Callback)
void cWorld::SaveAllChunks(void)
{
- m_LastSave = std::chrono::duration_cast<cTickTimeLong>(m_WorldAge);
- m_ChunkMap->SaveAllChunks();
+ if (IsSavingEnabled())
+ {
+ m_LastSave = std::chrono::duration_cast<cTickTimeLong>(m_WorldAge);
+ m_ChunkMap->SaveAllChunks();
+ }
}