OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

tunnel_map.h
Go to the documentation of this file.
1 /* $Id: tunnel_map.h 26878 2014-09-21 11:23:33Z rubidium $ */
2
3 /*
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/>.
8 */
9
12 #ifndef TUNNEL_MAP_H
13 #define TUNNEL_MAP_H
14
15 #include "road_map.h"
16
17
24 static inline bool IsTunnel(TileIndex t)
25 {
26 assert(IsTileType(t, MP_TUNNELBRIDGE));
27 return !HasBit(_m[t].m5, 7);
28 }
29
35 static inline bool IsTunnelTile(TileIndex t)
36 {
37 return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
38 }
39
40 TileIndex GetOtherTunnelEnd(TileIndex);
41 bool IsTunnelInWay(TileIndex, int z);
42 bool IsTunnelInWayDir(TileIndex tile, int z, DiagDirection dir);
43
51 static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
52 {
53 SetTileType(t, MP_TUNNELBRIDGE);
54 SetTileOwner(t, o);
55 _m[t].m2 = 0;
56 _m[t].m3 = 0;
57 _m[t].m4 = 0;
58 _m[t].m5 = TRANSPORT_ROAD << 2 | d;
59 SB(_me[t].m6, 2, 4, 0);
60 _me[t].m7 = 0;
61 SetRoadOwner(t, ROADTYPE_ROAD, o);
62 if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o);
63 SetRoadTypes(t, r);
64 }
65
73 static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
74 {
75 SetTileType(t, MP_TUNNELBRIDGE);
76 SetTileOwner(t, o);
77 _m[t].m2 = 0;
78 _m[t].m3 = r;
79 _m[t].m4 = 0;
80 _m[t].m5 = TRANSPORT_RAIL << 2 | d;
81 SB(_me[t].m6, 2, 4, 0);
82 _me[t].m7 = 0;
83 }
84
85 #endif /* TUNNEL_MAP_H */