summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-08-29 18:29:30 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-08-29 18:29:30 +0200
commitbb11091402142daf2f9e8294a256bb7222bbc344 (patch)
treeb8a4828b72991b39a5cbf3ed4bc07357f9399972 /src/World.cpp
parentFixed some headers, incorprated some code from the conflicts (diff)
parentcUUID: Fix FromHexDigit for digits >= 'a' (diff)
downloadcuberite-bb11091402142daf2f9e8294a256bb7222bbc344.tar
cuberite-bb11091402142daf2f9e8294a256bb7222bbc344.tar.gz
cuberite-bb11091402142daf2f9e8294a256bb7222bbc344.tar.bz2
cuberite-bb11091402142daf2f9e8294a256bb7222bbc344.tar.lz
cuberite-bb11091402142daf2f9e8294a256bb7222bbc344.tar.xz
cuberite-bb11091402142daf2f9e8294a256bb7222bbc344.tar.zst
cuberite-bb11091402142daf2f9e8294a256bb7222bbc344.zip
Diffstat (limited to 'src/World.cpp')
-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();