1
0

Fixed cChunk::m_Entities corruption upon world travel

This commit is contained in:
LogicParrot
2016-02-02 17:37:21 +02:00
parent 57e6fd654b
commit 07b7fd4ad3
4 changed files with 57 additions and 8 deletions

View File

@@ -1499,8 +1499,17 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
return false;
}
// Remove all links to the old world
SetWorldTravellingFrom(GetWorld()); // cChunk::Tick() handles entity removal
// Remove entity from chunk
if (!GetWorld()->DoWithChunk(GetChunkX(), GetChunkZ(), [this](cChunk & a_Chunk) -> bool
{
a_Chunk.SafeRemoveEntity(this);
return true;
}))
{
LOGD("Entity Teleportation failed! Didn't find the source chunk!\n");
return false;
}
GetWorld()->BroadcastDestroyEntity(*this);
SetPosition(a_NewPosition);