diff --git a/src/pathfinder/aystar.cpp b/src/pathfinder/aystar.cpp index 166aa9a8f3..db30cb570f 100644 --- a/src/pathfinder/aystar.cpp +++ b/src/pathfinder/aystar.cpp @@ -89,7 +89,7 @@ void AyStar::CheckTile(AyStarNode *current, PathNode *parent) * - #AYSTAR_FOUND_END_NODE : indicates we found the end. Path_found now is true, and in path is the path found. * - #AYSTAR_STILL_BUSY : indicates we have done this tile, did not found the path yet, and have items left to try. */ -int AyStar::Loop() +AyStarStatus AyStar::Loop() { /* Get the best node from OpenList */ PathNode *current = this->nodes.PopBestOpenNode(); @@ -134,9 +134,10 @@ int AyStar::Loop() * @note When the algorithm is done (when the return value is not #AYSTAR_STILL_BUSY) #Clear() is called automatically. * When you stop the algorithm halfway, you should call #Clear() yourself! */ -int AyStar::Main() +AyStarStatus AyStar::Main() { - int r, i = 0; + AyStarStatus r = AYSTAR_FOUND_END_NODE; + int i = 0; /* Loop through the OpenList * Quit if result is no AYSTAR_STILL_BUSY or is more than loops_per_tick */ while ((r = this->Loop()) == AYSTAR_STILL_BUSY && (this->loops_per_tick == 0 || ++i < this->loops_per_tick)) { } diff --git a/src/pathfinder/aystar.h b/src/pathfinder/aystar.h index ad24ad13ff..033e488d65 100644 --- a/src/pathfinder/aystar.h +++ b/src/pathfinder/aystar.h @@ -28,7 +28,7 @@ static const int AYSTAR_DEF_MAX_SEARCH_NODES = 10000; ///< Reference limit for #AyStar::max_search_nodes /** Return status of #AyStar methods. */ -enum AystarStatus { +enum AyStarStatus { AYSTAR_FOUND_END_NODE, ///< An end node was found. AYSTAR_EMPTY_OPENLIST, ///< All items are tested, and no path has been found. AYSTAR_STILL_BUSY, ///< Some checking was done, but no path found yet, and there are still items left to try. @@ -131,8 +131,8 @@ struct AyStar { /* These will contain the methods for manipulating the AyStar. Only * Main() should be called externally */ void AddStartNode(AyStarNode *start_node, int g); - int Main(); - int Loop(); + AyStarStatus Main(); + AyStarStatus Loop(); void CheckTile(AyStarNode *current, PathNode *parent); protected: