mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Remove unused options from AyStar.
parent
53899c3c21
commit
97ead8e241
|
@ -49,7 +49,6 @@ void AyStar::CheckTile(AyStarNode *current, PathNode *parent)
|
|||
assert(new_g >= 0);
|
||||
/* Add the parent g-value to the new g-value */
|
||||
new_g += parent->cost;
|
||||
if (this->max_path_cost != 0 && new_g > this->max_path_cost) return;
|
||||
|
||||
/* Calculate the h-value */
|
||||
int new_h = this->CalculateH(this, current, parent);
|
||||
|
@ -116,7 +115,7 @@ AyStarStatus AyStar::Loop()
|
|||
this->CheckTile(&neighbour, current);
|
||||
}
|
||||
|
||||
if (this->max_search_nodes != 0 && this->nodes.ClosedCount() >= this->max_search_nodes) {
|
||||
if (this->nodes.ClosedCount() >= AYSTAR_DEF_MAX_SEARCH_NODES) {
|
||||
/* We've expanded enough nodes */
|
||||
return AyStarStatus::LimitReached;
|
||||
} else {
|
||||
|
@ -131,16 +130,13 @@ AyStarStatus AyStar::Loop()
|
|||
* - #AyStarStatus::FoundEndNode
|
||||
* - #AyStarStatus::NoPath
|
||||
* - #AyStarStatus::StillBusy
|
||||
* @note When the algorithm is done (when the return value is not #AyStarStatus::StillBusy) #Clear() is called automatically.
|
||||
* When you stop the algorithm halfway, you should call #Clear() yourself!
|
||||
*/
|
||||
AyStarStatus AyStar::Main()
|
||||
{
|
||||
AyStarStatus r = AyStarStatus::FoundEndNode;
|
||||
int i = 0;
|
||||
/* Loop through the OpenList
|
||||
* Quit if result is no AyStarStatus::StillBusy or is more than loops_per_tick */
|
||||
while ((r = this->Loop()) == AyStarStatus::StillBusy && (this->loops_per_tick == 0 || ++i < this->loops_per_tick)) { }
|
||||
AyStarStatus r;
|
||||
do {
|
||||
r = this->Loop();
|
||||
} while (r == AyStarStatus::StillBusy);
|
||||
#ifdef AYSTAR_DEBUG
|
||||
switch (r) {
|
||||
case AyStarStatus::FoundEndNode: Debug(misc, 0, "[AyStar] Found path!"); break;
|
||||
|
@ -160,9 +156,7 @@ AyStarStatus AyStar::Main()
|
|||
|
||||
/**
|
||||
* Adds a node from where to start an algorithm. Multiple nodes can be added
|
||||
* if wanted. You should make sure that #Clear() is called before adding nodes
|
||||
* if the #AyStar has been used before (though the normal main loop calls
|
||||
* #Clear() automatically when the algorithm finishes.
|
||||
* if wanted.
|
||||
* @param start_node Node to start with.
|
||||
* @param g the cost for starting with this node.
|
||||
*/
|
||||
|
|
|
@ -27,7 +27,7 @@ enum class AyStarStatus : uint8_t {
|
|||
EmptyOpenList, ///< All items are tested, and no path has been found.
|
||||
StillBusy, ///< Some checking was done, but no path found yet, and there are still items left to try.
|
||||
NoPath, ///< No path to the goal was found.
|
||||
LimitReached, ///< The #AyStar::max_search_nodes limit has been reached, aborting search.
|
||||
LimitReached, ///< The AYSTAR_DEF_MAX_SEARCH_NODES limit has been reached, aborting search.
|
||||
Done, ///< Not an end-tile, or wrong direction.
|
||||
};
|
||||
|
||||
|
@ -113,10 +113,6 @@ struct AyStar {
|
|||
void *user_target;
|
||||
void *user_data;
|
||||
|
||||
uint8_t loops_per_tick; ///< How many loops are there called before Main() gives control back to the caller. 0 = until done.
|
||||
int max_path_cost; ///< If the g-value goes over this number, it stops searching, 0 = infinite.
|
||||
int max_search_nodes = AYSTAR_DEF_MAX_SEARCH_NODES; ///< The maximum number of nodes that will be expanded, 0 = infinite.
|
||||
|
||||
/* These should be filled with the neighbours of a tile by GetNeighbours */
|
||||
std::vector<AyStarNode> neighbours;
|
||||
|
||||
|
|
Loading…
Reference in New Issue