1
/* $Id: yapf.h 12252 2008-02-25 15:09:22Z KUDr $ */
1
/* $Id: yapf.h 14949 2009-01-10 00:31:47Z rubidium $ */
3
/** @file yapf.h Entry point for OpenTTD to YAPF. */
8
8
#include "../debug.h"
9
#include "../depot_type.h"
10
#include "../direction_type.h"
10
13
/** Finds the best path for given ship.
11
14
* @param v the ship that needs to find a path
14
17
* @param tracks available tracks on the new tile (to choose from)
15
18
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
17
Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
20
Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
19
22
/** Finds the best path for given road vehicle.
20
23
* @param v the RV that needs to find a path
22
25
* @param enterdir diagonal direction which the RV will enter this new tile from
23
26
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
25
Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir);
28
Trackdir YapfChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir);
27
30
/** Finds the best path for given train.
28
31
* @param v the train that needs to find a path
30
33
* @param enterdir diagonal direction which the RV will enter this new tile from
31
34
* @param tracks available trackdirs on the new tile (to choose from)
32
35
* @param path_not_found [out] true is returned if no path can be found (returned Trackdir is only a 'guess')
36
* @param reserve_track indicates whether YAPF should try to reserve the found path
37
* @param target [out] the target tile of the reservation, free is set to true if path was reserved
33
38
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
35
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found);
40
Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target);
37
42
/** Used by RV multistop feature to find the nearest road stop that has a free slot.
38
43
* @param v RV (its current tile will be the origin)
39
44
* @param tile destination tile
40
45
* @return distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found
42
uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile);
47
uint YapfRoadVehDistanceToTile(const Vehicle *v, TileIndex tile);
44
49
/** Used when user sends RV to the nearest depot or if RV needs servicing.
45
50
* Returns the nearest depot (or NULL if depot was not found).
47
Depot* YapfFindNearestRoadDepot(const Vehicle *v);
52
Depot *YapfFindNearestRoadDepot(const Vehicle *v);
49
54
/** Used when user sends train to the nearest depot or if train needs servicing.
50
55
* @param v train that needs to go to some depot
56
61
* @param reversed receives true if train needs to reversed first
57
62
* @return the true if depot was found.
59
bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed);
64
bool YapfFindNearestRailDepotTwoWay(const Vehicle *v, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed);
61
66
/** Returns true if it is better to reverse the train before leaving station */
62
bool YapfCheckReverseTrain(Vehicle* v);
67
bool YapfCheckReverseTrain(const Vehicle *v);
70
* Try to extend the reserved path of a train to the nearest safe tile.
72
* @param v The train that needs to find a safe tile.
73
* @param tile Last tile of the current reserved path.
74
* @param td Last trackdir of the current reserved path.
75
* @param override_railtype Should all physically compabtible railtypes be searched, even if the vehicle can't on them on it own?
76
* @return True if the path could be extended to a safe tile.
78
bool YapfRailFindNearestSafeTile(const Vehicle *v, TileIndex tile, Trackdir td, bool override_railtype);
64
80
/** Use this function to notify YAPF that track layout (or signal configuration) has change */
65
81
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track);
67
83
/** performance measurement helpers */
68
void* NpfBeginInterval();
69
int NpfEndInterval(void* perf);
84
void *NpfBeginInterval();
85
int NpfEndInterval(void *perf);
72
88
extern int _aystar_stats_open_size;