tunnelbridge_map.h
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 "direction_func.h"
00016 #include "core/bitmath_func.hpp"
00017 #include "tile_map.h"
00018 #include "bridge_map.h"
00019 #include "tunnel_map.h"
00020 #include "transport_type.h"
00021 #include "track_func.h"
00022
00023
00033 static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
00034 {
00035 assert(IsTileType(t, MP_TUNNELBRIDGE));
00036 return (DiagDirection)GB(_m[t].m5, 0, 2);
00037 }
00038
00046 static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
00047 {
00048 assert(IsTileType(t, MP_TUNNELBRIDGE));
00049 return (TransportType)GB(_m[t].m5, 2, 2);
00050 }
00051
00059 static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
00060 {
00061 assert(IsTileType(t, MP_TUNNELBRIDGE));
00062 return HasBit(_me[t].m7, 5);
00063 }
00064
00073 static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
00074 {
00075 assert(IsTileType(t, MP_TUNNELBRIDGE));
00076 SB(_me[t].m7, 5, 1, snow_or_desert);
00077 }
00078
00085 static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
00086 {
00087 assert(IsTileType(t, MP_TUNNELBRIDGE));
00088 return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
00089 }
00090
00091
00098 static inline bool HasTunnelBridgeReservation(TileIndex t)
00099 {
00100 assert(IsTileType(t, MP_TUNNELBRIDGE));
00101 assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
00102 return HasBit(_m[t].m5, 4);
00103 }
00104
00111 static inline void SetTunnelBridgeReservation(TileIndex t, bool b)
00112 {
00113 assert(IsTileType(t, MP_TUNNELBRIDGE));
00114 assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
00115 SB(_m[t].m5, 4, 1, b ? 1 : 0);
00116 }
00117
00124 static inline TrackBits GetTunnelBridgeReservationTrackBits(TileIndex t)
00125 {
00126 return HasTunnelBridgeReservation(t) ? DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t)) : TRACK_BIT_NONE;
00127 }
00128
00129 #endif