From 592db69c0ccd38c1c339c9ce2390743a0dbeb08d Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 14 May 2009 20:09:30 +0400 Subject: [PATCH] [7827] dd support 2d version for WorldObject::GetDistanceOrder. --- src/game/Object.cpp | 18 +++++++++++++----- src/game/Object.h | 2 +- src/shared/revision_nr.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 10b2ed8a5..1478ff971 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1162,17 +1162,25 @@ bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const return vMapManager->isInLineOfSight(GetMapId(), x, y, z+2.0f, ox, oy, oz+2.0f); } -bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2) const +bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D /* = true */) const { float dx1 = GetPositionX() - obj1->GetPositionX(); float dy1 = GetPositionY() - obj1->GetPositionY(); - float dz1 = GetPositionZ() - obj1->GetPositionZ(); - float distsq1 = dx1*dx1 + dy1*dy1 + dz1*dz1; + float distsq1 = dx1*dx1 + dy1*dy1; + if(is3D) + { + float dz1 = GetPositionZ() - obj1->GetPositionZ(); + distsq1 += dz1*dz1; + } float dx2 = GetPositionX() - obj2->GetPositionX(); float dy2 = GetPositionY() - obj2->GetPositionY(); - float dz2 = GetPositionZ() - obj2->GetPositionZ(); - float distsq2 = dx2*dx2 + dy2*dy2 + dz2*dz2; + float distsq2 = dx2*dx2 + dy2*dy2; + if(is3D) + { + float dz2 = GetPositionZ() - obj2->GetPositionZ(); + distsq2 += dz2*dz2; + } return distsq1 < distsq2; } diff --git a/src/game/Object.h b/src/game/Object.h index 42ffdee2d..e9953d797 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -446,7 +446,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object } bool IsWithinLOS(float x, float y, float z) const; bool IsWithinLOSInMap(const WorldObject* obj) const; - bool GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2) const; + bool GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D = true) const; bool IsInRange(WorldObject const* obj, float minRange, float maxRange) const; bool IsInRange2d(float x, float y, float minRange, float maxRange) const; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e6f9a434b..c2ab7f32e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7826" + #define REVISION_NR "7827" #endif // __REVISION_NR_H__