From 9e41ff39fc2cdeeddae0b5c9582824cb778f0fa2 Mon Sep 17 00:00:00 2001 From: wraitii Date: Sun, 1 Sep 2019 07:31:21 +0000 Subject: [PATCH] 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. --- source/simulation2/components/CCmpUnitMotion.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/simulation2/components/CCmpUnitMotion.cpp b/source/simulation2/components/CCmpUnitMotion.cpp index 1cac9f1072..64cbb06ad2 100644 --- a/source/simulation2/components/CCmpUnitMotion.cpp +++ b/source/simulation2/components/CCmpUnitMotion.cpp @@ -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); }