tron@3154: /* $Id$ */ tron@3154: rubidium@10429: /** @file tunnel_map.h Map accessors for tunnels. */ belugas@6918: tron@3154: #ifndef TUNNEL_MAP_H tron@3154: #define TUNNEL_MAP_H tron@3154: rubidium@8596: #include "direction_func.h" rubidium@8598: #include "rail_type.h" rubidium@8598: #include "road_type.h" rubidium@10444: #include "transport_type.h" rubidium@8604: #include "tile_map.h" tron@3154: smatz@8579: rubidium@7036: /** rubidium@7036: * Is this a tunnel (entrance)? rubidium@7036: * @param t the tile that might be a tunnel rubidium@7036: * @pre IsTileType(t, MP_TUNNELBRIDGE) rubidium@7036: * @return true if and only if this tile is a tunnel (entrance) rubidium@7036: */ tron@3184: static inline bool IsTunnel(TileIndex t) tron@3184: { tron@3369: assert(IsTileType(t, MP_TUNNELBRIDGE)); skidd13@8424: return !HasBit(_m[t].m5, 7); tron@3184: } tron@3184: rubidium@7036: /** rubidium@7036: * Is this a tunnel (entrance)? rubidium@7036: * @param t the tile that might be a tunnel rubidium@7036: * @return true if and only if this tile is a tunnel (entrance) rubidium@7036: */ tron@3184: static inline bool IsTunnelTile(TileIndex t) tron@3184: { tron@3184: return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t); tron@3184: } tron@3184: tron@3154: TileIndex GetOtherTunnelEnd(TileIndex); tron@3156: bool IsTunnelInWay(TileIndex, uint z); rubidium@7498: bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir); tron@3154: rubidium@7036: /** rubidium@7036: * Makes a road tunnel entrance rubidium@7036: * @param t the entrance of the tunnel rubidium@7036: * @param o the owner of the entrance rubidium@7036: * @param d the direction facing out of the tunnel rubidium@7157: * @param r the road type used in the tunnel rubidium@7036: */ rubidium@7157: static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r) tron@3154: { tron@3154: SetTileType(t, MP_TUNNELBRIDGE); tron@3154: SetTileOwner(t, o); tron@3154: _m[t].m2 = 0; rubidium@7157: _m[t].m3 = r; tron@3154: _m[t].m4 = 0; tron@3154: _m[t].m5 = TRANSPORT_ROAD << 2 | d; tron@3154: } tron@3154: rubidium@7036: /** rubidium@7036: * Makes a rail tunnel entrance rubidium@7036: * @param t the entrance of the tunnel rubidium@7036: * @param o the owner of the entrance rubidium@7036: * @param d the direction facing out of the tunnel rubidium@7036: * @param r the rail type used in the tunnel rubidium@7036: */ 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 */