From f61421edd0376d4d921485c4357695ada2f7341c Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 26 Jul 2010 19:14:54 +1200 Subject: [PATCH] gain ~20% faster pathing perf --- OpenRA.Game/PathSearch.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/PathSearch.cs b/OpenRA.Game/PathSearch.cs index 5815c096c1..63f1ef597a 100755 --- a/OpenRA.Game/PathSearch.cs +++ b/OpenRA.Game/PathSearch.cs @@ -70,7 +70,13 @@ namespace OpenRA public int2 Expand( World world ) { var p = queue.Pop(); - cellInfo[ p.Location.X, p.Location.Y ].Seen = true; + while (cellInfo[p.Location.X, p.Location.Y].Seen) + if (queue.Empty) + return p.Location; + else + p = queue.Pop(); + + cellInfo[p.Location.X, p.Location.Y].Seen = true; var mobile = self.traits.Get(); var thisCost = mobile.MovementCostForCell(self, p.Location);