From 07b7fd4ad3fef714399009efd5d4a903a561a6f2 Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Tue, 2 Feb 2016 17:37:21 +0200 Subject: Fixed cChunk::m_Entities corruption upon world travel --- src/Entities/Entity.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/Entities/Entity.cpp') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index d4097f734..ff03bae3c 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -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); -- cgit v1.2.3