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

@@ -1695,6 +1695,20 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
return false;
}
// Remove player 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;
}
// Remove player from world
GetWorld()->RemovePlayer(this, false);
// Send the respawn packet:
if (a_ShouldSendRespawn && (m_ClientHandle != nullptr))
{
@@ -1704,10 +1718,6 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
// Broadcast for other people that the player is gone.
GetWorld()->BroadcastDestroyEntity(*this);
// Remove player from the old world
SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal
GetWorld()->RemovePlayer(this, false);
SetPosition(a_NewPosition);
// Queue adding player to the new world, including all the necessary adjustments to the object