From 9d277f1d10c1b2f929711795c85dc4ff7c3d8d3b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 14 Jul 2020 17:57:30 +0100 Subject: cWorld * -> cWorld (#4771) * cWorld * -> cWorld --- src/World.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/World.cpp') 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(); } -- cgit v1.2.3