Unit Motion - make sure units don't get stuck in the special long-path computation step.

In some rare cases, units could be stuck in the special state of 3
failed path computations, making them always compute long paths instead
of trying short paths again. This can happen when they compute a long
path successfully, but the unit cannot actually move as it gets
obstructed right away.
Make sure this state is never kept for more than one turn to fix this
problem.

Refs #5569 (probable fix but kept open for further investigating).

Differential Revision: https://code.wildfiregames.com/D2239
This was SVN commit r22815.
This commit is contained in:
wraitii 2019-09-01 07:31:21 +00:00
parent 2c229a986d
commit 9e41ff39fc

View File

@ -1385,6 +1385,8 @@ void CCmpUnitMotion::ComputePathToGoal(const CFixedVector2D& from, const PathGoa
}
else
{
if (m_FailedPathComputations == MAX_FAILED_PATH_COMPUTATIONS_BEFORE_LONG_PATH)
m_FailedPathComputations++; // This makes sure we don't end up stuck in this special state which can break pathing.
m_ShortPath.m_Waypoints.clear();
RequestLongPath(from, goal);
}