diff --git a/src/org/andengine/util/algorithm/path/astar/AStarPathFinder.java b/src/org/andengine/util/algorithm/path/astar/AStarPathFinder.java index 13be0af1e..4d68e9704 100644 --- a/src/org/andengine/util/algorithm/path/astar/AStarPathFinder.java +++ b/src/org/andengine/util/algorithm/path/astar/AStarPathFinder.java @@ -77,6 +77,10 @@ public Path findPath(final IPathFinderMap pPathFinderMap, final int pXMin, fi while (openNodes.size() > 0) { /* The first Node in the open list is the one with the lowest cost. */ currentNode = sortedOpenNodes.poll(); + if (currentNode == null) { + break; + } + final long currentNodeID = currentNode.mID; if (currentNodeID == toNodeID) { break; @@ -151,7 +155,7 @@ public Path findPath(final IPathFinderMap pPathFinderMap, final int pXMin, fi sortedOpenNodes.clear(); /* Check if a path was found. */ - if (currentNode.mID != toNodeID) { + if (currentNode == null || currentNode.mID != toNodeID) { return null; } @@ -275,4 +279,4 @@ public boolean equals(final Node pNode) { // Inner and Anonymous Classes // =========================================================== } -} \ No newline at end of file +}