aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2017-08-12 19:43:37 +0200
committerccrs <ccrs@users.noreply.github.com>2017-08-12 19:43:37 +0200
commiteb2769996f01bfd7d7118503a44705711eb309a3 (patch)
tree77291a03cc04afb4abb132916e174c7b089873d0
parentee5cbf28bc003ecc52347fdd612e27432bd87c24 (diff)
Core/Movement: 7fff83d6752 followup
since MOTION_SLOT_IDLE cannot be expired, signal path done and behave like IdleMotionGenerator
-rw-r--r--src/server/game/Movement/MotionMaster.cpp2
-rwxr-xr-xsrc/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp30
-rwxr-xr-xsrc/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h3
3 files changed, 22 insertions, 13 deletions
diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp
index 2c9899ed43a..b2027144487 100644
--- a/src/server/game/Movement/MotionMaster.cpp
+++ b/src/server/game/Movement/MotionMaster.cpp
@@ -73,7 +73,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 3ca1d581982..6171afc5274 100755
--- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
@@ -40,6 +40,7 @@ WaypointMovementGenerator<Creature>::WaypointMovementGenerator(WaypointPath& pat
_repeating = repeating;
_loadedFromDB = false;
_stalled = false;
+ _done = false;
}
void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature)
@@ -67,6 +68,7 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature)
void WaypointMovementGenerator<Creature>::DoInitialize(Creature* creature)
{
+ _done = false;
LoadPath(creature);
}
@@ -78,8 +80,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)
@@ -116,10 +124,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())
@@ -156,7 +164,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();
@@ -228,7 +237,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())
{
@@ -236,10 +248,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);
@@ -266,7 +274,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 2ea92f021da..3a0140ffa91 100755
--- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h
+++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h
@@ -55,7 +55,7 @@ template<>
class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creature, WaypointMovementGenerator<Creature>>, public PathMovementBase<Creature, WaypointPath const*>
{
public:
- explicit WaypointMovementGenerator(uint32 pathId = 0, bool repeating = true) : _nextMoveTime(0), _recalculateSpeed(false), _isArrivalDone(false), _pathId(pathId), _repeating(repeating), _loadedFromDB(true), _stalled(false) { }
+ explicit WaypointMovementGenerator(uint32 pathId = 0, bool repeating = true) : _nextMoveTime(0), _recalculateSpeed(false), _isArrivalDone(false), _pathId(pathId), _repeating(repeating), _loadedFromDB(true), _stalled(false), _done(false) { }
explicit WaypointMovementGenerator(WaypointPath& path, bool repeating = true);
~WaypointMovementGenerator() { _path = nullptr; }
@@ -92,6 +92,7 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creat
bool _repeating;
bool _loadedFromDB;
bool _stalled;
+ bool _done;
};
/**