tron@3154: /* $Id$ */ tron@3154: tron@3154: #ifndef TUNNEL_MAP_H tron@3154: #define TUNNEL_MAP_H tron@3154: tron@3154: #include "direction.h" tron@3154: #include "macros.h" tron@3154: #include "map.h" tron@3154: #include "rail.h" tron@3154: tron@3154: tron@3184: static inline bool IsTunnel(TileIndex t) tron@3184: { tron@3369: assert(IsTileType(t, MP_TUNNELBRIDGE)); tron@3184: return !HASBIT(_m[t].m5, 7); tron@3184: } tron@3184: tron@3184: tron@3184: static inline bool IsTunnelTile(TileIndex t) tron@3184: { tron@3184: return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t); tron@3184: } tron@3184: tron@3184: tron@3154: static inline DiagDirection GetTunnelDirection(TileIndex t) tron@3154: { tron@3369: assert(IsTunnelTile(t)); tron@3154: return (DiagDirection)GB(_m[t].m5, 0, 2); tron@3154: } tron@3154: tron@3154: tron@3154: static inline TransportType GetTunnelTransportType(TileIndex t) tron@3154: { tron@3369: assert(IsTunnelTile(t)); tron@3154: return (TransportType)GB(_m[t].m5, 2, 2); tron@3154: } tron@3154: tron@3154: tron@3154: TileIndex GetOtherTunnelEnd(TileIndex); tron@3156: bool IsTunnelInWay(TileIndex, uint z); tron@3154: tron@3154: tron@3154: static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d) tron@3154: { tron@3154: SetTileType(t, MP_TUNNELBRIDGE); tron@3154: SetTileOwner(t, o); tron@3154: _m[t].m2 = 0; tron@3154: _m[t].m3 = 0; tron@3154: _m[t].m4 = 0; tron@3154: _m[t].m5 = TRANSPORT_ROAD << 2 | d; tron@3154: } tron@3154: tron@3154: static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r) tron@3154: { tron@3154: SetTileType(t, MP_TUNNELBRIDGE); tron@3154: SetTileOwner(t, o); tron@3154: _m[t].m2 = 0; tron@3154: _m[t].m3 = r; tron@3154: _m[t].m4 = 0; tron@3154: _m[t].m5 = TRANSPORT_RAIL << 2 | d; tron@3154: } tron@3154: peter1138@4666: #endif /* TUNNEL_MAP_H */