fix: Fixes returning min distance from GetXInRangeByDistance (#2280)
This commit is contained in:
parent
06443ba0ca
commit
ad26ab6260
3 changed files with 9 additions and 9 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue