diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2016-12-18 21:41:37 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2016-12-18 21:41:37 +0100 |
commit | b5b119ca750a1790848b514bb00831b050f25fac (patch) | |
tree | e7a145a856676d248da5050b57da1cee4d005815 /src/ChunkMap.cpp | |
parent | test (diff) | |
download | cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.gz cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.bz2 cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.lz cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.xz cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.zst cuberite-b5b119ca750a1790848b514bb00831b050f25fac.zip |
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r-- | src/ChunkMap.cpp | 40 |
1 files changed, 4 insertions, 36 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 2e6153f0e..abd4eb8bf 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1582,51 +1582,19 @@ void cChunkMap::RemoveChunkClient(int a_ChunkX, int a_ChunkZ, const std::shared_ +void cChunkMap::AddEntity(std::unique_ptr<cEntity> a_Entity) { - for (const auto & Chunk : m_Chunks) - { - Chunk.second->RemoveClient(a_Client); - } -} - - - - - -void cChunkMap::AddEntity(cEntity * a_Entity) -{ - cCSLock Lock(m_CSChunks); - cChunkPtr Chunk = GetChunk(a_Entity->GetChunkX(), a_Entity->GetChunkZ()); - if (Chunk == nullptr) // This will assert inside GetChunk in Debug builds - { - LOGWARNING("Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.", - static_cast<void *>(a_Entity), a_Entity->GetClass(), a_Entity->GetUniqueID() - ); - return; - } - Chunk->AddEntity(a_Entity); -} - - - - ASSERT(GetWorld()->IsInTickThread()); -void cChunkMap::AddEntityIfNotPresent(cEntity * a_Entity) -{ - cCSLock Lock(m_CSChunks); cChunkPtr Chunk = GetChunk(a_Entity->GetChunkX(), a_Entity->GetChunkZ()); if (Chunk == nullptr) // This will assert inside GetChunk in Debug builds { LOGWARNING("Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.", - static_cast<void *>(a_Entity), a_Entity->GetClass(), a_Entity->GetUniqueID() + static_cast<void *>(a_Entity.get()), a_Entity->GetClass(), a_Entity->GetUniqueID() ); return; } - if (!Chunk->HasEntity(a_Entity->GetUniqueID())) - { - Chunk->AddEntity(a_Entity); - } + Chunk->AddEntity(std::move(a_Entity)); } @@ -2574,10 +2542,10 @@ void cChunkMap::GetChunkStats(int & a_NumChunksValid, int & a_NumChunksDirty) bool cChunkMap::GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, MTRand & a_Rand) { + ASSERT(GetWorld()->IsInTickThread()); int ChunkX, ChunkZ; cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ); - ASSERT(GetWorld()->IsInTickThread()); cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ChunkZ); if (Chunk != nullptr) { |