tron@3154: /* $Id$ */ tron@3154: rubidium@9111: /** @file tunnel_map.h Map accessors for tunnels. */ belugas@6422: tron@3154: #ifndef TUNNEL_MAP_H tron@3154: #define TUNNEL_MAP_H tron@3154: rubidium@8100: #include "direction_func.h" rubidium@8102: #include "rail_type.h" rubidium@8102: #include "road_type.h" rubidium@9126: #include "transport_type.h" rubidium@8108: #include "tile_map.h" tron@3154: smatz@8083: rubidium@6540: /** rubidium@6540: * Is this a tunnel (entrance)? rubidium@6540: * @param t the tile that might be a tunnel rubidium@6540: * @pre IsTileType(t, MP_TUNNELBRIDGE) rubidium@6540: * @return true if and only if this tile is a tunnel (entrance) rubidium@6540: */ tron@3184: static inline bool IsTunnel(TileIndex t) tron@3184: { tron@3369: assert(IsTileType(t, MP_TUNNELBRIDGE)); skidd13@7928: return !HasBit(_m[t].m5, 7); tron@3184: } tron@3184: rubidium@6540: /** rubidium@6540: * Is this a tunnel (entrance)? rubidium@6540: * @param t the tile that might be a tunnel rubidium@6540: * @return true if and only if this tile is a tunnel (entrance) rubidium@6540: */ 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@7002: bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir); tron@3154: rubidium@6540: /** rubidium@6540: * Makes a road tunnel entrance rubidium@6540: * @param t the entrance of the tunnel rubidium@6540: * @param o the owner of the entrance rubidium@6540: * @param d the direction facing out of the tunnel rubidium@6661: * @param r the road type used in the tunnel rubidium@6540: */ rubidium@6661: 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@6661: _m[t].m3 = r; tron@3154: _m[t].m4 = 0; tron@3154: _m[t].m5 = TRANSPORT_ROAD << 2 | d; tron@3154: } tron@3154: rubidium@6540: /** rubidium@6540: * Makes a rail tunnel entrance rubidium@6540: * @param t the entrance of the tunnel rubidium@6540: * @param o the owner of the entrance rubidium@6540: * @param d the direction facing out of the tunnel rubidium@6540: * @param r the rail type used in the tunnel rubidium@6540: */ 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 */