diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-12-24 16:27:44 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-12-26 18:55:45 +0100 |
commit | 9fcd2d4210d6928fa974adc82e289472a9b4f181 (patch) | |
tree | 0836b9d729c502d2ae006764609c57e09acfed15 /src/Chunk.cpp | |
parent | Silverfish: correct search cube (diff) | |
download | cuberite-9fcd2d4210d6928fa974adc82e289472a9b4f181.tar cuberite-9fcd2d4210d6928fa974adc82e289472a9b4f181.tar.gz cuberite-9fcd2d4210d6928fa974adc82e289472a9b4f181.tar.bz2 cuberite-9fcd2d4210d6928fa974adc82e289472a9b4f181.tar.lz cuberite-9fcd2d4210d6928fa974adc82e289472a9b4f181.tar.xz cuberite-9fcd2d4210d6928fa974adc82e289472a9b4f181.tar.zst cuberite-9fcd2d4210d6928fa974adc82e289472a9b4f181.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Chunk.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index eb44828e2..fc128b31c 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -262,6 +262,9 @@ void cChunk::MarkLoadFailed(void) { ASSERT(m_Presence == cpQueued); + // Mark dirty before generating, so that we get saved and don't have to later generate again: + MarkDirty(); + // The chunk is always needed, generate it: m_World->GetGenerator().QueueGenerateChunk({m_PosX, m_PosZ}, false); } @@ -307,6 +310,25 @@ void cChunk::SetAllData(cSetChunkData & a_SetChunkData) m_ChunkData.Assign(std::move(a_SetChunkData.GetChunkData())); m_IsLightValid = a_SetChunkData.IsLightValid(); + // Entities need some extra steps to destroy, so here we're keeping the old ones. + // Move the entities already in the chunk, including player entities, so that we don't lose any: + a_SetChunkData.GetEntities().insert( + a_SetChunkData.GetEntities().end(), + std::make_move_iterator(m_Entities.begin()), + std::make_move_iterator(m_Entities.end()) + ); + + // Store the augmented result: + m_Entities = std::move(a_SetChunkData.GetEntities()); + + // Set all the entity variables again: + for (const auto & Entity : m_Entities) + { + Entity->SetWorld(m_World); + Entity->SetParentChunk(this); + Entity->SetIsTicking(true); + } + // Clear the block entities present - either the loader / saver has better, or we'll create empty ones: m_BlockEntities = std::move(a_SetChunkData.GetBlockEntities()); |