Merge pull request #5648 from Elron103/pull-requests
Core/Misc: Add a validity check for coordinates, prevents possible crashes with invalid coordinates
This commit is contained in:
@@ -2741,6 +2741,14 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
|||||||
pos.m_positionZ += 2.0f;
|
pos.m_positionZ += 2.0f;
|
||||||
destx = pos.m_positionX + dist * cos(angle);
|
destx = pos.m_positionX + dist * cos(angle);
|
||||||
desty = pos.m_positionY + dist * sin(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);
|
ground = GetMap()->GetHeight(GetPhaseMask(), destx, desty, MAX_HEIGHT, true);
|
||||||
floor = GetMap()->GetHeight(GetPhaseMask(), destx, desty, pos.m_positionZ, true);
|
floor = GetMap()->GetHeight(GetPhaseMask(), destx, desty, pos.m_positionZ, true);
|
||||||
destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
|
destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
|
||||||
|
|||||||
Reference in New Issue
Block a user