Update: Translations from eints
[openttd-github.git] / src / pathfinder / yapf / yapf.h
blob186986ce57e57b1b4e8f90477f9b90d671043df7
1 /*
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/>.
6 */
8 /** @file yapf.h Entry point for OpenTTD to YAPF. */
10 #ifndef YAPF_H
11 #define YAPF_H
13 #include "../../direction_type.h"
14 #include "../../track_type.h"
15 #include "../../vehicle_type.h"
16 #include "../../ship.h"
17 #include "../../roadveh.h"
18 #include "../pathfinder_type.h"
20 /**
21 * Finds the best path for given ship using YAPF.
22 * @param v the ship that needs to find a path
23 * @param tile the tile to find the path from (should be next tile the ship is about to enter)
24 * @param path_found [out] Whether a path has been found (true) or has been guessed (false)
25 * @return the best trackdir for next turn or INVALID_TRACK if the path could not be found
27 Track YapfShipChooseTrack(const Ship *v, TileIndex tile, bool &path_found, ShipPathCache &path_cache);
29 /**
30 * Returns true if it is better to reverse the ship before leaving depot using YAPF.
31 * @param v the ship leaving the depot
32 * @param trackdir [out] the best of all possible reversed trackdirs
33 * @return true if reversing is better
35 bool YapfShipCheckReverse(const Ship *v, Trackdir *trackdir);
37 /**
38 * Finds the best path for given road vehicle using YAPF.
39 * @param v the RV that needs to find a path
40 * @param tile the tile to find the path from (should be next tile the RV is about to enter)
41 * @param enterdir diagonal direction which the RV will enter this new tile from
42 * @param trackdirs available trackdirs on the new tile (to choose from)
43 * @param path_found [out] Whether a path has been found (true) or has been guessed (false)
44 * @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
46 Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool &path_found, RoadVehPathCache &path_cache);
48 /**
49 * Finds the best path for given train using YAPF.
50 * @param v the train that needs to find a path
51 * @param tile the tile to find the path from (should be next tile the train is about to enter)
52 * @param enterdir diagonal direction which the RV will enter this new tile from
53 * @param tracks available trackdirs on the new tile (to choose from)
54 * @param path_found [out] Whether a path has been found (true) or has been guessed (false)
55 * @param reserve_track indicates whether YAPF should try to reserve the found path
56 * @param target [out] the target tile of the reservation, free is set to true if path was reserved
57 * @param dest [out] the final tile of the best path found
58 * @return the best track for next turn
60 Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, struct PBSTileInfo *target, TileIndex *dest);
62 /**
63 * Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using YAPF.
64 * @param v vehicle that needs to go to some depot
65 * @param max_penalty max distance (in pathfinder penalty) from the current vehicle position
66 * (used also as optimization - the pathfinder can stop path finding if max_penalty
67 * was reached and no depot was seen)
68 * @return the data about the depot
70 FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penalty);
72 /**
73 * Used when user sends train to the nearest depot or if train needs servicing using YAPF.
74 * @param v train that needs to go to some depot
75 * @param max_distance max distance (int pathfinder penalty) from the current train position
76 * (used also as optimization - the pathfinder can stop path finding if max_penalty
77 * was reached and no depot was seen)
78 * @return the data about the depot
80 FindDepotData YapfTrainFindNearestDepot(const Train *v, int max_distance);
82 /**
83 * Returns true if it is better to reverse the train before leaving station using YAPF.
84 * @param v the train leaving the station
85 * @return true if reversing is better
87 bool YapfTrainCheckReverse(const Train *v);
89 /**
90 * Try to extend the reserved path of a train to the nearest safe tile using YAPF.
92 * @param v The train that needs to find a safe tile.
93 * @param tile Last tile of the current reserved path.
94 * @param td Last trackdir of the current reserved path.
95 * @param override_railtype Should all physically compatible railtypes be searched, even if the vehicle can't run on them on its own?
96 * @return True if the path could be extended to a safe tile.
98 bool YapfTrainFindNearestSafeTile(const Train *v, TileIndex tile, Trackdir td, bool override_railtype);
100 #endif /* YAPF_H */