[10420] Avoid send stop packet in PointMovementGenerator when unit is not moving

Also never send stop packet when destinationHolder hasArrived, it's expected that unit is already not moving.

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-08-29 11:03:55 +02:00
parent 0d363cc77a
commit 04b62bb9ee
2 changed files with 10 additions and 5 deletions

View file

@ -28,8 +28,11 @@
template<class T>
void PointMovementGenerator<T>::Initialize(T &unit)
{
unit.StopMoving();
if (!unit.IsStopped())
unit.StopMoving();
unit.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
Traveller<T> traveller(unit);
i_destinationHolder.SetDestination(traveller, i_x, i_y, i_z);
@ -52,11 +55,12 @@ void PointMovementGenerator<T>::Interrupt(T &unit)
template<class T>
void PointMovementGenerator<T>::Reset(T &unit)
{
unit.StopMoving();
if (!unit.IsStopped())
unit.StopMoving();
unit.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
}
template<class T>
bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff)
{
@ -70,6 +74,7 @@ bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff)
}
unit.addUnitState(UNIT_STAT_ROAMING_MOVE);
Traveller<T> traveller(unit);
if (i_destinationHolder.UpdateTraveller(traveller, diff, false))
{
@ -79,7 +84,7 @@ bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff)
if(i_destinationHolder.HasArrived())
{
unit.StopMoving();
unit.clearUnitState(UNIT_STAT_ROAMING_MOVE);
MovementInform(unit);
return false;
}