diff options
author | Mattes D <github@xoft.cz> | 2014-04-02 21:26:45 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-04-02 21:26:45 +0200 |
commit | e7b8e17746de3b03f16e572bd4f4cd239bcd126a (patch) | |
tree | 868c65755c11c2cb8c46968529a57071a69f8eb7 /src/Mobs | |
parent | Fixed boat placement code. (diff) | |
parent | With eXtra line! (diff) | |
download | cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.gz cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.bz2 cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.lz cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.xz cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.zst cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.zip |
Diffstat (limited to 'src/Mobs')
-rw-r--r-- | src/Mobs/Monster.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index d3e0f1c26..aa6071515 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -111,9 +111,9 @@ void cMonster::SpawnOn(cClientHandle & a_Client) void cMonster::TickPathFinding() { - int PosX = (int)floor(GetPosX()); - int PosY = (int)floor(GetPosY()); - int PosZ = (int)floor(GetPosZ()); + const int PosX = (int)floor(GetPosX()); + const int PosY = (int)floor(GetPosY()); + const int PosZ = (int)floor(GetPosZ()); m_FinalDestination.y = (double)FindFirstNonAirBlockPosition(m_FinalDestination.x, m_FinalDestination.z); @@ -130,14 +130,16 @@ void cMonster::TickPathFinding() { 0, 1}, { 0,-1}, } ; + + if ((PosY - 1 < 0) || (PosY + 2 > cChunkDef::Height) /* PosY + 1 will never be true if PosY + 2 is not */) + { + // Too low/high, can't really do anything + FinishPathFinding(); + return; + } for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) { - if ((gCrossCoords[i].x + PosX == PosX) && (gCrossCoords[i].z + PosZ == PosZ)) - { - continue; - } - if (IsCoordinateInTraversedList(Vector3i(gCrossCoords[i].x + PosX, PosY, gCrossCoords[i].z + PosZ))) { continue; |