diff options
3 files changed, 22 insertions, 13 deletions
diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 19b4e2b6197..07623c3a261 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -71,7 +71,7 @@ void MotionMaster::Initialize() // clear ALL movement generators (including default) while (!empty()) { - MovementGenerator *curr = top(); + MovementGenerator* curr = top(); pop(); if (curr) DirectDelete(curr); diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 8780531443b..abd813c849f 100644 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -29,7 +29,7 @@ #include "WaypointManager.h" #include "World.h" -WaypointMovementGenerator<Creature>::WaypointMovementGenerator(uint32 pathId /*= 0*/, bool repeating /*= true*/) : _nextMoveTime(0), _recalculateSpeed(false), _isArrivalDone(false), _pathId(pathId), _repeating(repeating), _loadedFromDB(true), _stalled(false) +WaypointMovementGenerator<Creature>::WaypointMovementGenerator(uint32 pathId /*= 0*/, bool repeating /*= true*/) : _nextMoveTime(0), _recalculateSpeed(false), _isArrivalDone(false), _pathId(pathId), _repeating(repeating), _loadedFromDB(true), _stalled(false), _done(false) { } @@ -43,6 +43,7 @@ WaypointMovementGenerator<Creature>::WaypointMovementGenerator(WaypointPath& pat _repeating = repeating; _loadedFromDB = false; _stalled = false; + _done = false; } WaypointMovementGenerator<Creature>::~WaypointMovementGenerator() @@ -75,6 +76,7 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature) void WaypointMovementGenerator<Creature>::DoInitialize(Creature* creature) { + _done = false; LoadPath(creature); } @@ -86,8 +88,14 @@ void WaypointMovementGenerator<Creature>::DoFinalize(Creature* creature) void WaypointMovementGenerator<Creature>::DoReset(Creature* creature) { - if (CanMove(creature)) + if (!_done && CanMove(creature)) StartMoveNow(creature); + else if (_done) + { + // mimic IdleMovementGenerator + if (!creature->IsStopped()) + creature->StopMoving(); + } } void WaypointMovementGenerator<Creature>::OnArrived(Creature* creature) @@ -124,10 +132,10 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature* creature) bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature) { if (!creature || !creature->IsAlive()) - return false; + return true; - if (!_path || _path->nodes.empty()) - return false; + if (_done || !_path || _path->nodes.empty()) + return true; // if the owner is the leader of its formation, check members status if (creature->IsFormationLeader() && !creature->IsFormationLeaderMoveAllowed()) @@ -164,7 +172,8 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature) transportPath = false; // else if (vehicle) - this should never happen, vehicle offsets are const } - return false; + _done = true; + return true; } _currentNode = (_currentNode + 1) % _path->nodes.size(); @@ -236,7 +245,10 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature) bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 diff) { if (!creature || !creature->IsAlive()) - return false; + return true; + + if (_done || !_path || _path->nodes.empty()) + return true; if (_stalled || creature->HasUnitState(UNIT_STATE_NOT_MOVE) || creature->IsMovementPreventedByCasting()) { @@ -244,10 +256,6 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di return true; } - // prevent a crash at empty waypoint path. - if (!_path || _path->nodes.empty()) - return false; - if (!_nextMoveTime.Passed()) { _nextMoveTime.Update(diff); @@ -274,7 +282,7 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di StartMove(creature); } } - return true; + return true; } void WaypointMovementGenerator<Creature>::MovementInform(Creature* creature) diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h index f6d3b6a3c9e..e8cfbb0c094 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h @@ -91,6 +91,7 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creat bool _repeating; bool _loadedFromDB; bool _stalled; + bool _done; }; /** |
