Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef TUNNELBRIDGE_MAP_H
00013 #define TUNNELBRIDGE_MAP_H
00014
00015 #include "bridge_map.h"
00016 #include "tunnel_map.h"
00017
00018
00028 static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
00029 {
00030 assert(IsTileType(t, MP_TUNNELBRIDGE));
00031 return (DiagDirection)GB(_m[t].m5, 0, 2);
00032 }
00033
00041 static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
00042 {
00043 assert(IsTileType(t, MP_TUNNELBRIDGE));
00044 return (TransportType)GB(_m[t].m5, 2, 2);
00045 }
00046
00054 static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
00055 {
00056 assert(IsTileType(t, MP_TUNNELBRIDGE));
00057 return HasBit(_me[t].m7, 5);
00058 }
00059
00068 static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
00069 {
00070 assert(IsTileType(t, MP_TUNNELBRIDGE));
00071 SB(_me[t].m7, 5, 1, snow_or_desert);
00072 }
00073
00080 static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
00081 {
00082 assert(IsTileType(t, MP_TUNNELBRIDGE));
00083 return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
00084 }
00085
00086
00093 static inline bool HasTunnelBridgeReservation(TileIndex t)
00094 {
00095 assert(IsTileType(t, MP_TUNNELBRIDGE));
00096 assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
00097 return HasBit(_m[t].m5, 4);
00098 }
00099
00106 static inline void SetTunnelBridgeReservation(TileIndex t, bool b)
00107 {
00108 assert(IsTileType(t, MP_TUNNELBRIDGE));
00109 assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
00110 SB(_m[t].m5, 4, 1, b ? 1 : 0);
00111 }
00112
00119 static inline TrackBits GetTunnelBridgeReservationTrackBits(TileIndex t)
00120 {
00121 return HasTunnelBridgeReservation(t) ? DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t)) : TRACK_BIT_NONE;
00122 }
00123
00128 static inline void SetBitTunnelBridgeSignal(TileIndex t)
00129 {
00130 assert(IsTileType(t, MP_TUNNELBRIDGE));
00131 SetBit(_m[t].m5, 5);
00132 }
00133
00138 static inline void ClrBitTunnelBridgeSignal(TileIndex t)
00139 {
00140 assert(IsTileType(t, MP_TUNNELBRIDGE));
00141 ClrBit(_m[t].m5, 5);
00142 }
00143
00148 static inline void SetBitTunnelBridgeExit(TileIndex t)
00149 {
00150 assert(IsTileType(t, MP_TUNNELBRIDGE));
00151 SetBit(_m[t].m5, 6);
00152 }
00153
00158 static inline void ClrBitTunnelBridgeExit(TileIndex t)
00159 {
00160 assert(IsTileType(t, MP_TUNNELBRIDGE));
00161 ClrBit(_m[t].m5, 6);
00162 }
00163
00170 static inline bool HasWormholeSignals(TileIndex t)
00171 {
00172 return IsTileType(t, MP_TUNNELBRIDGE) && (HasBit(_m[t].m5, 5) || HasBit(_m[t].m5, 6)) ;
00173 }
00174
00181 static inline bool IsTunnelBridgeWithSignGreen(TileIndex t)
00182 {
00183 assert(IsTileType(t, MP_TUNNELBRIDGE));
00184 return HasBit(_m[t].m5, 5) && !HasBit(_m[t].m5, 6);
00185 }
00186
00187 static inline bool IsTunnelBridgeWithSignRed(TileIndex t)
00188 {
00189 assert(IsTileType(t, MP_TUNNELBRIDGE));
00190 return HasBit(_m[t].m5, 5) && HasBit(_m[t].m5, 6);
00191 }
00192
00199 static inline bool IsTunnelBridgeEntrance(TileIndex t)
00200 {
00201 assert(IsTileType(t, MP_TUNNELBRIDGE));
00202 return HasBit(_m[t].m5, 5) ;
00203 }
00204
00210 static inline bool IsTunnelBridgeExit(TileIndex t)
00211 {
00212 assert(IsTileType(t, MP_TUNNELBRIDGE));
00213 return !HasBit(_m[t].m5, 5) && HasBit(_m[t].m5, 6);
00214 }
00215
00216 #endif