summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/SetChunkData.cpp8
-rw-r--r--src/SetChunkData.h10
-rw-r--r--src/World.cpp2
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp2
4 files changed, 12 insertions, 10 deletions
diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp
index 5a0bea980..f2b58570d 100644
--- a/src/SetChunkData.cpp
+++ b/src/SetChunkData.cpp
@@ -33,8 +33,8 @@ cSetChunkData::cSetChunkData(
const NIBBLETYPE * a_SkyLight,
const cChunkDef::HeightMap * a_HeightMap,
const cChunkDef::BiomeMap * a_Biomes,
- cEntityList & a_Entities,
- cBlockEntityList & a_BlockEntities,
+ cEntityList && a_Entities,
+ cBlockEntityList && a_BlockEntities,
bool a_ShouldMarkDirty
) :
m_ChunkX(a_ChunkX),
@@ -84,8 +84,8 @@ cSetChunkData::cSetChunkData(
}
// Move entities and blockentities:
- std::swap(m_Entities, a_Entities);
- std::swap(m_BlockEntities, a_BlockEntities);
+ m_Entities = std::move(a_Entities);
+ m_BlockEntities = std::move(a_BlockEntities);
}
diff --git a/src/SetChunkData.h b/src/SetChunkData.h
index 1eeb75ca9..bf5283569 100644
--- a/src/SetChunkData.h
+++ b/src/SetChunkData.h
@@ -24,8 +24,10 @@ public:
/** Constructs a new instance based on data existing elsewhere, will copy all the memory. Prefer to use the
other constructor as much as possible.
- Will move the entity and blockentity lists into the internal storage, and empty the a_Entities and
- a_BlockEntities lists.
+ Will move the entity and blockentity lists into the internal storage, and invalidate a_Entities and
+ a_BlockEntities.
+ When passing an lvalue, a_Entities and a_BlockEntities must be explicitly converted to an rvalue beforehand
+ with std::move().
a_BlockTypes and a_BlockMetas must always be valid.
If either of the light arrays are nullptr, the chunk data will be marked as not having any light at all and
will be scheduled for re-lighting once it is set into the chunkmap.
@@ -41,8 +43,8 @@ public:
const NIBBLETYPE * a_SkyLight,
const cChunkDef::HeightMap * a_HeightMap,
const cChunkDef::BiomeMap * a_Biomes,
- cEntityList & a_Entities,
- cBlockEntityList & a_BlockEntities,
+ cEntityList && a_Entities,
+ cBlockEntityList && a_BlockEntities,
bool a_ShouldMarkDirty
);
diff --git a/src/World.cpp b/src/World.cpp
index a088f6eb1..8e1d0b33e 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -3712,7 +3712,7 @@ void cWorld::cChunkGeneratorCallbacks::OnChunkGenerated(cChunkDesc & a_ChunkDesc
a_ChunkDesc.GetBlockTypes(), BlockMetas,
nullptr, nullptr, // We don't have lighting, chunk will be lighted when needed
&a_ChunkDesc.GetHeightMap(), &a_ChunkDesc.GetBiomeMap(),
- a_ChunkDesc.GetEntities(), a_ChunkDesc.GetBlockEntities(),
+ std::move(a_ChunkDesc.GetEntities()), std::move(a_ChunkDesc.GetBlockEntities()),
true
));
SetChunkData->RemoveInvalidBlockEntities();
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 7244bcb73..948a0c9a0 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -431,7 +431,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
IsLightValid ? BlockLight : nullptr,
IsLightValid ? SkyLight : nullptr,
nullptr, Biomes,
- Entities, BlockEntities,
+ std::move(Entities), std::move(BlockEntities),
false
));
m_World->QueueSetChunkData(SetChunkData);