diff --git a/source/simulation2/components/CCmpPathfinder.cpp b/source/simulation2/components/CCmpPathfinder.cpp index 536dff6e1c..54804f46a4 100644 --- a/source/simulation2/components/CCmpPathfinder.cpp +++ b/source/simulation2/components/CCmpPathfinder.cpp @@ -794,16 +794,13 @@ bool CCmpPathfinder::CheckMovement(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, pass_class_t passClass) { - // Test against obstructions first + // Test against obstructions first. Pathfinding-blocking obstructions are not handled here. CmpPtr cmpObstructionManager(GetSystemEntity()); - if (!cmpObstructionManager) + if (!cmpObstructionManager || cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r)) return false; - if (cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r)) - return false; - - // Then test against the terrain - return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_TerrainOnlyGrid); + // Then test against the passability grid. + return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_Grid); } ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter, diff --git a/source/simulation2/components/ICmpObstructionManager.h b/source/simulation2/components/ICmpObstructionManager.h index 7723d643ca..d01c72eeea 100644 --- a/source/simulation2/components/ICmpObstructionManager.h +++ b/source/simulation2/components/ICmpObstructionManager.h @@ -346,6 +346,12 @@ public: if (group == m_Group || (group2 != INVALID_ENTITY && group2 == m_Group)) return false; + // If an obstruction already blocks tile-based pathfinding, + // it will be handled as part of the terrain passability handling + // and doesn't need to be matched by this filter + if (flags & ICmpObstructionManager::FLAG_BLOCK_PATHFINDING) + return false; + if (!(flags & ICmpObstructionManager::FLAG_BLOCK_MOVEMENT)) return false;