1
0

cWorld * -> cWorld (#4771)

* cWorld * -> cWorld
This commit is contained in:
Tiger Wang
2020-07-14 17:57:30 +01:00
committed by GitHub
parent 36eab1b323
commit 9d277f1d10
6 changed files with 96 additions and 129 deletions

View File

@@ -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();
}