summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2017-08-29 14:08:18 +0200
committerLukas Pioch <lukas@zgow.de>2017-08-29 15:46:36 +0200
commit1779db1201f3c514997624381b520d89c7c4d5a7 (patch)
treee7661ffc9569597fca8b4c1880b1a443b278a263 /src
parentRepair the removed constructor of cCuboid `cCuboid(otherCuboid)` (#3966) (diff)
downloadcuberite-1779db1201f3c514997624381b520d89c7c4d5a7.tar
cuberite-1779db1201f3c514997624381b520d89c7c4d5a7.tar.gz
cuberite-1779db1201f3c514997624381b520d89c7c4d5a7.tar.bz2
cuberite-1779db1201f3c514997624381b520d89c7c4d5a7.tar.lz
cuberite-1779db1201f3c514997624381b520d89c7c4d5a7.tar.xz
cuberite-1779db1201f3c514997624381b520d89c7c4d5a7.tar.zst
cuberite-1779db1201f3c514997624381b520d89c7c4d5a7.zip
Diffstat (limited to '')
-rw-r--r--src/World.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 04ca1709e..acec3049e 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -995,18 +995,21 @@ void cWorld::Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_La
}
// Add entities waiting in the queue to be added:
+ cEntityList EntitiesToAdd;
{
+ // Don't access chunkmap while holding lock
cCSLock Lock(m_CSEntitiesToAdd);
- for (auto & Entity : m_EntitiesToAdd)
- {
- Entity->SetWorld(this);
- auto EntityPtr = Entity.get();
- m_ChunkMap->AddEntity(std::move(Entity));
- ASSERT(!EntityPtr->IsTicking());
- EntityPtr->SetIsTicking(true);
- }
- m_EntitiesToAdd.clear();
+ std::swap(EntitiesToAdd, m_EntitiesToAdd);
+ }
+ for (auto & Entity : EntitiesToAdd)
+ {
+ Entity->SetWorld(this);
+ auto EntityPtr = Entity.get();
+ m_ChunkMap->AddEntity(std::move(Entity));
+ ASSERT(!EntityPtr->IsTicking());
+ EntityPtr->SetIsTicking(true);
}
+ EntitiesToAdd.clear();
// Add players waiting in the queue to be added:
AddQueuedPlayers();