mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-26 20:02:25 +01:00
Core/Misc: Add a validity check for coordinates, prevents crashes
This commit is contained in:
@@ -2674,6 +2674,14 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
pos.m_positionZ += 2.0f;
|
||||
destx = pos.m_positionX + dist * cos(angle);
|
||||
desty = pos.m_positionY + dist * sin(angle);
|
||||
|
||||
// Prevent invalid coordinates here, position is unchanged
|
||||
if (!Trinity::IsValidMapCoord(destx, desty))
|
||||
{
|
||||
sLog->outCrash("WorldObject::MovePositionToFirstCollision invalid coordinates X: %f and Y: %f were passed!", destx, desty);
|
||||
return;
|
||||
}
|
||||
|
||||
ground = GetMap()->GetHeight(GetPhaseMask(), destx, desty, MAX_HEIGHT, true);
|
||||
floor = GetMap()->GetHeight(GetPhaseMask(), destx, desty, pos.m_positionZ, true);
|
||||
destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
|
||||
|
||||
Reference in New Issue
Block a user