1
1
forked from 0ad/0ad

Fix formationmember not leaving walking state if offset cannot be reached

Fail movement for formationmember when cannot find path to destination
and formationcontroller is not moving so formationmember will enter idle
state or follow next command relying on member stopping movement first.

Introduced in a1dc9cadd8.

Differentail Revision: https://code.wildfiregames.com/D2438

This was SVN commit r23496.
This commit is contained in:
Angen 2020-02-13 19:44:03 +00:00
parent a3a5b2fd08
commit 0535eb9b92

View File

@ -478,6 +478,12 @@ private:
return m_MoveRequest.m_Type == MoveRequest::OFFSET;
}
bool IsFormationControllerNotMoving() const
{
CmpPtr<ICmpUnitMotion> cmpControllerMotion(GetSimContext(), m_MoveRequest.m_Entity);
return cmpControllerMotion && !cmpControllerMotion->IsMoveRequested();
}
entity_id_t GetGroup() const
{
return IsFormationMember() ? m_MoveRequest.m_Entity : GetEntityId();
@ -758,7 +764,8 @@ void CCmpUnitMotion::PathResult(u32 ticket, const WaypointPath& path)
// Don't notify if we are a formation member - we can occasionally be stuck for a long time
// if our current offset is unreachable.
if (!IsFormationMember())
// Unless the formationcontroller has reached final destination and we are stuck
if (!IsFormationMember() || IsFormationControllerNotMoving())
IncrementFailedPathComputationAndMaybeNotify();
// If there's no waypoints then we couldn't get near the target