rubidium@9786: /* $Id$ */ rubidium@9786: rubidium@9786: /** @file pbs.h PBS support routines */ rubidium@9786: rubidium@9786: #ifndef PBS_H rubidium@9786: #define PBS_H rubidium@9786: rubidium@9786: #include "tile_type.h" rubidium@9787: #include "direction_type.h" rubidium@9786: #include "track_type.h" rubidium@9798: #include "vehicle_type.h" rubidium@9786: rubidium@9786: TrackBits GetReservedTrackbits(TileIndex t); rubidium@9786: rubidium@9787: void SetRailwayStationPlatformReservation(TileIndex start, DiagDirection dir, bool b); rubidium@9787: rubidium@9787: bool TryReserveRailTrack(TileIndex tile, Track t); rubidium@9787: void UnreserveRailTrack(TileIndex tile, Track t); rubidium@9787: rubidium@9798: /** This struct contains information about the end of a reserved path. */ rubidium@9798: struct PBSTileInfo { rubidium@9798: TileIndex tile; ///< Tile the path ends, INVALID_TILE if no valid path was found. rubidium@9798: Trackdir trackdir; ///< The reserved trackdir on the tile. rubidium@9798: bool okay; ///< True if tile is a safe wairing position, false otherwise. rubidium@9798: rubidium@9798: PBSTileInfo() : tile(INVALID_TILE), trackdir(INVALID_TRACKDIR), okay(false) {} rubidium@9798: PBSTileInfo(TileIndex _t, Trackdir _td, bool _okay) : tile(_t), trackdir(_td), okay(_okay) {} rubidium@9798: }; rubidium@9798: frosch@9831: PBSTileInfo FollowTrainReservation(const Vehicle *v, Vehicle **train_on_res = NULL); rubidium@9798: bool IsSafeWaitingPosition(const Vehicle *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg = false); rubidium@9798: bool IsWaitingPositionFree(const Vehicle *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg = false); rubidium@9798: rubidium@9814: Vehicle *GetTrainForReservation(TileIndex tile, Track track); rubidium@9814: rubidium@9787: /** rubidium@9787: * Check whether some of tracks is reserved on a tile. rubidium@9787: * rubidium@9787: * @param tile the tile rubidium@9787: * @param tracks the tracks to test rubidium@9787: * @return true if at least on of tracks is reserved rubidium@9787: */ rubidium@9787: static inline bool HasReservedTracks(TileIndex tile, TrackBits tracks) rubidium@9787: { rubidium@9787: return (GetReservedTrackbits(tile) & tracks) != TRACK_BIT_NONE; rubidium@9787: } rubidium@9787: rubidium@9786: #endif /* PBS_H */