From 25a8de8a47048e1176695b93b047286241bde189 Mon Sep 17 00:00:00 2001 From: teinarss Date: Tue, 10 Jul 2018 16:53:01 +0200 Subject: [PATCH] Fixing pathfinding calc when the distance was to small for the bidirectional logic to work. --- OpenRA.Mods.Common/Traits/World/PathFinder.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/World/PathFinder.cs b/OpenRA.Mods.Common/Traits/World/PathFinder.cs index ab0c7b0d2c..fcf06335ee 100644 --- a/OpenRA.Mods.Common/Traits/World/PathFinder.cs +++ b/OpenRA.Mods.Common/Traits/World/PathFinder.cs @@ -70,6 +70,10 @@ namespace OpenRA.Mods.Common.Traits if (domainIndex != null && !domainIndex.IsPassable(source, target, li)) return EmptyPath; + var distance = source - target; + if (distance.LengthSquared < 3 && li.CanMoveFreelyInto(world, self, target, null, CellConditions.All)) + return new List { target }; + List pb; using (var fromSrc = PathSearch.FromPoint(world, li, self, target, source, true).WithIgnoredActor(ignoreActor)) using (var fromDest = PathSearch.FromPoint(world, li, self, source, target, true).WithIgnoredActor(ignoreActor).Reverse()) @@ -143,7 +147,6 @@ namespace OpenRA.Mods.Common.Traits { // make some progress on the first search var p = fromSrc.Expand(); - if (fromDest.Graph[p].Status == CellStatus.Closed && fromDest.Graph[p].CostSoFar < int.MaxValue) { @@ -153,7 +156,6 @@ namespace OpenRA.Mods.Common.Traits // make some progress on the second search var q = fromDest.Expand(); - if (fromSrc.Graph[q].Status == CellStatus.Closed && fromSrc.Graph[q].CostSoFar < int.MaxValue) {