summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Monster.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-05-10 13:16:20 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-05-10 13:16:20 +0200
commit9c490293b88f9828577e5431c5151f7f1bec09f4 (patch)
treebe616a3c3b2db083b2f3908220818231778609ef /src/Mobs/Monster.cpp
parentFixed some warnings and logic errors in Monster.cpp (diff)
parentMerge pull request #1985 from SafwatHalaby/lessPathCalcs (diff)
downloadcuberite-9c490293b88f9828577e5431c5151f7f1bec09f4.tar
cuberite-9c490293b88f9828577e5431c5151f7f1bec09f4.tar.gz
cuberite-9c490293b88f9828577e5431c5151f7f1bec09f4.tar.bz2
cuberite-9c490293b88f9828577e5431c5151f7f1bec09f4.tar.lz
cuberite-9c490293b88f9828577e5431c5151f7f1bec09f4.tar.xz
cuberite-9c490293b88f9828577e5431c5151f7f1bec09f4.tar.zst
cuberite-9c490293b88f9828577e5431c5151f7f1bec09f4.zip
Diffstat (limited to 'src/Mobs/Monster.cpp')
-rw-r--r--src/Mobs/Monster.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 1cc6e7391..f3f8c6b24 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(FloorC(m_FinalDestination.x), FloorC(m_FinalDestination.z));
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
- int RelX = FloorC(m_FinalDestination.x) - Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = FloorC(m_FinalDestination.z) - Chunk->GetPosZ() * cChunkDef::Width;
+
if ((Chunk == nullptr) || !Chunk->IsValid())
{
return false;
}
+
+ int RelX = FloorC(m_FinalDestination.x) - Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = FloorC(m_FinalDestination.z) - Chunk->GetPosZ() * cChunkDef::Width;
// If destination in the air, go down to the lowest air block.
while (m_FinalDestination.y > 0)
@@ -958,7 +960,7 @@ cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType)
{
case mtMagmaCube:
{
- toReturn = new cMagmaCube(Random.NextInt(2) + 1);
+ toReturn = new cMagmaCube(1 << Random.NextInt(3)); // Size 1, 2 or 4
break;
}
case mtSlime: