diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-09-02 20:11:38 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-09-02 20:11:38 +0200 |
commit | e431bb4e63b03a4137e4264beccfab0fffea6e36 (patch) | |
tree | e5442606b9e5be82070dc733b6162a76ed89ac87 /src/SetChunkData.cpp | |
parent | Changed the IsEnchantable() comment. (diff) | |
parent | Re-added alternate spellings of darkgraywool. (diff) | |
download | cuberite-e431bb4e63b03a4137e4264beccfab0fffea6e36.tar cuberite-e431bb4e63b03a4137e4264beccfab0fffea6e36.tar.gz cuberite-e431bb4e63b03a4137e4264beccfab0fffea6e36.tar.bz2 cuberite-e431bb4e63b03a4137e4264beccfab0fffea6e36.tar.lz cuberite-e431bb4e63b03a4137e4264beccfab0fffea6e36.tar.xz cuberite-e431bb4e63b03a4137e4264beccfab0fffea6e36.tar.zst cuberite-e431bb4e63b03a4137e4264beccfab0fffea6e36.zip |
Diffstat (limited to '')
-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..bfe59fbcb 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++; + delete *itr; + m_BlockEntities.erase(itr); + itr = itr2; + } + else + { + // Good blocktype, keep the block entity: + ++itr; + } + } // for itr - m_BlockEntities[] +} + + + + |