1
0
forked from 0ad/0ad

Fix 'gliding' behaviour at the end of movement by moving the PossiblyAtDestination check earlier.

Units in 0 A.D. exhibited a "gliding" behaviour at the end of a
movement, e.g. they switched to the Idle animation and still moved a
little bit.

The reason for this behaviour is that entities check if they reached
their destination after moving. Other components (unitAI mostly) will
then possibly change animations and such, resulting in a movement over
the turn while the entity is possibly now in another animation state
than "move".
Instead, what should be done is checking if the entity has arrived
before moving, so if UnitAI calls StopMoving, then entity won't move at
all on the same turn, and the gliding effect vanishes.

The STATE_STOPPING state is made un-necessary by this change, since this
off-by-one mistake was the reason for its existence. It can be removed
(see downstream).

Differential Revision: https://code.wildfiregames.com/D1898
This was SVN commit r22365.
This commit is contained in:
wraitii 2019-06-11 18:51:55 +00:00
parent f04bdd84ae
commit 8ac104b07a

View File

@ -816,6 +816,9 @@ void CCmpUnitMotion::Move(fixed dt)
if (m_State == STATE_IDLE)
return;
if (PossiblyAtDestination())
MoveSucceeded();
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
if (!cmpPosition || !cmpPosition->IsInWorld())
return;
@ -856,12 +859,6 @@ void CCmpUnitMotion::Move(fixed dt)
if (m_PathState == PATHSTATE_FOLLOWING)
{
if (PossiblyAtDestination())
{
m_State = STATE_STOPPING;
return;
}
// We may need to recompute our path sometimes (e.g. if our target moves).
// Since we request paths asynchronously anyways, this does not need to be done before moving.
if (IsFormationMember())