diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-04-12 00:10:25 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-04-12 15:09:58 +0200 |
commit | 64778c6a397e08c2bfd20b6c3a7e54344a6e4a4b (patch) | |
tree | ed43c7ea29d1787272faf1c6910b0775244fb7f3 /src | |
parent | Added override specifiers to overridden functions. (diff) | |
download | cuberite-64778c6a397e08c2bfd20b6c3a7e54344a6e4a4b.tar cuberite-64778c6a397e08c2bfd20b6c3a7e54344a6e4a4b.tar.gz cuberite-64778c6a397e08c2bfd20b6c3a7e54344a6e4a4b.tar.bz2 cuberite-64778c6a397e08c2bfd20b6c3a7e54344a6e4a4b.tar.lz cuberite-64778c6a397e08c2bfd20b6c3a7e54344a6e4a4b.tar.xz cuberite-64778c6a397e08c2bfd20b6c3a7e54344a6e4a4b.tar.zst cuberite-64778c6a397e08c2bfd20b6c3a7e54344a6e4a4b.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Chunk.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index b16646d5a..aa2a2887c 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -253,9 +253,9 @@ void cChunk::OnUnload() } // Notify all block entities of imminent unload: - for (auto & BlockEntity : m_BlockEntities) + for (auto & KeyPair : m_BlockEntities) { - BlockEntity.second->OnRemoveFromWorld(); + KeyPair.second->OnRemoveFromWorld(); } } @@ -362,19 +362,26 @@ void cChunk::SetAllData(SetChunkData && a_SetChunkData) Entity->SetIsTicking(true); } - // Clear the block entities present - either the loader / saver has better, or we'll create empty ones: + // Remove the block entities present - either the loader / saver has better, or we'll create empty ones: + for (auto & KeyPair : m_BlockEntities) + { + KeyPair.second->Destroy(); + KeyPair.second->OnRemoveFromWorld(); + } + + // Clear the old ones: m_BlockEntities = std::move(a_SetChunkData.BlockEntities); // Check that all block entities have a valid blocktype at their respective coords (DEBUG-mode only): - #ifndef NDEBUG - for (auto & KeyPair : m_BlockEntities) - { - cBlockEntity * Block = KeyPair.second.get(); - BLOCKTYPE EntityBlockType = Block->GetBlockType(); - BLOCKTYPE WorldBlockType = GetBlock(Block->GetRelX(), Block->GetPosY(), Block->GetRelZ()); - ASSERT(WorldBlockType == EntityBlockType); - } // for KeyPair - m_BlockEntities - #endif // !NDEBUG +#ifndef NDEBUG + for (auto & KeyPair : m_BlockEntities) + { + cBlockEntity * Block = KeyPair.second.get(); + BLOCKTYPE EntityBlockType = Block->GetBlockType(); + BLOCKTYPE WorldBlockType = GetBlock(Block->GetRelX(), Block->GetPosY(), Block->GetRelZ()); + ASSERT(WorldBlockType == EntityBlockType); + } +#endif // Set all block entities' World variable: for (auto & KeyPair : m_BlockEntities) |