diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-08-10 19:24:50 +0200 |
---|---|---|
committer | peterbell10 <peterbell10@live.co.uk> | 2017-08-10 20:06:37 +0200 |
commit | 0979cd8f17ced73ca56f00026b798faf077254ca (patch) | |
tree | 55fc0b407583fc8a390f741ec849d90353997788 /src/Chunk.cpp | |
parent | Update copyright dates and contributors message (#3907) (diff) | |
download | cuberite-0979cd8f17ced73ca56f00026b798faf077254ca.tar cuberite-0979cd8f17ced73ca56f00026b798faf077254ca.tar.gz cuberite-0979cd8f17ced73ca56f00026b798faf077254ca.tar.bz2 cuberite-0979cd8f17ced73ca56f00026b798faf077254ca.tar.lz cuberite-0979cd8f17ced73ca56f00026b798faf077254ca.tar.xz cuberite-0979cd8f17ced73ca56f00026b798faf077254ca.tar.zst cuberite-0979cd8f17ced73ca56f00026b798faf077254ca.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Chunk.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 3b9739907..a55a967e0 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1770,16 +1770,20 @@ void cChunk::AddBlockEntityClean(cBlockEntity * a_BlockEntity) cBlockEntity * cChunk::GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ) { - // Check that the query coords are within chunk bounds: - ASSERT(a_BlockX >= m_PosX * cChunkDef::Width); - ASSERT(a_BlockX < m_PosX * cChunkDef::Width + cChunkDef::Width); - ASSERT(a_BlockZ >= m_PosZ * cChunkDef::Width); - ASSERT(a_BlockZ < m_PosZ * cChunkDef::Width + cChunkDef::Width); - int RelX = a_BlockX - m_PosX * cChunkDef::Width; int RelZ = a_BlockZ - m_PosZ * cChunkDef::Width; - auto itr = m_BlockEntities.find(MakeIndex(RelX, a_BlockY, RelZ)); + if ( + !IsValidWidth (RelX) || + !IsValidHeight(a_BlockY) || + !IsValidWidth (RelZ) + ) + { + // Coordinates are outside outside the world, no block entities here + return nullptr; + } + + auto itr = m_BlockEntities.find(MakeIndexNoCheck(RelX, a_BlockY, RelZ)); return (itr == m_BlockEntities.end()) ? nullptr : itr->second; } |