From 7cc495ec913a5ebca97169ed3bfc59da02f5820e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lancelot=20de=20Ferri=C3=A8re?= Date: Sat, 3 May 2025 08:45:05 +0200 Subject: [PATCH] Fix UnitMotion 'path prediction' to not trigger if following a short path This is needed otherwise units might never go around pure unit obstructions. Adds a small test map. Fixes def0f57365392852c3bf2884bcc2a6d0efdfb64c --- .../data/mods/public/maps/scenarios/vertex_pathfinder_test.xml | 3 +++ source/simulation2/components/CCmpUnitMotion.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 binaries/data/mods/public/maps/scenarios/vertex_pathfinder_test.xml diff --git a/binaries/data/mods/public/maps/scenarios/vertex_pathfinder_test.xml b/binaries/data/mods/public/maps/scenarios/vertex_pathfinder_test.xml new file mode 100644 index 0000000000..6650f33dc0 --- /dev/null +++ b/binaries/data/mods/public/maps/scenarios/vertex_pathfinder_test.xml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b3343935dc599dd9d338b9fbd5961e0a0685862b164ded020e10e97f4c597ae +size 65417 diff --git a/source/simulation2/components/CCmpUnitMotion.h b/source/simulation2/components/CCmpUnitMotion.h index 50c5e34eb0..9796bd03bb 100644 --- a/source/simulation2/components/CCmpUnitMotion.h +++ b/source/simulation2/components/CCmpUnitMotion.h @@ -1091,7 +1091,7 @@ void CCmpUnitMotion::PostMove(CCmpUnitMotionManager::MotionState& state, fixed d const bool needPathUpdate{PathingUpdateNeeded(state.pos)}; // If we're following a long-path, check if we might run into units in advance, to smoothe motion. - if (!needPathUpdate && !state.wasObstructed && m_LongPath.m_Waypoints.size() >= 1) + if (!needPathUpdate && !state.wasObstructed && m_LongPath.m_Waypoints.size() >= 1 && m_ShortPath.m_Waypoints.empty()) { ICmpObstructionManager::tag_t specificIgnore; if (m_MoveRequest.m_Type == MoveRequest::ENTITY)