Core/Movement: 7fff83d675 followup

since MOTION_SLOT_IDLE cannot be expired, signal path done and behave like IdleMotionGenerator
This commit is contained in:
ccrs
2017-08-12 19:43:37 +02:00
parent ee5cbf28bc
commit eb2769996f
3 changed files with 22 additions and 13 deletions

View File

@@ -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);

View File

@@ -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)

View File

@@ -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;
};
/**