Core/MMaps: Add several safety checks to confirm a valid path generation.

- Address some issues in TargetMovementGenerator. Thanks Chevron
This commit is contained in:
kaelima
2012-09-07 04:21:11 +02:00
parent 0522e50c86
commit a2d533752c
8 changed files with 46 additions and 40 deletions
+6 -2
View File
@@ -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;
}