diff options
author | madmaxoft <github@xoft.cz> | 2014-08-30 22:17:49 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-08-30 22:17:49 +0200 |
commit | 26b8471280b876f624abb07db6616e67c11f5faa (patch) | |
tree | e058274eb79850074b2502a0a39a72c9b37e08fc /src/SetChunkData.cpp | |
parent | Updated Core (diff) | |
parent | WSSAnvil: Removed leftover debugging code. (diff) | |
download | cuberite-26b8471280b876f624abb07db6616e67c11f5faa.tar cuberite-26b8471280b876f624abb07db6616e67c11f5faa.tar.gz cuberite-26b8471280b876f624abb07db6616e67c11f5faa.tar.bz2 cuberite-26b8471280b876f624abb07db6616e67c11f5faa.tar.lz cuberite-26b8471280b876f624abb07db6616e67c11f5faa.tar.xz cuberite-26b8471280b876f624abb07db6616e67c11f5faa.tar.zst cuberite-26b8471280b876f624abb07db6616e67c11f5faa.zip |
Diffstat (limited to 'src/SetChunkData.cpp')
-rw-r--r-- | src/SetChunkData.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp index af6ad1251..97903074a 100644 --- a/src/SetChunkData.cpp +++ b/src/SetChunkData.cpp @@ -5,6 +5,7 @@ #include "Globals.h" #include "SetChunkData.h" +#include "BlockEntities/BlockEntity.h" @@ -116,3 +117,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++; + m_BlockEntities.erase(itr); + delete *itr; + itr = itr2; + } + else + { + // Good blocktype, keep the block entity: + ++itr; + } + } // for itr - m_BlockEntities[] +} + + + + |