Removed unused sanity checks from pathfinding

These haven't been active and used in years.
This commit is contained in:
reaperrr
2019-01-03 23:40:09 +01:00
committed by Paul Chote
parent 5166b8cd5d
commit 117dde32ba
2 changed files with 0 additions and 44 deletions

View File

@@ -197,10 +197,7 @@ namespace OpenRA.Mods.Common.Activities
return NextActivity; return NextActivity;
if (path == null) if (path == null)
{
path = EvalPath(); path = EvalPath();
SanityCheckPath(mobile);
}
if (path.Count == 0) if (path.Count == 0)
{ {
@@ -260,16 +257,6 @@ namespace OpenRA.Mods.Common.Activities
return this; 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<CPos, SubCell>? PopPath(Actor self) Pair<CPos, SubCell>? PopPath(Actor self)
{ {
if (path.Count == 0) if (path.Count == 0)

View File

@@ -84,8 +84,6 @@ namespace OpenRA.Mods.Common.Traits
using (var fromDest = PathSearch.FromPoint(world, li, self, source, target, true).WithIgnoredActor(ignoreActor).Reverse()) using (var fromDest = PathSearch.FromPoint(world, li, self, source, target, true).WithIgnoredActor(ignoreActor).Reverse())
pb = FindBidiPath(fromSrc, fromDest); pb = FindBidiPath(fromSrc, fromDest);
CheckSanePath2(pb, source, target);
return pb; return pb;
} }
@@ -197,7 +195,6 @@ namespace OpenRA.Mods.Common.Traits
} }
ret.Add(currentNode); ret.Add(currentNode);
CheckSanePath(ret);
return ret; return ret;
} }
@@ -226,35 +223,7 @@ namespace OpenRA.Mods.Common.Traits
ret.Add(q); ret.Add(q);
} }
CheckSanePath(ret);
return ret; return ret;
} }
[Conditional("SANITY_CHECKS")]
static void CheckSanePath(IList<CPos> 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<CPos> 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");
}
} }
} }