annotate src/pbs.h @ 20729:ea20edff1862 draft default tip master

(svn r25643) -Fix (r25480): [OSX] Define version constants before they're used
author planetmaker <planetmaker@openttd.org>
date Wed, 31 Jul 2013 18:50:01 +0000 (2013-07-31)
parents f8c0e108128c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9786
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
1 /* $Id$ */
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12502
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12502
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12502
diff changeset
5 * 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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12502
diff changeset
6 * 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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12502
diff changeset
7 * 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/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12502
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12502
diff changeset
9
9786
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
10 /** @file pbs.h PBS support routines */
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
11
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
12 #ifndef PBS_H
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
13 #define PBS_H
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
14
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
15 #include "tile_type.h"
9787
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
16 #include "direction_type.h"
9786
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
17 #include "track_type.h"
9798
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
18 #include "vehicle_type.h"
9786
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
19
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
20 TrackBits GetReservedTrackbits(TileIndex t);
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
21
12502
9472b49c61a1 (svn r16939) -Codechange: s/RailwayStation/RailStation/ to unify the way it's written.
rubidium <rubidium@openttd.org>
parents: 11985
diff changeset
22 void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b);
9787
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
23
19973
f8c0e108128c (svn r24905) -Feature(ish): Implement station randomisation triggers.
peter1138 <peter1138@openttd.org>
parents: 17639
diff changeset
24 bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations = true);
9787
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
25 void UnreserveRailTrack(TileIndex tile, Track t);
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
26
9798
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
27 /** This struct contains information about the end of a reserved path. */
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
28 struct PBSTileInfo {
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
29 TileIndex tile; ///< Tile the path ends, INVALID_TILE if no valid path was found.
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
30 Trackdir trackdir; ///< The reserved trackdir on the tile.
10027
673c3c22b5c5 (svn r14186) -Fix [FS#2255]: small typo (Jafinto)
rubidium <rubidium@openttd.org>
parents: 9831
diff changeset
31 bool okay; ///< True if tile is a safe waiting position, false otherwise.
9798
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
32
17639
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
33 /**
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
34 * Create an empty PBSTileInfo.
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
35 */
9798
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
36 PBSTileInfo() : tile(INVALID_TILE), trackdir(INVALID_TRACKDIR), okay(false) {}
17639
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
37
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
38 /**
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
39 * Create a PBSTileInfo with given tile, track direction and safe waiting position information.
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
40 * @param _t The tile where the path ends.
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
41 * @param _td The reserved track dir on the tile.
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
42 * @param _okay Whether the tile is a safe waiting point or not.
3cd4f18cdbc1 (svn r22410) -Document: some more bits ;)
rubidium <rubidium@openttd.org>
parents: 14100
diff changeset
43 */
9798
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
44 PBSTileInfo(TileIndex _t, Trackdir _td, bool _okay) : tile(_t), trackdir(_td), okay(_okay) {}
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
45 };
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
46
14100
e4f2ba58a34f (svn r18647) -Fix: [YAPP] A train inside a station was not always found when checking for trains on a reserved path.
michi_cc <michi_cc@openttd.org>
parents: 12778
diff changeset
47 PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res = NULL);
11985
e05790b0a6c6 (svn r16391) -Codechange: use Train instead of Vehicle where appropriate.
rubidium <rubidium@openttd.org>
parents: 10083
diff changeset
48 bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg = false);
e05790b0a6c6 (svn r16391) -Codechange: use Train instead of Vehicle where appropriate.
rubidium <rubidium@openttd.org>
parents: 10083
diff changeset
49 bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg = false);
9798
ccd88d3e3e23 (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9787
diff changeset
50
11985
e05790b0a6c6 (svn r16391) -Codechange: use Train instead of Vehicle where appropriate.
rubidium <rubidium@openttd.org>
parents: 10083
diff changeset
51 Train *GetTrainForReservation(TileIndex tile, Track track);
9814
7cd3c451b12d (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9798
diff changeset
52
9787
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
53 /**
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
54 * Check whether some of tracks is reserved on a tile.
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
55 *
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
56 * @param tile the tile
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
57 * @param tracks the tracks to test
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
58 * @return true if at least on of tracks is reserved
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
59 */
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
60 static inline bool HasReservedTracks(TileIndex tile, TrackBits tracks)
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
61 {
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
62 return (GetReservedTrackbits(tile) & tracks) != TRACK_BIT_NONE;
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
63 }
7b4d79522b7e (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9786
diff changeset
64
9786
f94081b1f0dc (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
diff changeset
65 #endif /* PBS_H */