Fixed crash on server stop.
The entity destructors called through chunkmap destructor and chunk destructor were accessing the world which was in an already invalid state (half-destroyed). Fixed by destroying chunkmap explicitly and providing a nullptr check in the HasEntity() function.
This commit is contained in:
parent
3c3cb198f3
commit
e08331a24b
@ -346,6 +346,10 @@ cWorld::~cWorld()
|
|||||||
Serializer.Save();
|
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.
|
||||||
|
m_ChunkMap.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3122,6 +3126,11 @@ bool cWorld::HasEntity(int a_UniqueID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the entity is in the chunkmap:
|
// Check if the entity is in the chunkmap:
|
||||||
|
if (m_ChunkMap.get() == nullptr)
|
||||||
|
{
|
||||||
|
// Chunkmap has already been destroyed, there are no entities anymore.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return m_ChunkMap->HasEntity(a_UniqueID);
|
return m_ChunkMap->HasEntity(a_UniqueID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user