diff --git a/zone/npc.h b/zone/npc.h index 55b613289..4491d5e6c 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -282,7 +282,7 @@ public: void ResumeWandering(); void PauseWandering(int pausetime); void MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot); - void GetClosestWaypoint(std::list &wp_list, int count, float m_x, float m_y, float m_z); + void GetClosestWaypoint(std::list &wp_list, int count, const xyz_location& location ); uint32 GetEquipment(uint8 material_slot) const; // returns item id int32 GetEquipmentMaterial(uint8 material_slot) const; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index e3193c2c8..51f68e952 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -260,7 +260,7 @@ void NPC::CalculateNewWaypoint() case 1: //10 closest { std::list closest; - GetClosestWaypoint(closest, 10, GetX(), GetY(), GetZ()); + GetClosestWaypoint(closest, 10, GetPosition()); std::list::iterator iter = closest.begin(); if(closest.size() != 0) { @@ -316,7 +316,7 @@ void NPC::CalculateNewWaypoint() case 5: //pick random closest 5 and pick one that's in sight { std::list closest; - GetClosestWaypoint(closest, 5, GetX(), GetY(), GetZ()); + GetClosestWaypoint(closest, 5, GetPosition()); std::list::iterator iter = closest.begin(); while(iter != closest.end()) @@ -357,7 +357,7 @@ bool wp_distance_pred(const wp_distance& left, const wp_distance& right) return left.dist < right.dist; } -void NPC::GetClosestWaypoint(std::list &wp_list, int count, float m_x, float m_y, float m_z) +void NPC::GetClosestWaypoint(std::list &wp_list, int count, const xyz_location& location) { wp_list.clear(); if(Waypoints.size() <= count) @@ -372,11 +372,11 @@ void NPC::GetClosestWaypoint(std::list &wp_list, int count, float m_x, f std::list distances; for(int i = 0; i < Waypoints.size(); ++i) { - float cur_x = (Waypoints[i].x - m_x); + float cur_x = (Waypoints[i].x - location.m_X); cur_x *= cur_x; - float cur_y = (Waypoints[i].y - m_y); + float cur_y = (Waypoints[i].y - location.m_Y); cur_y *= cur_y; - float cur_z = (Waypoints[i].z - m_z); + float cur_z = (Waypoints[i].z - location.m_Z); cur_z *= cur_z; float cur_dist = cur_x + cur_y + cur_z; wp_distance w_dist;