summaryrefslogtreecommitdiffstats
path: root/src/ChunkMap.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-06 01:35:42 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2021-01-12 13:34:34 +0100
commit054a89dd9e5d6819adede9d7ba781b69f98ff2f4 (patch)
tree820a104cae2d9e4ec912b0a1bd7debac52cf4cc9 /src/ChunkMap.cpp
parentConvert most calls to blocking GetHeight/GetBiomeAt to direct chunk accesses (diff)
downloadcuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.gz
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.bz2
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.lz
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.xz
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.zst
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.zip
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r--src/ChunkMap.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index c5798260b..c1d9b78ab 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -940,19 +940,18 @@ void cChunkMap::RemoveClientFromChunks(cClientHandle * a_Client)
void cChunkMap::AddEntity(OwnedEntity a_Entity)
{
cCSLock Lock(m_CSChunks);
- const auto Chunk = FindChunk(a_Entity->GetChunkX(), a_Entity->GetChunkZ());
- if (Chunk == nullptr)
+ if (FindChunk(a_Entity->GetChunkX(), a_Entity->GetChunkZ()) == nullptr)
{
- LOGWARNING("Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.",
- static_cast<void *>(a_Entity.get()), a_Entity->GetClass(), a_Entity->GetUniqueID()
+ LOGWARNING("%s: Entity at %p (%s, ID %d) spawning in a non-existent chunk.",
+ __FUNCTION__, static_cast<void *>(a_Entity.get()), a_Entity->GetClass(), a_Entity->GetUniqueID()
);
- return;
}
const auto EntityPtr = a_Entity.get();
ASSERT(EntityPtr->GetWorld() == m_World);
- Chunk->AddEntity(std::move(a_Entity));
+ auto & Chunk = ConstructChunk(a_Entity->GetChunkX(), a_Entity->GetChunkZ());
+ Chunk.AddEntity(std::move(a_Entity));
EntityPtr->OnAddToWorld(*m_World);
ASSERT(!EntityPtr->IsTicking());
@@ -1738,11 +1737,7 @@ void cChunkMap::Tick(std::chrono::milliseconds a_Dt)
cCSLock Lock(m_CSChunks);
for (auto & Chunk : m_Chunks)
{
- // Only tick chunks that are valid and should be ticked:
- if (Chunk.second.IsValid() && Chunk.second.ShouldBeTicked())
- {
- Chunk.second.Tick(a_Dt);
- }
+ Chunk.second.Tick(a_Dt);
}
}