From 117dde32baa88e08e6778468e1206c45f9bf04cb Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 3 Jan 2019 23:40:09 +0100 Subject: [PATCH] Removed unused sanity checks from pathfinding These haven't been active and used in years. --- OpenRA.Mods.Common/Activities/Move/Move.cs | 13 -------- OpenRA.Mods.Common/Traits/World/PathFinder.cs | 31 ------------------- 2 files changed, 44 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index e926cba67f..7645e843d0 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -197,10 +197,7 @@ namespace OpenRA.Mods.Common.Activities return NextActivity; if (path == null) - { path = EvalPath(); - SanityCheckPath(mobile); - } if (path.Count == 0) { @@ -260,16 +257,6 @@ namespace OpenRA.Mods.Common.Activities return this; } - [Conditional("SANITY_CHECKS")] - void SanityCheckPath(Mobile mobile) - { - if (path.Count == 0) - return; - var d = path[path.Count - 1] - mobile.ToCell; - if (d.LengthSquared > 2) - throw new InvalidOperationException("(Move) Sanity check failed"); - } - Pair? PopPath(Actor self) { if (path.Count == 0) diff --git a/OpenRA.Mods.Common/Traits/World/PathFinder.cs b/OpenRA.Mods.Common/Traits/World/PathFinder.cs index b46495f010..44dedd99e2 100644 --- a/OpenRA.Mods.Common/Traits/World/PathFinder.cs +++ b/OpenRA.Mods.Common/Traits/World/PathFinder.cs @@ -84,8 +84,6 @@ namespace OpenRA.Mods.Common.Traits using (var fromDest = PathSearch.FromPoint(world, li, self, source, target, true).WithIgnoredActor(ignoreActor).Reverse()) pb = FindBidiPath(fromSrc, fromDest); - CheckSanePath2(pb, source, target); - return pb; } @@ -197,7 +195,6 @@ namespace OpenRA.Mods.Common.Traits } ret.Add(currentNode); - CheckSanePath(ret); return ret; } @@ -226,35 +223,7 @@ namespace OpenRA.Mods.Common.Traits ret.Add(q); } - CheckSanePath(ret); return ret; } - - [Conditional("SANITY_CHECKS")] - static void CheckSanePath(IList path) - { - if (path.Count == 0) - return; - var prev = path[0]; - foreach (var cell in path) - { - var d = cell - prev; - if (Math.Abs(d.X) > 1 || Math.Abs(d.Y) > 1) - throw new InvalidOperationException("(PathFinder) path sanity check failed"); - prev = cell; - } - } - - [Conditional("SANITY_CHECKS")] - static void CheckSanePath2(IList path, CPos src, CPos dest) - { - if (path.Count == 0) - return; - - if (path[0] != dest) - throw new InvalidOperationException("(PathFinder) sanity check failed: doesn't go to dest"); - if (path[path.Count - 1] != src) - throw new InvalidOperationException("(PathFinder) sanity check failed: doesn't come from src"); - } } }