From 6d96a4334163c6eab20efcdd76d1e28de3885e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Jim=C3=A9nez?= Date: Wed, 15 Apr 2015 23:43:14 +0200 Subject: [PATCH] Fixes #7955. Improves pathfinder performance a bit. --- OpenRA.Mods.Common/Pathfinder/PathSearch.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Pathfinder/PathSearch.cs b/OpenRA.Mods.Common/Pathfinder/PathSearch.cs index 8f8a782706..37cc477ca9 100644 --- a/OpenRA.Mods.Common/Pathfinder/PathSearch.cs +++ b/OpenRA.Mods.Common/Pathfinder/PathSearch.cs @@ -104,14 +104,14 @@ namespace OpenRA.Mods.Common.Pathfinder var neighborCell = Graph[neighborCPos]; // Cost is even higher; next direction: - if (gCost >= neighborCell.CostSoFar) + if (neighborCell.Status == CellStatus.Closed || gCost >= neighborCell.CostSoFar) continue; // Now we may seriously consider this direction using heuristics. If the cell has // already been processed, we can reuse the result (just the difference between the // estimated total and the cost so far int hCost; - if (neighborCell.Status == CellStatus.Open || neighborCell.Status == CellStatus.Closed) + if (neighborCell.Status == CellStatus.Open) hCost = neighborCell.EstimatedTotal - neighborCell.CostSoFar; else hCost = heuristic(neighborCPos);