Mobs: Fixed crash with terrain too high.
This commit is contained in:
parent
564b9ad337
commit
1240e583d2
@ -160,7 +160,7 @@ void cMonster::TickPathFinding()
|
|||||||
BLOCKTYPE BlockAtYP = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY + 1, gCrossCoords[i].z + PosZ);
|
BLOCKTYPE BlockAtYP = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY + 1, gCrossCoords[i].z + PosZ);
|
||||||
BLOCKTYPE BlockAtYPP = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY + 2, gCrossCoords[i].z + PosZ);
|
BLOCKTYPE BlockAtYPP = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY + 2, gCrossCoords[i].z + PosZ);
|
||||||
int LowestY = FindFirstNonAirBlockPosition(gCrossCoords[i].x + PosX, gCrossCoords[i].z + PosZ);
|
int LowestY = FindFirstNonAirBlockPosition(gCrossCoords[i].x + PosX, gCrossCoords[i].z + PosZ);
|
||||||
BLOCKTYPE BlockAtLowestY = m_World->GetBlock(gCrossCoords[i].x + PosX, LowestY, gCrossCoords[i].z + PosZ);
|
BLOCKTYPE BlockAtLowestY = (LowestY >= cChunkDef::Height) ? E_BLOCK_AIR : m_World->GetBlock(gCrossCoords[i].x + PosX, LowestY, gCrossCoords[i].z + PosZ);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(!cBlockInfo::IsSolid(BlockAtY)) &&
|
(!cBlockInfo::IsSolid(BlockAtY)) &&
|
||||||
@ -453,7 +453,7 @@ int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))) && (PosY < cChunkDef::Height))
|
while ((PosY < cChunkDef::Height) && cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))))
|
||||||
{
|
{
|
||||||
PosY++;
|
PosY++;
|
||||||
}
|
}
|
||||||
|
@ -169,10 +169,12 @@ protected:
|
|||||||
/** Stores if mobile is currently moving towards the ultimate, final destination */
|
/** Stores if mobile is currently moving towards the ultimate, final destination */
|
||||||
bool m_bMovingToDestination;
|
bool m_bMovingToDestination;
|
||||||
|
|
||||||
/** Finds the first non-air block position (not the highest, as cWorld::GetHeight does)
|
/** Finds the lowest non-air block position (not the highest, as cWorld::GetHeight does)
|
||||||
If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1
|
If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1
|
||||||
If current Y is solid, goes up to find first nonsolid block, and returns that */
|
If current Y is solid, goes up to find first nonsolid block, and returns that.
|
||||||
|
If no suitable position is found, returns cChunkDef::Height. */
|
||||||
int FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ);
|
int FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ);
|
||||||
|
|
||||||
/** Returns if a monster can actually reach a given height by jumping or walking */
|
/** Returns if a monster can actually reach a given height by jumping or walking */
|
||||||
inline bool IsNextYPosReachable(int a_PosY)
|
inline bool IsNextYPosReachable(int a_PosY)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user