Core/MMaps: Add several safety checks to confirm a valid path generation.
- Address some issues in TargetMovementGenerator. Thanks Chevron
This commit is contained in:
@@ -58,8 +58,12 @@ bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool fo
|
||||
if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z))
|
||||
return false;
|
||||
|
||||
float newDestZ = _sourceUnit->GetBaseMap()->GetHeight(_sourceUnit->GetPhaseMask(), x, y, z, true, MAX_FALL_DISTANCE);
|
||||
if (newDestZ >= INVALID_HEIGHT)
|
||||
return false;
|
||||
|
||||
Vector3 oldDest = GetEndPosition();
|
||||
Vector3 dest(destX, destY, destZ);
|
||||
Vector3 dest(destX, destY, newDestZ);
|
||||
SetEndPosition(dest);
|
||||
|
||||
Vector3 start(x, y, z);
|
||||
@@ -124,7 +128,7 @@ dtPolyRef PathGenerator::GetPathPolyByPosition(dtPolyRef const* polyPath, uint32
|
||||
minDist3d = dtVdistSqr(point, closestPoint);
|
||||
}
|
||||
|
||||
if(minDist2d < 1.0f) // shortcut out - close enough for us
|
||||
if (minDist2d < 1.0f) // shortcut out - close enough for us
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user