From fd55949a3b980fb7f49fa40c53d5736406c4eec9 Mon Sep 17 00:00:00 2001 From: Amber Ehrlich Date: Fri, 14 Jun 2024 18:27:14 -0400 Subject: [PATCH] Fix Areas, I think --- GameServer/world/Area.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/GameServer/world/Area.cs b/GameServer/world/Area.cs index 975e452b..0324811e 100644 --- a/GameServer/world/Area.cs +++ b/GameServer/world/Area.cs @@ -26,6 +26,7 @@ using DOL.Language; using System.Numerics; using static DOL.GS.WarMapMgr; +using System.Drawing; namespace DOL.GS { @@ -244,10 +245,10 @@ public override bool IsContaining(Coordinate point, bool checkZ) var diff = point - Coordinate; // check if spot is in circle - var m_distSq = diff.X * diff.X + diff.Y * diff.Y; + double m_distSq = (double)diff.X * diff.X + (double)diff.Y * diff.Y; if (Coordinate.Z != 0 && point.Z != 0 && checkZ) { - int m_zdiff = point.Z - Coordinate.Z; + double m_zdiff = point.Z - Coordinate.Z; m_distSq += m_zdiff * m_zdiff; } @@ -257,15 +258,20 @@ public override bool IsContaining(Coordinate point, bool checkZ) /// public override float DistanceSquared(Coordinate position, bool checkZ) { - var direction = position - Coordinate; - float radiusSquared = Radius * Radius; - var distanceToCenterSquared = (float)(checkZ ? direction.Length : direction.Length2D); + var diff = position - Coordinate; + double radiusSquared = Radius * Radius; + double m_distSq = (double)diff.X * diff.X + (double)diff.Y * diff.Y; + if (Coordinate.Z != 0 && position.Z != 0 && checkZ) + { + double m_zdiff = position.Z - Coordinate.Z; + m_distSq += m_zdiff * m_zdiff; + } - if (distanceToCenterSquared < radiusSquared) // Inside + if (m_distSq < radiusSquared) // Inside { return 0.0f; } - return distanceToCenterSquared - radiusSquared; + return (float)(m_distSq - radiusSquared); } public override void LoadFromDatabase(DBArea area)