Fix: Violation of strict weak ordering in engine name sorter
[openttd-github.git] / src / pbs.h
bloba7af4e373ec8adeebfab0de0f8878cff8a1092fb
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file pbs.h PBS support routines */
10 #ifndef PBS_H
11 #define PBS_H
13 #include "tile_type.h"
14 #include "direction_type.h"
15 #include "track_type.h"
16 #include "vehicle_type.h"
18 TrackBits GetReservedTrackbits(TileIndex t);
20 void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b);
22 bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations = true);
23 void UnreserveRailTrack(TileIndex tile, Track t);
25 /** This struct contains information about the end of a reserved path. */
26 struct PBSTileInfo {
27 TileIndex tile; ///< Tile the path ends, INVALID_TILE if no valid path was found.
28 Trackdir trackdir; ///< The reserved trackdir on the tile.
29 bool okay; ///< True if tile is a safe waiting position, false otherwise.
31 /**
32 * Create an empty PBSTileInfo.
34 PBSTileInfo() : tile(INVALID_TILE), trackdir(INVALID_TRACKDIR), okay(false) {}
36 /**
37 * Create a PBSTileInfo with given tile, track direction and safe waiting position information.
38 * @param _t The tile where the path ends.
39 * @param _td The reserved track dir on the tile.
40 * @param _okay Whether the tile is a safe waiting point or not.
42 PBSTileInfo(TileIndex _t, Trackdir _td, bool _okay) : tile(_t), trackdir(_td), okay(_okay) {}
45 PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res = nullptr);
46 bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg = false);
47 bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg = false);
49 Train *GetTrainForReservation(TileIndex tile, Track track);
51 /**
52 * Check whether some of tracks is reserved on a tile.
54 * @param tile the tile
55 * @param tracks the tracks to test
56 * @return true if at least on of tracks is reserved
58 static inline bool HasReservedTracks(TileIndex tile, TrackBits tracks)
60 return (GetReservedTrackbits(tile) & tracks) != TRACK_BIT_NONE;
63 #endif /* PBS_H */