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/tunnelbridge_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/tunnelbridge_map.h')
-rw-r--r-- | src/tunnelbridge_map.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tunnelbridge_map.h b/src/tunnelbridge_map.h index bdc709944..5b5c6e447 100644 --- a/src/tunnelbridge_map.h +++ b/src/tunnelbridge_map.h @@ -11,6 +11,7 @@ #include "bridge_map.h" #include "tunnel_map.h" #include "transport_type.h" +#include "track_func.h" /** @@ -80,4 +81,42 @@ static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t) return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t); } + +/** + * Get the reservation state of the rail tunnel/bridge + * @pre IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL + * @param t the tile + * @return reservation state + */ +static inline bool GetTunnelBridgeReservation(TileIndex t) +{ + assert(IsTileType(t, MP_TUNNELBRIDGE)); + assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL); + return HasBit(_m[t].m5, 4); +} + +/** + * Set the reservation state of the rail tunnel/bridge + * @pre IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL + * @param t the tile + * @param b the reservation state + */ +static inline void SetTunnelBridgeReservation(TileIndex t, bool b) +{ + assert(IsTileType(t, MP_TUNNELBRIDGE)); + assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL); + SB(_m[t].m5, 4, 1, b ? 1 : 0); +} + +/** + * Get the reserved track bits for a rail tunnel/bridge + * @pre IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL + * @param t the tile + * @return reserved track bits + */ +static inline TrackBits GetRailTunnelBridgeReservation(TileIndex t) +{ + return GetTunnelBridgeReservation(t) ? DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t)) : TRACK_BIT_NONE; +} + #endif /* TUNNELBRIDGE_MAP_H */ |