author | rubidium |
Sat, 02 Aug 2008 22:51:53 +0000 | |
changeset 9802 | 6589c004f0d9 |
parent 9798 | 4b8cdc1adf4b |
permissions | -rw-r--r-- |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
1 |
/* $Id$ */ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
2 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8785
diff
changeset
|
3 |
/** @file yapf.h Entry point for OpenTTD to YAPF. */ |
6121
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5587
diff
changeset
|
4 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
5 |
#ifndef YAPF_H |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
6 |
#define YAPF_H |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
7 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
8 |
#include "../debug.h" |
8768
4bcc90746175
(svn r12467) -Codechange: move DepotID to a more logical location.
rubidium
parents:
8636
diff
changeset
|
9 |
#include "../depot_type.h" |
8785
871586967963
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
8768
diff
changeset
|
10 |
#include "../direction_type.h" |
9798
4b8cdc1adf4b
(svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents:
9439
diff
changeset
|
11 |
#include "../pbs.h" |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
12 |
|
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
13 |
/** Finds the best path for given ship. |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
14 |
* @param v the ship that needs to find a path |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
15 |
* @param tile the tile to find the path from (should be next tile the ship is about to enter) |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
16 |
* @param enterdir diagonal direction which the ship will enter this new tile from |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
17 |
* @param tracks available tracks on the new tile (to choose from) |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
18 |
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found |
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
19 |
*/ |
9439 | 20 |
Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks); |
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
21 |
|
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
22 |
/** Finds the best path for given road vehicle. |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
23 |
* @param v the RV that needs to find a path |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
24 |
* @param tile the tile to find the path from (should be next tile the RV is about to enter) |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
25 |
* @param enterdir diagonal direction which the RV will enter this new tile from |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
26 |
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
27 |
*/ |
9439 | 28 |
Trackdir YapfChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir); |
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
29 |
|
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
30 |
/** Finds the best path for given train. |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
31 |
* @param v the train that needs to find a path |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
32 |
* @param tile the tile to find the path from (should be next tile the train is about to enter) |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
33 |
* @param enterdir diagonal direction which the RV will enter this new tile from |
6484
79156627e1ba
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6248
diff
changeset
|
34 |
* @param tracks available trackdirs on the new tile (to choose from) |
79156627e1ba
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6248
diff
changeset
|
35 |
* @param path_not_found [out] true is returned if no path can be found (returned Trackdir is only a 'guess') |
9798
4b8cdc1adf4b
(svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents:
9439
diff
changeset
|
36 |
* @param reserve_track indicates whether YAPF should try to reserve the found path |
4b8cdc1adf4b
(svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents:
9439
diff
changeset
|
37 |
* @param target [out] the target tile of the reservation, free is set to true if path was reserved |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
38 |
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
39 |
*/ |
9798
4b8cdc1adf4b
(svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents:
9439
diff
changeset
|
40 |
Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
41 |
|
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
42 |
/** Used by RV multistop feature to find the nearest road stop that has a free slot. |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
43 |
* @param v RV (its current tile will be the origin) |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
44 |
* @param tile destination tile |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
45 |
* @return distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
46 |
*/ |
3915
914d45c135c7
(svn r5033) -CodeChange: [YAPF] RoadFindPathToStop() can now use YAPF for multistop handling.
KUDr
parents:
3900
diff
changeset
|
47 |
uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile); |
914d45c135c7
(svn r5033) -CodeChange: [YAPF] RoadFindPathToStop() can now use YAPF for multistop handling.
KUDr
parents:
3900
diff
changeset
|
48 |
|
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
49 |
/** Used when user sends RV to the nearest depot or if RV needs servicing. |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
50 |
* Returns the nearest depot (or NULL if depot was not found). |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
51 |
*/ |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
52 |
Depot* YapfFindNearestRoadDepot(const Vehicle *v); |
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
53 |
|
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
54 |
/** Used when user sends train to the nearest depot or if train needs servicing. |
6484
79156627e1ba
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6248
diff
changeset
|
55 |
* @param v train that needs to go to some depot |
79156627e1ba
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6248
diff
changeset
|
56 |
* @param max_distance max distance (number of track tiles) from the current train position |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
57 |
* (used also as optimization - the pathfinder can stop path finding if max_distance |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
58 |
* was reached and no depot was seen) |
6484
79156627e1ba
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6248
diff
changeset
|
59 |
* @param reverse_penalty penalty that should be added for the path that requires reversing the train first |
79156627e1ba
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6248
diff
changeset
|
60 |
* @param depot_tile receives the depot tile if depot was found |
79156627e1ba
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6248
diff
changeset
|
61 |
* @param reversed receives true if train needs to reversed first |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
62 |
* @return the true if depot was found. |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4462
diff
changeset
|
63 |
*/ |
9439 | 64 |
bool YapfFindNearestRailDepotTwoWay(const Vehicle *v, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
65 |
|
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
66 |
/** Returns true if it is better to reverse the train before leaving station */ |
9439 | 67 |
bool YapfCheckReverseTrain(const Vehicle* v); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
68 |
|
9802
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
69 |
/** |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
70 |
* Try to extend the reserved path of a train to the nearest safe tile. |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
71 |
* |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
72 |
* @param v The train that needs to find a safe tile. |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
73 |
* @param tile Last tile of the current reserved path. |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
74 |
* @param td Last trackdir of the current reserved path. |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
75 |
* @param override_railtype Should all physically compabtible railtypes be searched, even if the vehicle can't on them on it own? |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
76 |
* @return True if the path could be extended to a safe tile. |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
77 |
*/ |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
78 |
bool YapfRailFindNearestSafeTile(const Vehicle *v, TileIndex tile, Trackdir td, bool override_railtype); |
6589c004f0d9
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9798
diff
changeset
|
79 |
|
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
80 |
/** Use this function to notify YAPF that track layout (or signal configuration) has change */ |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
81 |
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track); |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
82 |
|
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
83 |
/** performance measurement helpers */ |
6247 | 84 |
void* NpfBeginInterval(); |
9439 | 85 |
int NpfEndInterval(void *perf); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
86 |
|
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
87 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
88 |
extern int _aystar_stats_open_size; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
89 |
extern int _aystar_stats_closed_size; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
90 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
91 |
|
4462
d67a579a5452
(svn r6245) -Add: added comments for all YAPF C interface functions (yapf.h) used by other modules, added FollowTrackInit() into YAPF track followers.
KUDr
parents:
3977
diff
changeset
|
92 |
/** Base tile length units */ |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
93 |
enum { |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
94 |
YAPF_TILE_LENGTH = 100, |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
95 |
YAPF_TILE_CORNER_LENGTH = 71 |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
96 |
}; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
97 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
98 |
#endif /* YAPF_H */ |