summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-02-03 19:19:11 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-02-03 19:19:11 +0100
commita5403c897658c0cb837c9167d74e7302a09659c2 (patch)
tree85013e81fad7154733fa52e58138b4c854a597ed /src/Entities
parentMerge pull request #2903 from marvinkopf/FixTabAutoComplete (diff)
parentFixed cChunk::m_Entities corruption upon world travel (diff)
downloadcuberite-a5403c897658c0cb837c9167d74e7302a09659c2.tar
cuberite-a5403c897658c0cb837c9167d74e7302a09659c2.tar.gz
cuberite-a5403c897658c0cb837c9167d74e7302a09659c2.tar.bz2
cuberite-a5403c897658c0cb837c9167d74e7302a09659c2.tar.lz
cuberite-a5403c897658c0cb837c9167d74e7302a09659c2.tar.xz
cuberite-a5403c897658c0cb837c9167d74e7302a09659c2.tar.zst
cuberite-a5403c897658c0cb837c9167d74e7302a09659c2.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp13
-rw-r--r--src/Entities/Player.cpp18
2 files changed, 25 insertions, 6 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 593bc6aca..0706a1676 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);
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 767ee2061..7ba6b2bf6 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -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