diff options
author | Mattes D <github@xoft.cz> | 2016-12-15 15:28:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-15 15:28:15 +0100 |
commit | fc40932ab1a663574938535dae918d8cd916efe6 (patch) | |
tree | 24a0b525c79b552a50700784a2e37a87489b85f4 /src | |
parent | APIDump: Proper error messages on apicheck failures. (diff) | |
parent | Fixed minecart destruction using deallocated memory. (diff) | |
download | cuberite-fc40932ab1a663574938535dae918d8cd916efe6.tar cuberite-fc40932ab1a663574938535dae918d8cd916efe6.tar.gz cuberite-fc40932ab1a663574938535dae918d8cd916efe6.tar.bz2 cuberite-fc40932ab1a663574938535dae918d8cd916efe6.tar.lz cuberite-fc40932ab1a663574938535dae918d8cd916efe6.tar.xz cuberite-fc40932ab1a663574938535dae918d8cd916efe6.tar.zst cuberite-fc40932ab1a663574938535dae918d8cd916efe6.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Minecart.cpp | 11 | ||||
-rw-r--r-- | src/WorldStorage/WorldStorage.cpp | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index c75c8288c..b8e8e9f29 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -1250,10 +1250,15 @@ void cMinecartWithChest::Destroyed() m_Contents.CopyToItems(Pickups); - // This makes the command not execute if the world is in the midst of destruction :) - GetWorld()->ScheduleTask(1, [this, Pickups](cWorld & World) + // Schedule the pickups creation for the next world tick + // This avoids a deadlock when terminating the world + // Note that the scheduled task may be run when this object is no longer valid, we need to store everything in the task's captured variables + auto posX = GetPosX(); + auto posY = GetPosY() + 1; + auto posZ = GetPosZ(); + GetWorld()->ScheduleTask(1, [Pickups, posX, posY, posZ](cWorld & World) { - World.SpawnItemPickups(Pickups, GetPosX(), GetPosY() + 1, GetPosZ(), 4); + World.SpawnItemPickups(Pickups, posX, posY, posZ, 4); }); } diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index 55555d731..29fe78d4f 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -142,6 +142,8 @@ size_t cWorldStorage::GetSaveQueueLength(void) void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback) { + ASSERT((a_ChunkX > -0x08000000) && (a_ChunkX < 0x08000000)); + ASSERT((a_ChunkZ > -0x08000000) && (a_ChunkZ < 0x08000000)); ASSERT(m_World->IsChunkQueued(a_ChunkX, a_ChunkZ)); m_LoadQueue.EnqueueItem(cChunkCoordsWithCallback(a_ChunkX, a_ChunkZ, a_Callback)); |