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