# tunnelbridge_map.h

Go to the documentation of this file.

    00001 /* $Id: tunnelbridge_map.h 15601 2009-03-02 22:57:47Z rubidium $ */
    00002
    00005 #ifndef TUNNELBRIDGE_MAP_H
    00006 #define TUNNELBRIDGE_MAP_H
    00007
    00008 #include "direction_func.h"
    00009 #include "core/bitmath_func.hpp"
    00010 #include "tile_map.h"
    00011 #include "bridge_map.h"
    00012 #include "tunnel_map.h"
    00013 #include "transport_type.h"
    00014 #include "track_func.h"
    00015
    00016
    00026 static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
    00027 {
    00028   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00029   return (DiagDirection)GB(_m[t].m5, 0, 2);
    00030 }
    00031
    00039 static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
    00040 {
    00041   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00042   return (TransportType)GB(_m[t].m5, 2, 2);
    00043 }
    00044
    00052 static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
    00053 {
    00054   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00055   return HasBit(_me[t].m7, 5);
    00056 }
    00057
    00066 static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
    00067 {
    00068   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00069   SB(_me[t].m7, 5, 1, snow_or_desert);
    00070 }
    00071
    00078 static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
    00079 {
    00080   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00081   return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
    00082 }
    00083
    00084
    00091 static inline bool GetTunnelBridgeReservation(TileIndex t)
    00092 {
    00093   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00094   assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
    00095   return HasBit(_m[t].m5, 4);
    00096 }
    00097
    00104 static inline void SetTunnelBridgeReservation(TileIndex t, bool b)
    00105 {
    00106   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00107   assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
    00108   SB(_m[t].m5, 4, 1, b ? 1 : 0);
    00109 }
    00110
    00117 static inline TrackBits GetRailTunnelBridgeReservation(TileIndex t)
    00118 {
    00119   return GetTunnelBridgeReservation(t) ? DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t)) : TRACK_BIT_NONE;
    00120 }
    00121
    00122 #endif /* TUNNELBRIDGE_MAP_H */