2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file tunnel_map.h Map accessors for tunnels. */
17 * Is this a tunnel (entrance)?
18 * @param t the tile that might be a tunnel
19 * @pre IsTileType(t, MP_TUNNELBRIDGE)
20 * @return true if and only if this tile is a tunnel (entrance)
22 static inline bool IsTunnel(TileIndex t
)
24 assert(IsTileType(t
, MP_TUNNELBRIDGE
));
25 return !HasBit(_m
[t
].m5
, 7);
29 * Is this a tunnel (entrance)?
30 * @param t the tile that might be a tunnel
31 * @return true if and only if this tile is a tunnel (entrance)
33 static inline bool IsTunnelTile(TileIndex t
)
35 return IsTileType(t
, MP_TUNNELBRIDGE
) && IsTunnel(t
);
38 TileIndex
GetOtherTunnelEnd(TileIndex
);
39 bool IsTunnelInWay(TileIndex
, int z
);
40 bool IsTunnelInWayDir(TileIndex tile
, int z
, DiagDirection dir
);
43 * Makes a road tunnel entrance
44 * @param t the entrance of the tunnel
45 * @param o the owner of the entrance
46 * @param d the direction facing out of the tunnel
47 * @param r the road type used in the tunnel
49 static inline void MakeRoadTunnel(TileIndex t
, Owner o
, DiagDirection d
, RoadType road_rt
, RoadType tram_rt
)
51 SetTileType(t
, MP_TUNNELBRIDGE
);
56 _m
[t
].m5
= TRANSPORT_ROAD
<< 2 | d
;
57 SB(_me
[t
].m6
, 2, 4, 0);
60 SetRoadOwner(t
, RTT_ROAD
, o
);
61 if (o
!= OWNER_TOWN
) SetRoadOwner(t
, RTT_TRAM
, o
);
62 SetRoadTypes(t
, road_rt
, tram_rt
);
66 * Makes a rail tunnel entrance
67 * @param t the entrance of the tunnel
68 * @param o the owner of the entrance
69 * @param d the direction facing out of the tunnel
70 * @param r the rail type used in the tunnel
72 static inline void MakeRailTunnel(TileIndex t
, Owner o
, DiagDirection d
, RailType r
)
74 SetTileType(t
, MP_TUNNELBRIDGE
);
79 _m
[t
].m5
= TRANSPORT_RAIL
<< 2 | d
;
80 SB(_me
[t
].m6
, 2, 4, 0);
85 #endif /* TUNNEL_MAP_H */