summaryrefslogtreecommitdiffstats
path: root/src/SetChunkData.cpp
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2014-10-11 19:32:21 +0200
committerAlexander Harkness <bearbin@gmail.com>2014-10-11 19:32:21 +0200
commit93833069a80fe4aec33a95148df39ad40671ddaf (patch)
tree2e6a335a60e618b5fe456ca8a586a2c5448c8c87 /src/SetChunkData.cpp
parentReverted submodule changes. (diff)
parentMerge pull request #1528 from kjanku1/master (diff)
downloadcuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.gz
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.bz2
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.lz
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.xz
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.zst
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.zip
Diffstat (limited to 'src/SetChunkData.cpp')
-rw-r--r--src/SetChunkData.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp
index 6e0c2733e..707dfb9e8 100644
--- a/src/SetChunkData.cpp
+++ b/src/SetChunkData.cpp
@@ -5,6 +5,7 @@
#include "Globals.h"
#include "SetChunkData.h"
+#include "BlockEntities/BlockEntity.h"
@@ -13,6 +14,9 @@
cSetChunkData::cSetChunkData(int a_ChunkX, int a_ChunkZ, bool a_ShouldMarkDirty) :
m_ChunkX(a_ChunkX),
m_ChunkZ(a_ChunkZ),
+ m_IsLightValid(false),
+ m_IsHeightMapValid(false),
+ m_AreBiomesValid(false),
m_ShouldMarkDirty(a_ShouldMarkDirty)
{
}
@@ -40,7 +44,6 @@ cSetChunkData::cSetChunkData(
// Check the params' validity:
ASSERT(a_BlockTypes != NULL);
ASSERT(a_BlockMetas != NULL);
- ASSERT(a_Biomes != NULL);
// Copy block types and metas:
memcpy(m_BlockTypes, a_BlockTypes, sizeof(cChunkDef::BlockTypes));
@@ -113,3 +116,35 @@ void cSetChunkData::CalculateHeightMap(void)
+
+void cSetChunkData::RemoveInvalidBlockEntities(void)
+{
+ for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end();)
+ {
+ BLOCKTYPE EntityBlockType = (*itr)->GetBlockType();
+ BLOCKTYPE WorldBlockType = cChunkDef::GetBlock(m_BlockTypes, (*itr)->GetRelX(), (*itr)->GetPosY(), (*itr)->GetRelZ());
+ if (EntityBlockType != WorldBlockType)
+ {
+ // Bad blocktype, remove the block entity:
+ LOGD("Block entity blocktype mismatch at {%d, %d, %d}: entity for blocktype %s(%d) in block %s(%d). Deleting the block entity.",
+ (*itr)->GetPosX(), (*itr)->GetPosY(), (*itr)->GetPosZ(),
+ ItemTypeToString(EntityBlockType).c_str(), EntityBlockType,
+ ItemTypeToString(WorldBlockType).c_str(), WorldBlockType
+ );
+ cBlockEntityList::iterator itr2 = itr;
+ itr2++;
+ delete *itr;
+ m_BlockEntities.erase(itr);
+ itr = itr2;
+ }
+ else
+ {
+ // Good blocktype, keep the block entity:
+ ++itr;
+ }
+ } // for itr - m_BlockEntities[]
+}
+
+
+
+