mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
Codechange: Rename and return AyStarStatus instead of int (#13125)
- Rename enum AystarStatus to AyStarStatus. - Return AyStarStatus instead of int for AyStar::Main and AyStar::Loop functions.
This commit is contained in:
parent
7c3b0e5c9c
commit
8e9603bd33
@ -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)) { }
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user