1
/* $Id: pbs.h 14258 2008-09-07 11:23:10Z rubidium $ */
3
/** @file pbs.h PBS support routines */
9
#include "direction_type.h"
10
#include "track_type.h"
11
#include "vehicle_type.h"
13
TrackBits GetReservedTrackbits(TileIndex t);
15
void SetRailwayStationPlatformReservation(TileIndex start, DiagDirection dir, bool b);
17
bool TryReserveRailTrack(TileIndex tile, Track t);
18
void UnreserveRailTrack(TileIndex tile, Track t);
20
/** This struct contains information about the end of a reserved path. */
22
TileIndex tile; ///< Tile the path ends, INVALID_TILE if no valid path was found.
23
Trackdir trackdir; ///< The reserved trackdir on the tile.
24
bool okay; ///< True if tile is a safe waiting position, false otherwise.
26
PBSTileInfo() : tile(INVALID_TILE), trackdir(INVALID_TRACKDIR), okay(false) {}
27
PBSTileInfo(TileIndex _t, Trackdir _td, bool _okay) : tile(_t), trackdir(_td), okay(_okay) {}
30
PBSTileInfo FollowTrainReservation(const Vehicle *v, bool *train_on_res = NULL);
31
bool IsSafeWaitingPosition(const Vehicle *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg = false);
32
bool IsWaitingPositionFree(const Vehicle *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg = false);
34
Vehicle *GetTrainForReservation(TileIndex tile, Track track);
37
* Check whether some of tracks is reserved on a tile.
39
* @param tile the tile
40
* @param tracks the tracks to test
41
* @return true if at least on of tracks is reserved
43
static inline bool HasReservedTracks(TileIndex tile, TrackBits tracks)
45
return (GetReservedTrackbits(tile) & tracks) != TRACK_BIT_NONE;