|
OpenTTD Source 20260421-master-gc2fbc6fdeb
|
River builder pathfinder implementation. More...
Public Types | |
| using | Node = RiverBuilderTypes::NodeList::Item |
| using | Key = Node::Key |
| Public Types inherited from CYapfBaseT< RiverBuilderTypes > | |
| typedef RiverBuilderTypes::Tpf | Tpf |
| the pathfinder class (derived from THIS class) | |
| typedef RiverBuilderTypes::TrackFollower | TrackFollower |
| typedef RiverBuilderTypes::NodeList | NodeList |
| our node list | |
| typedef RiverBuilderTypes::VehicleType | VehicleType |
| the type of vehicle | |
| typedef NodeList::Item | Node |
| this will be our node type | |
| typedef Node::Key | Key |
| key to hash tables | |
| using | PfFollowNodeFunc |
| Called by YAPF to move from the given node to the next tile. | |
| using | PfCalcCostFunc |
| Called by YAPF to calculate the cost from the origin to the given node. | |
| using | PfCalcEstimateFunc |
| Called by YAPF to calculate cost estimate. | |
| using | PfDetectDestinationFunc |
| Called by YAPF to detect if node ends in the desired destination. | |
| using | PfDetectDestinationTileFunc |
| Called by YAPF to detect if node ends in the desired destination. | |
| using | TransportTypeCharFunc |
| Return debug report character to identify the transportation type. | |
| Public Types inherited from CYapfSegmentCostCacheNoneT< RiverBuilderTypes > | |
| typedef RiverBuilderTypes::Tpf | Tpf |
| the pathfinder class (derived from THIS class) | |
| typedef RiverBuilderTypes::NodeList::Item | Node |
| this will be our node type | |
Public Member Functions | |
| YapfRiverBuilder (TileIndex start_tile, TileIndex end_tile) | |
| bool | PfDetectDestination (Node &n) const |
| Called by YAPF to detect if node ends in the desired destination. | |
| bool | PfCalcCost (Node &n, const RiverBuilderFollower *follower) |
| Called by YAPF to calculate the cost from the origin to the given node. | |
| bool | PfCalcEstimate (Node &n) |
| Called by YAPF to calculate cost estimate. | |
| void | PfFollowNode (Node &old_node) |
| Called by YAPF to move from the given node to the next tile. | |
| char | TransportTypeChar () const |
| Return debug report character to identify the transportation type. | |
| Public Member Functions inherited from CYapfBaseT< RiverBuilderTypes > | |
| CYapfBaseT () | |
| default constructor | |
| ~CYapfBaseT () | |
| default destructor | |
| const YAPFSettings & | PfGetSettings () const |
| Return current settings (can be custom - company based - but later). | |
| bool | FindPath (const VehicleType *v) |
| Main pathfinder routine: | |
| Node * | GetBestNode () |
| If path was found return the best node that has reached the destination. | |
| Node & | CreateNewNode () |
| Calls NodeList::CreateNewNode() - allocates new node that can be filled and used as argument for AddStartupNode() or AddNewNode(). | |
| void | AddStartupNode (Node &n) |
| Add new node (created by CreateNewNode and filled with data) into open list. | |
| void | AddMultipleNodes (Node *parent, const TrackFollower &tf) |
| Add multiple nodes - direct children of the given node. | |
| void | AddNewNode (Node &n, const TrackFollower &follower) |
| AddNewNode() - called by Tderived::PfFollowNode() for each child node. | |
| const VehicleType * | GetVehicle () const |
| void | DumpBase (DumpTarget &dmp) const |
| Public Member Functions inherited from CYapfSegmentCostCacheNoneT< RiverBuilderTypes > | |
| bool | PfNodeCacheFetch (Node &) |
| Called by YAPF to attach cached or local segment cost data to the given node. | |
Static Public Member Functions | |
| static void | BuildRiver (TileIndex start_tile, TileIndex end_tile, TileIndex spring_tile, bool main_river) |
Protected Member Functions | |
| YapfRiverBuilder & | Yapf () |
| Protected Member Functions inherited from CYapfBaseT< RiverBuilderTypes > | |
| Tpf & | Yapf () |
| Access the inherited path finder. | |
Protected Attributes | |
| TileIndex | end_tile |
| End tile of the river. | |
| Protected Attributes inherited from CYapfBaseT< RiverBuilderTypes > | |
| Node * | best_dest_node |
| pointer to the destination node found at last round | |
| Node * | best_intermediate_node |
| here should be node closest to the destination if path not found | |
| const YAPFSettings * | settings |
| current settings (_settings_game.yapf) | |
| int | max_search_nodes |
| maximum number of nodes we are allowed to visit before we give up | |
| const VehicleType * | vehicle |
| vehicle that we are trying to drive | |
| int | stats_cost_calcs |
| stats - how many node's costs were calculated | |
| int | stats_cache_hits |
| stats - how many node's costs were reused from cache | |
Additional Inherited Members | |
| Data Fields inherited from CYapfBaseT< RiverBuilderTypes > | |
| NodeList | nodes |
| node list multi-container | |
| int | num_steps |
| this is there for debugging purposes (hope it doesn't hurt) | |
River builder pathfinder implementation.
Definition at line 41 of file yapf_river_builder.cpp.
| using YapfRiverBuilder::Key = Node::Key |
Definition at line 47 of file yapf_river_builder.cpp.
| using YapfRiverBuilder::Node = RiverBuilderTypes::NodeList::Item |
Definition at line 46 of file yapf_river_builder.cpp.
Definition at line 58 of file yapf_river_builder.cpp.
|
inlinestatic |
Definition at line 107 of file yapf_river_builder.cpp.
|
inline |
Called by YAPF to calculate the cost from the origin to the given node.
Calculates only the cost of given node, adds it to the parent node cost and stores the result into Node::cost member.
| n | The node to consider. |
| follower | The track follower to the next node. |
true iff the costs could be calculated. Definition at line 74 of file yapf_river_builder.cpp.
References _settings_game, and RandomRange().
|
inline |
Called by YAPF to calculate cost estimate.
Calculates distance to the destination adds it to the actual cost from origin and stores the sum to the Node::estimate.
| n | The node to start from. |
true iff the cost could be estimated. Definition at line 81 of file yapf_river_builder.cpp.
References DistanceManhattan().
|
inline |
Called by YAPF to detect if node ends in the desired destination.
| n | The current node. |
true iff the destination has been reached. Definition at line 68 of file yapf_river_builder.cpp.
|
inline |
Called by YAPF to move from the given node to the next tile.
For each reachable trackdir on the new tile creates new node, initializes it and adds it to the open list by calling Yapf().AddNewNode(n).
| old_node | The node to follow from. |
Definition at line 89 of file yapf_river_builder.cpp.
References CYapfBaseT< Types >::AddNewNode(), CYapfBaseT< Types >::CreateNewNode(), DIAGDIR_BEGIN, DIAGDIR_END, INVALID_TRACKDIR, IsValidTile(), RiverFlowsDown(), TileOffsByDiagDir(), and CYapfBaseT< RiverBuilderTypes >::Yapf().
|
inline |
Return debug report character to identify the transportation type.
Definition at line 102 of file yapf_river_builder.cpp.
|
inlineprotected |
Definition at line 52 of file yapf_river_builder.cpp.
|
protected |
End tile of the river.
Definition at line 50 of file yapf_river_builder.cpp.