OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

pbs.h
Go to the documentation of this file.
1 /* $Id: pbs.h 24905 2013-01-11 07:39:25Z peter1138 $ */
2
3 /*
4 * This file is part of OpenTTD.
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.
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.
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/>.
8 */
9
12 #ifndef PBS_H
13 #define PBS_H
14
15 #include "tile_type.h"
16 #include "direction_type.h"
17 #include "track_type.h"
18 #include "vehicle_type.h"
19
20 TrackBits GetReservedTrackbits(TileIndex t);
21
22 void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b);
23
24 bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations = true);
25 void UnreserveRailTrack(TileIndex tile, Track t);
26
28 struct PBSTileInfo {
29 TileIndex tile;
30 Trackdir trackdir;
31 bool okay;
32
36 PBSTileInfo() : tile(INVALID_TILE), trackdir(INVALID_TRACKDIR), okay(false) {}
37
44 PBSTileInfo(TileIndex _t, Trackdir _td, bool _okay) : tile(_t), trackdir(_td), okay(_okay) {}
45 };
46
47 PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res = NULL);
48 bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg = false);
49 bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg = false);
50
51 Train *GetTrainForReservation(TileIndex tile, Track track);
52
60 static inline bool HasReservedTracks(TileIndex tile, TrackBits tracks)
61 {
62 return (GetReservedTrackbits(tile) & tracks) != TRACK_BIT_NONE;
63 }
64
65 #endif /* PBS_H */