From c58a199db80fd3d24075582d239f782416c78de1 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 26 Dec 2008 15:46:10 -0600 Subject: [PATCH] *Try to fix the bug about crash caused by waypoint. --HG-- branch : trunk --- src/game/WaypointMovementGenerator.cpp | 12 +++++++++--- src/game/WaypointMovementGenerator.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index 85ef44b51b..67c56d763b 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -36,11 +36,17 @@ void WaypointMovementGenerator::Initialize(Creature &u) { u.StopMoving(); - i_nextMoveTime.Reset(0); - i_currentNode = -1; if(!path_id) path_id = u.GetWaypointPath(); - waypoints = WaypointMgr.GetPath(path_id); + waypoints = WaypointMgr.GetPath(path_id); + if(waypoints && waypoints->size()) + { + Traveller traveller(unit); + node = *(waypoints->at(i_currentNode)); + InitTraveller(u,node); + i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z); + i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); + } } template<> diff --git a/src/game/WaypointMovementGenerator.h b/src/game/WaypointMovementGenerator.h index 5e01984d42..99d111063d 100644 --- a/src/game/WaypointMovementGenerator.h +++ b/src/game/WaypointMovementGenerator.h @@ -81,7 +81,7 @@ class TRINITY_DLL_SPEC WaypointMovementGenerator private: WaypointData node; - uint32 i_currentNode, path_id; + uint32 path_id; TimeTrackerSmall i_nextMoveTime; WaypointPath *waypoints; bool repeating, StopedByPlayer;