OpenTTD

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 */
track_type.h
All types related to tracks.
direction_type.h
Different types to &#39;show&#39; directions.
GetReservedTrackbits
TrackBits GetReservedTrackbits(TileIndex t)
Get the reserved trackbits for any tile, regardless of type.
Definition: pbs.cpp:26
Track
Track
These are used to specify a single track.
Definition: track_type.h:21
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:212
IsSafeWaitingPosition
bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg=false)
Determine whether a certain track on a tile is a safe position to end a path.
Definition: pbs.cpp:383
GetTrainForReservation
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
Definition: pbs.cpp:333
TryReserveRailTrack
bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations=true)
Try to reserve a specific track on a tile.
Definition: pbs.cpp:82
PBSTileInfo::PBSTileInfo
PBSTileInfo(TileIndex _t, Trackdir _td, bool _okay)
Create a PBSTileInfo with given tile, track direction and safe waiting position information.
Definition: pbs.h:44
TrackBits
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:41
IsWaitingPositionFree
bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg=false)
Check if a safe position is free.
Definition: pbs.cpp:429
PBSTileInfo::PBSTileInfo
PBSTileInfo()
Create an empty PBSTileInfo.
Definition: pbs.h:36
SetRailStationPlatformReservation
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
Set the reservation for a complete station platform.
Definition: pbs.cpp:59
Trackdir
Trackdir
Enumeration for tracks and directions.
Definition: track_type.h:74
PBSTileInfo::okay
bool okay
True if tile is a safe waiting position, false otherwise.
Definition: pbs.h:31
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:80
PBSTileInfo::tile
TileIndex tile
Tile the path ends, INVALID_TILE if no valid path was found.
Definition: pbs.h:29
Train
&#39;Train&#39; is either a loco or a wagon.
Definition: train.h:88
PBSTileInfo
This struct contains information about the end of a reserved path.
Definition: pbs.h:28
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
vehicle_type.h
Types related to vehicles.
PBSTileInfo::trackdir
Trackdir trackdir
The reserved trackdir on the tile.
Definition: pbs.h:30
HasReservedTracks
static bool HasReservedTracks(TileIndex tile, TrackBits tracks)
Check whether some of tracks is reserved on a tile.
Definition: pbs.h:60
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:85
INVALID_TRACKDIR
Flag for an invalid trackdir.
Definition: track_type.h:93
FollowTrainReservation
PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res=NULL)
Follow a train reservation to the last tile.
Definition: pbs.cpp:291
tile_type.h
Types related to tiles.
UnreserveRailTrack
void UnreserveRailTrack(TileIndex tile, Track t)
Lift the reservation of a specific track on a tile.
Definition: pbs.cpp:143
TRACK_BIT_NONE
No track.
Definition: track_type.h:42