X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FPathFinder.cs;h=02c645cc8f8ed4c71e20705b96951a627acd15b4;hp=53e148d1f2cc713b29940cd2613df0ac5462bcfb;hb=188525be158d8ba27fbbedf699eec5df59c5a2ee;hpb=af9deb873b24dadd0d509ce199fc6cac2b3efbc9 diff --git a/CarFire/CarFire/CarFire/PathFinder.cs b/CarFire/CarFire/CarFire/PathFinder.cs index 53e148d..02c645c 100644 --- a/CarFire/CarFire/CarFire/PathFinder.cs +++ b/CarFire/CarFire/CarFire/PathFinder.cs @@ -129,7 +129,7 @@ namespace CarFire List list = new List(); cell = cell.Parent; - while (cell.Point != start) + while (cell != null && cell.Point != start) { list.Add(cell.Point); cell = cell.Parent; @@ -152,13 +152,12 @@ namespace CarFire #endif foreach (Point point in neighbors) { - Cell inQueue = mCells[point.X, point.Y]; - if (0 <= point.X && point.X < mGridWidth && 0 <= point.Y && point.Y < mGridHeight && mGrid[point.X, point.Y]) { int cost = cell.G + costFunction(cell.Point, point); + Cell inQueue = mCells[point.X, point.Y]; if (inQueue == null) { Cell neighbor = new Cell(point, cost, heuristic(point, finish), cell);