summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-07-14 18:57:30 +0200
committerGitHub <noreply@github.com>2020-07-14 18:57:30 +0200
commit9d277f1d10c1b2f929711795c85dc4ff7c3d8d3b (patch)
tree861b54c5b0fbd2dd98c5a0f6674e8abafe38b26e /src/World.cpp
parentIntroduce recipe book functionality (#4493) (diff)
downloadcuberite-9d277f1d10c1b2f929711795c85dc4ff7c3d8d3b.tar
cuberite-9d277f1d10c1b2f929711795c85dc4ff7c3d8d3b.tar.gz
cuberite-9d277f1d10c1b2f929711795c85dc4ff7c3d8d3b.tar.bz2
cuberite-9d277f1d10c1b2f929711795c85dc4ff7c3d8d3b.tar.lz
cuberite-9d277f1d10c1b2f929711795c85dc4ff7c3d8d3b.tar.xz
cuberite-9d277f1d10c1b2f929711795c85dc4ff7c3d8d3b.tar.zst
cuberite-9d277f1d10c1b2f929711795c85dc4ff7c3d8d3b.zip
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 251c8ce51..6e7c066c9 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -457,21 +457,6 @@ cWorld::~cWorld()
delete m_WaterSimulator; m_WaterSimulator = nullptr;
delete m_LavaSimulator; m_LavaSimulator = nullptr;
delete m_RedstoneSimulator; m_RedstoneSimulator = nullptr;
-
- m_Storage.WaitForFinish();
-
- if (IsSavingEnabled())
- {
- // Unload the scoreboard
- cScoreboardSerializer Serializer(m_DataPath, &m_Scoreboard);
- Serializer.Save();
-
- 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.
- m_ChunkMap.reset();
}
@@ -964,11 +949,25 @@ void cWorld::Stop(cDeadlockDetect & a_DeadlockDetect)
m_Lighting.Stop();
m_Generator.Stop();
m_ChunkSender.Stop();
- m_Storage.Stop();
+ m_Storage.Stop(); // Waits for thread to finish
a_DeadlockDetect.UntrackCriticalSection(m_CSClients);
a_DeadlockDetect.UntrackCriticalSection(m_CSTasks);
m_ChunkMap->UntrackInDeadlockDetect(a_DeadlockDetect);
+
+ if (IsSavingEnabled())
+ {
+ // Unload the scoreboard
+ cScoreboardSerializer Serializer(m_DataPath, &m_Scoreboard);
+ Serializer.Save();
+
+ 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.
+ // TODO: destructors should only be used for releasing resources, not doing extra work
+ m_ChunkMap.reset();
}