From 35e9fade06cc12f410c3598b0e704b91ba2473dd Mon Sep 17 00:00:00 2001 From: Vapre Date: Tue, 3 Aug 2021 23:29:35 +0200 Subject: [PATCH] PathGraph, skip closed cells early. Fix #19579. --- OpenRA.Mods.Common/Pathfinder/PathGraph.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Pathfinder/PathGraph.cs b/OpenRA.Mods.Common/Pathfinder/PathGraph.cs index 70abc3c0f8..558a5a24f9 100644 --- a/OpenRA.Mods.Common/Pathfinder/PathGraph.cs +++ b/OpenRA.Mods.Common/Pathfinder/PathGraph.cs @@ -147,13 +147,10 @@ namespace OpenRA.Mods.Common.Pathfinder { var dir = directions[i]; var neighbor = position + dir; + var movementCost = GetCostToNode(neighbor, dir); // PERF: Skip closed cells already, 15% of all cells - if (info[neighbor].Status == CellStatus.Closed) - continue; - - var movementCost = GetCostToNode(neighbor, dir); - if (movementCost != CostForInvalidCell) + if (movementCost != CostForInvalidCell && info[neighbor].Status != CellStatus.Closed) validNeighbors.Add(new GraphConnection(neighbor, movementCost)); }