]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/PathFinder.cs
git-svn-id: https://bd85.net/svn/cs3505_group@152 92bb83a3-7c8f-8a45-bc97-515c4e399668
[chaz/carfire] / CarFire / CarFire / CarFire / PathFinder.cs
index 53e148d1f2cc713b29940cd2613df0ac5462bcfb..02c645cc8f8ed4c71e20705b96951a627acd15b4 100644 (file)
@@ -129,7 +129,7 @@ namespace CarFire
                     List<Point> list = new List<Point>();\r
 \r
                     cell = cell.Parent;\r
-                    while (cell.Point != start)\r
+                    while (cell != null && cell.Point != start)\r
                     {\r
                         list.Add(cell.Point);\r
                         cell = cell.Parent;\r
@@ -152,13 +152,12 @@ namespace CarFire
 #endif\r
                 foreach (Point point in neighbors)\r
                 {\r
-                    Cell inQueue = mCells[point.X, point.Y];\r
-\r
                     if (0 <= point.X && point.X < mGridWidth && 0 <= point.Y && point.Y < mGridHeight &&\r
                         mGrid[point.X, point.Y])\r
                     {\r
                         int cost = cell.G + costFunction(cell.Point, point);\r
 \r
+                        Cell inQueue = mCells[point.X, point.Y];\r
                         if (inQueue == null)\r
                         {\r
                             Cell neighbor = new Cell(point, cost, heuristic(point, finish), cell);\r
This page took 0.018235 seconds and 4 git commands to generate.