diff options
author | rubidium <rubidium@openttd.org> | 2008-08-02 22:47:20 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-08-02 22:47:20 +0000 |
commit | ec7cc498254cccf3e1d150e6d978b7cf2b89eb89 (patch) | |
tree | 8771ffd53d04267f920a1a780c439b1f8f8c63de /src/road_map.h | |
parent | ea570c81600edf40dfa6876d20e5e3a6ededb3d3 (diff) | |
download | openttd-ec7cc498254cccf3e1d150e6d978b7cf2b89eb89.tar.xz |
(svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
Diffstat (limited to 'src/road_map.h')
-rw-r--r-- | src/road_map.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/road_map.h b/src/road_map.h index 756e3fcb7..dfd88ae3f 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -253,6 +253,43 @@ static inline TrackBits GetCrossingRailBits(TileIndex tile) return AxisToTrackBits(GetCrossingRailAxis(tile)); } + +/** + * Get the reservation state of the rail crossing + * @pre IsLevelCrossingTile(t) + * @param t the crossing tile + * @return reservation state + */ +static inline bool GetCrossingReservation(TileIndex t) +{ + assert(IsLevelCrossingTile(t)); + return HasBit(_m[t].m5, 4); +} + +/** + * Set the reservation state of the rail crossing + * @note Works for both waypoints and rail depots + * @pre IsLevelCrossingTile(t) + * @param t the crossing tile + * @param b the reservation state + */ +static inline void SetCrossingReservation(TileIndex t, bool b) +{ + assert(IsLevelCrossingTile(t)); + SB(_m[t].m5, 4, 1, b ? 1 : 0); +} + +/** + * Get the reserved track bits for a rail crossing + * @pre IsLevelCrossingTile(t) + * @param t the tile + * @return reserved track bits + */ +static inline TrackBits GetRailCrossingReservation(TileIndex t) +{ + return GetCrossingReservation(t) ? GetCrossingRailBits(t) : TRACK_BIT_NONE; +} + static inline bool IsCrossingBarred(TileIndex t) { assert(IsLevelCrossing(t)); |