2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file npf_func.h Functions to access the new pathfinder. */
13 #include "../../track_type.h"
14 #include "../../direction_type.h"
15 #include "../../vehicle_type.h"
16 #include "../pathfinder_type.h"
19 * Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using NPF.
20 * @param v vehicle that needs to go to some depot
21 * @param max_penalty max distance (in pathfinder penalty) from the current vehicle position
22 * (used also as optimization - the pathfinder can stop path finding if max_penalty
23 * was reached and no depot was seen)
24 * @return the data about the depot
26 FindDepotData
NPFRoadVehicleFindNearestDepot(const RoadVehicle
*v
, int max_penalty
);
29 * Finds the best path for given road vehicle using NPF.
30 * @param v the RV that needs to find a path
31 * @param tile the tile to find the path from (should be next tile the RV is about to enter)
32 * @param enterdir diagonal direction which the RV will enter this new tile from
33 * @param path_found [out] Whether a path has been found (true) or has been guessed (false)
34 * @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
36 Trackdir
NPFRoadVehicleChooseTrack(const RoadVehicle
*v
, TileIndex tile
, DiagDirection enterdir
, bool &path_found
);
39 * Finds the best path for given ship using NPF.
40 * @param v the ship that needs to find a path
41 * @param path_found [out] Whether a path has been found (true) or has been guessed (false)
42 * @return the best trackdir for next turn or INVALID_TRACK if the path could not be found
44 Track
NPFShipChooseTrack(const Ship
*v
, bool &path_found
);
47 * Returns true if it is better to reverse the ship before leaving depot using NPF.
48 * @param v the ship leaving the depot
49 * @return true if reversing is better
51 bool NPFShipCheckReverse(const Ship
*v
);
54 * Used when user sends train to the nearest depot or if train needs servicing using NPF
55 * @param v train that needs to go to some depot
56 * @param max_penalty max max_penalty (in pathfinder penalty) from the current train position
57 * (used also as optimization - the pathfinder can stop path finding if max_penalty
58 * was reached and no depot was seen)
59 * @return the data about the depot
61 FindDepotData
NPFTrainFindNearestDepot(const Train
*v
, int max_penalty
);
64 * Try to extend the reserved path of a train to the nearest safe tile using NPF.
66 * @param v The train that needs to find a safe tile.
67 * @param tile Last tile of the current reserved path.
68 * @param td Last trackdir of the current reserved path.
69 * @param override_railtype Should all physically compatible railtypes be searched, even if the vehicle can't run on them on its own?
70 * @return True if the path could be extended to a safe tile.
72 bool NPFTrainFindNearestSafeTile(const Train
*v
, TileIndex tile
, Trackdir td
, bool override_railtype
);
75 * Returns true if it is better to reverse the train before leaving station using NPF.
76 * @param v the train leaving the station
77 * @return true if reversing is better
79 bool NPFTrainCheckReverse(const Train
*v
);
82 * Finds the best path for given train using NPF.
83 * @param v the train that needs to find a path
84 * @param path_found [out] Whether a path has been found (true) or has been guessed (false)
85 * @param reserve_track indicates whether YAPF should try to reserve the found path
86 * @param target [out] the target tile of the reservation, free is set to true if path was reserved
87 * @return the best track for next turn
89 Track
NPFTrainChooseTrack(const Train
*v
, bool &path_found
, bool reserve_track
, struct PBSTileInfo
*target
);
91 #endif /* NPF_FUNC_H */