Skip to content

Commit

Permalink
Fix Areas, I think
Browse files Browse the repository at this point in the history
  • Loading branch information
Mishura4 committed Jun 14, 2024
1 parent 507a728 commit fd55949
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions GameServer/world/Area.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using DOL.Language;
using System.Numerics;
using static DOL.GS.WarMapMgr;
using System.Drawing;

namespace DOL.GS
{
Expand Down Expand Up @@ -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;
}

Expand All @@ -257,15 +258,20 @@ public override bool IsContaining(Coordinate point, bool checkZ)
/// <inheritdoc />
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)
Expand Down

0 comments on commit fd55949

Please sign in to comment.