diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-09-03 23:25:35 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-09-03 23:25:35 +0200 |
commit | 5e670a050bb263ec66227e572eaf9fe0a95ccf1c (patch) | |
tree | fbe5e46923e7ccbb33a5857c8bc21787410ca0be /src/ChunkMap.cpp | |
parent | Define _DEBUG macro for tests and main server (#4843) (diff) | |
download | cuberite-5e670a050bb263ec66227e572eaf9fe0a95ccf1c.tar cuberite-5e670a050bb263ec66227e572eaf9fe0a95ccf1c.tar.gz cuberite-5e670a050bb263ec66227e572eaf9fe0a95ccf1c.tar.bz2 cuberite-5e670a050bb263ec66227e572eaf9fe0a95ccf1c.tar.lz cuberite-5e670a050bb263ec66227e572eaf9fe0a95ccf1c.tar.xz cuberite-5e670a050bb263ec66227e572eaf9fe0a95ccf1c.tar.zst cuberite-5e670a050bb263ec66227e572eaf9fe0a95ccf1c.zip |
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r-- | src/ChunkMap.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 14d0d0d94..92cce9b55 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -909,21 +909,12 @@ void cChunkMap::AddEntity(OwnedEntity a_Entity) -void cChunkMap::AddEntityIfNotPresent(OwnedEntity a_Entity) +void cChunkMap::AddPlayer(std::unique_ptr<cPlayer> a_Player) { cCSLock Lock(m_CSChunks); - const auto Chunk = FindChunk(a_Entity->GetChunkX(), a_Entity->GetChunkZ()); - if (Chunk == 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() - ); - return; - } - if (!Chunk->HasEntity(a_Entity->GetUniqueID())) - { - Chunk->AddEntity(std::move(a_Entity)); - } + auto & Chunk = ConstructChunk(a_Player->GetChunkX(), a_Player->GetChunkZ()); // Always construct the chunk for players + ASSERT(!Chunk.HasEntity(a_Player->GetUniqueID())); + Chunk.AddEntity(std::move(a_Player)); } |