smatz@8579: /* $Id$ */ smatz@8579: smatz@8579: /** @file tunnelbridge_map.h Functions that have tunnels and bridges in common */ smatz@8579: smatz@8579: #ifndef TUNNELBRIDGE_MAP_H smatz@8579: #define TUNNELBRIDGE_MAP_H smatz@8579: rubidium@8596: #include "direction_func.h" rubidium@8635: #include "core/bitmath_func.hpp" rubidium@8635: #include "tile_map.h" smatz@8693: #include "bridge_map.h" smatz@8693: #include "tunnel_map.h" smatz@8579: smatz@8579: smatz@8579: /** frosch@8977: * Get the direction pointing to the other end. frosch@8977: * frosch@8977: * Tunnel: Get the direction facing into the tunnel smatz@8579: * Bridge: Get the direction pointing onto the bridge smatz@8579: * @param t The tile to analyze smatz@8579: * @pre IsTileType(t, MP_TUNNELBRIDGE) smatz@8579: * @return the above mentionned direction smatz@8579: */ smatz@8579: static inline DiagDirection GetTunnelBridgeDirection(TileIndex t) smatz@8579: { smatz@8579: assert(IsTileType(t, MP_TUNNELBRIDGE)); smatz@8579: return (DiagDirection)GB(_m[t].m5, 0, 2); smatz@8579: } smatz@8579: smatz@8579: /** smatz@8579: * Tunnel: Get the transport type of the tunnel (road or rail) smatz@8579: * Bridge: Get the transport type of the bridge's ramp smatz@8579: * @param t The tile to analyze smatz@8579: * @pre IsTileType(t, MP_TUNNELBRIDGE) smatz@8579: * @return the transport type in the tunnel/bridge smatz@8579: */ smatz@8579: static inline TransportType GetTunnelBridgeTransportType(TileIndex t) smatz@8579: { smatz@8579: assert(IsTileType(t, MP_TUNNELBRIDGE)); smatz@8579: return (TransportType)GB(_m[t].m5, 2, 2); smatz@8579: } smatz@8579: smatz@8579: /** smatz@8579: * Tunnel: Is this tunnel entrance in a snowy or desert area? smatz@8579: * Bridge: Does the bridge ramp lie in a snow or desert area? smatz@8579: * @param t The tile to analyze smatz@8579: * @pre IsTileType(t, MP_TUNNELBRIDGE) smatz@8579: * @return true if and only if the tile is in a snowy/desert area smatz@8579: */ smatz@8579: static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t) smatz@8579: { smatz@8579: assert(IsTileType(t, MP_TUNNELBRIDGE)); smatz@8579: return HasBit(_m[t].m4, 7); smatz@8579: } smatz@8579: smatz@8579: /** smatz@8579: * Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there. smatz@8579: * Bridge: Sets whether the bridge ramp lies in a snow or desert area. smatz@8579: * @param t the tunnel entrance / bridge ramp tile smatz@8579: * @param snow_or_desert is the entrance/ramp in snow or desert (true), when smatz@8579: * not in snow and not in desert false smatz@8579: * @pre IsTileType(t, MP_TUNNELBRIDGE) smatz@8579: */ smatz@8579: static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert) smatz@8579: { smatz@8579: assert(IsTileType(t, MP_TUNNELBRIDGE)); smatz@8579: SB(_m[t].m4, 7, 1, snow_or_desert); smatz@8579: } smatz@8579: smatz@8693: /** smatz@8693: * Determines type of the wormhole and returns its other end smatz@8693: * @param t one end smatz@8693: * @pre IsTileType(t, MP_TUNNELBRIDGE) smatz@8693: * @return other end smatz@8693: */ smatz@8693: static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t) smatz@8693: { smatz@8693: assert(IsTileType(t, MP_TUNNELBRIDGE)); smatz@8693: return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t); smatz@8693: } smatz@8693: smatz@8579: #endif /* TUNNELBRIDGE_MAP_H */