summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiLSPACE <NiLSPACE@users.noreply.github.com>2015-05-09 00:51:34 +0200
committerNiLSPACE <NiLSPACE@users.noreply.github.com>2015-05-09 00:51:34 +0200
commit4d459d39eecf183171b42de83ca0333bd604d3b6 (patch)
tree90e1091c4b21ca5bbd980cd7029423111b7b1e6c
parentMerge pull request #1945 from Woazboat/CodeCleanup_refactored (diff)
parentMove chunk position accesses after the chunk validity checks (diff)
downloadcuberite-4d459d39eecf183171b42de83ca0333bd604d3b6.tar
cuberite-4d459d39eecf183171b42de83ca0333bd604d3b6.tar.gz
cuberite-4d459d39eecf183171b42de83ca0333bd604d3b6.tar.bz2
cuberite-4d459d39eecf183171b42de83ca0333bd604d3b6.tar.lz
cuberite-4d459d39eecf183171b42de83ca0333bd604d3b6.tar.xz
cuberite-4d459d39eecf183171b42de83ca0333bd604d3b6.tar.zst
cuberite-4d459d39eecf183171b42de83ca0333bd604d3b6.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Monster.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 84f58ff85..9df5bd930 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -264,12 +264,14 @@ bool cMonster::EnsureProperDestination(cChunk & a_Chunk)
cChunk * Chunk = a_Chunk.GetNeighborChunk(m_FinalDestination.x, m_FinalDestination.z);
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
- int RelX = m_FinalDestination.x - Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = m_FinalDestination.z - Chunk->GetPosZ() * cChunkDef::Width;
+
if ((Chunk == nullptr) || !Chunk->IsValid())
{
return false;
}
+
+ int RelX = m_FinalDestination.x - Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = m_FinalDestination.z - Chunk->GetPosZ() * cChunkDef::Width;
// If destination in the air, go down to the lowest air block.
while (m_FinalDestination.y > 0)