fix: Fixes returning min distance from GetXInRangeByDistance (#2280)

This commit is contained in:
Kamron Batman 2025-11-28 11:56:06 -08:00 committed by GitHub
parent 06443ba0ca
commit ad26ab6260
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 9 deletions

View file

@ -173,7 +173,7 @@ public partial class Map
if (current != null)
{
_minDistance = MinDistSqToSectorRect(_center.m_X, _center.m_Y, _currentSectorX, _currentSectorY);
_minDistance = MinDistToSectorSqrt(_center.m_X, _center.m_Y, _currentSectorX, _currentSectorY);
}
}
@ -266,7 +266,7 @@ public partial class Map
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int MinDistSqToSectorRect(int cx, int cy, int sectorX, int sectorY)
private static int MinDistToSectorSqrt(int cx, int cy, int sectorX, int sectorY)
{
var x0 = sectorX * SectorSize;
var y0 = sectorY * SectorSize;
@ -293,7 +293,7 @@ public partial class Map
dy = cy - y1;
}
return dx * dx + dy * dy;
return (int)Math.Sqrt(dx * dx + dy * dy);
}
}
}

View file

@ -201,7 +201,7 @@ public partial class Map
if (current != null)
{
_minDistance = MinDistSqToSectorRect(_center.m_X, _center.m_Y, _currentSectorX, _currentSectorY);
_minDistance = MinDistToSectorSqrt(_center.m_X, _center.m_Y, _currentSectorX, _currentSectorY);
}
}
@ -292,7 +292,7 @@ public partial class Map
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int MinDistSqToSectorRect(int cx, int cy, int sectorX, int sectorY)
private static int MinDistToSectorSqrt(int cx, int cy, int sectorX, int sectorY)
{
var x0 = sectorX * SectorSize;
var y0 = sectorY * SectorSize;
@ -319,7 +319,7 @@ public partial class Map
dy = cy - y1;
}
return dx * dx + dy * dy;
return (int)Math.Sqrt(dx * dx + dy * dy);
}
}
}

View file

@ -196,7 +196,7 @@ public partial class Map
if (current != null)
{
_minDistance = MinDistSqToSectorRect(_center.m_X, _center.m_Y, _currentSectorX, _currentSectorY);
_minDistance = MinDistToSectorSqrt(_center.m_X, _center.m_Y, _currentSectorX, _currentSectorY);
}
}
@ -287,7 +287,7 @@ public partial class Map
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int MinDistSqToSectorRect(int cx, int cy, int sectorX, int sectorY)
private static int MinDistToSectorSqrt(int cx, int cy, int sectorX, int sectorY)
{
var x0 = sectorX * SectorSize;
var y0 = sectorY * SectorSize;
@ -314,7 +314,7 @@ public partial class Map
dy = cy - y1;
}
return dx * dx + dy * dy;
return (int)Math.Sqrt(dx * dx + dy * dy);
}
}
}