4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file tunnel_map.h Map accessors for tunnels. */
19 * Is this a tunnel (entrance)?
20 * @param t the tile that might be a tunnel
21 * @pre IsTileType(t, MP_TUNNELBRIDGE)
22 * @return true if and only if this tile is a tunnel (entrance)
24 static inline bool IsTunnel(TileIndex t
)
26 assert(IsTileType(t
, MP_TUNNELBRIDGE
));
27 return !HasBit(_m
[t
].m5
, 7);
31 * Is this a tunnel (entrance)?
32 * @param t the tile that might be a tunnel
33 * @return true if and only if this tile is a tunnel (entrance)
35 static inline bool IsTunnelTile(TileIndex t
)
37 return IsTileType(t
, MP_TUNNELBRIDGE
) && IsTunnel(t
);
40 TileIndex
GetOtherTunnelEnd(TileIndex
);
41 bool IsTunnelInWay(TileIndex
, int z
);
42 bool IsTunnelInWayDir(TileIndex tile
, int z
, DiagDirection dir
);
45 * Makes a road tunnel entrance
46 * @param t the entrance of the tunnel
47 * @param o the owner of the entrance
48 * @param d the direction facing out of the tunnel
49 * @param r the road type used in the tunnel
51 static inline void MakeRoadTunnel(TileIndex t
, Owner o
, DiagDirection d
, RoadTypes r
)
53 SetTileType(t
, MP_TUNNELBRIDGE
);
58 _m
[t
].m5
= TRANSPORT_ROAD
<< 2 | d
;
59 SB(_me
[t
].m6
, 2, 4, 0);
61 SetRoadOwner(t
, ROADTYPE_ROAD
, o
);
62 if (o
!= OWNER_TOWN
) SetRoadOwner(t
, ROADTYPE_TRAM
, o
);
67 * Makes a rail tunnel entrance
68 * @param t the entrance of the tunnel
69 * @param o the owner of the entrance
70 * @param d the direction facing out of the tunnel
71 * @param r the rail type used in the tunnel
73 static inline void MakeRailTunnel(TileIndex t
, Owner o
, DiagDirection d
, RailType r
)
75 SetTileType(t
, MP_TUNNELBRIDGE
);
80 _m
[t
].m5
= TRANSPORT_RAIL
<< 2 | d
;
81 SB(_me
[t
].m6
, 2, 4, 0);
85 #endif /* TUNNEL_MAP_H */