21 { |
22 { |
22 assert(IsTileType(t, MP_TUNNELBRIDGE)); |
23 assert(IsTileType(t, MP_TUNNELBRIDGE)); |
23 return !HasBit(_m[t].m5, 7); |
24 return !HasBit(_m[t].m5, 7); |
24 } |
25 } |
25 |
26 |
26 |
|
27 /** |
27 /** |
28 * Is this a tunnel (entrance)? |
28 * Is this a tunnel (entrance)? |
29 * @param t the tile that might be a tunnel |
29 * @param t the tile that might be a tunnel |
30 * @return true if and only if this tile is a tunnel (entrance) |
30 * @return true if and only if this tile is a tunnel (entrance) |
31 */ |
31 */ |
32 static inline bool IsTunnelTile(TileIndex t) |
32 static inline bool IsTunnelTile(TileIndex t) |
33 { |
33 { |
34 return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t); |
34 return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t); |
35 } |
35 } |
36 |
36 |
37 /** |
|
38 * Gets the direction facing out of the tunnel |
|
39 * @param t the tile to get the tunnel facing direction of |
|
40 * @pre IsTunnelTile(t) |
|
41 * @return the direction the tunnel is facing |
|
42 */ |
|
43 static inline DiagDirection GetTunnelDirection(TileIndex t) |
|
44 { |
|
45 assert(IsTunnelTile(t)); |
|
46 return (DiagDirection)GB(_m[t].m5, 0, 2); |
|
47 } |
|
48 |
|
49 /** |
|
50 * Gets the transport type of the tunnel (road or rail) |
|
51 * @param t the tunnel entrance tile to get the type of |
|
52 * @pre IsTunnelTile(t) |
|
53 * @return the transport type in the tunnel |
|
54 */ |
|
55 static inline TransportType GetTunnelTransportType(TileIndex t) |
|
56 { |
|
57 assert(IsTunnelTile(t)); |
|
58 return (TransportType)GB(_m[t].m5, 2, 2); |
|
59 } |
|
60 |
|
61 /** |
|
62 * Is this tunnel entrance in a snowy or desert area? |
|
63 * @param t the tunnel entrance tile |
|
64 * @pre IsTunnelTile(t) |
|
65 * @return true if and only if the tunnel entrance is in a snowy/desert area |
|
66 */ |
|
67 static inline bool HasTunnelSnowOrDesert(TileIndex t) |
|
68 { |
|
69 assert(IsTunnelTile(t)); |
|
70 return HasBit(_m[t].m4, 7); |
|
71 } |
|
72 |
|
73 /** |
|
74 * Places this tunnel entrance in a snowy or desert area, |
|
75 * or takes it out of there. |
|
76 * @param t the tunnel entrance tile |
|
77 * @param snow_or_desert is the entrance in snow or desert (true), when |
|
78 * not in snow and not in desert false |
|
79 * @pre IsTunnelTile(t) |
|
80 */ |
|
81 static inline void SetTunnelSnowOrDesert(TileIndex t, bool snow_or_desert) |
|
82 { |
|
83 assert(IsTunnelTile(t)); |
|
84 SB(_m[t].m4, 7, 1, snow_or_desert); |
|
85 } |
|
86 |
|
87 |
|
88 TileIndex GetOtherTunnelEnd(TileIndex); |
37 TileIndex GetOtherTunnelEnd(TileIndex); |
89 bool IsTunnelInWay(TileIndex, uint z); |
38 bool IsTunnelInWay(TileIndex, uint z); |
90 bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir); |
39 bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir); |
91 |
|
92 |
40 |
93 /** |
41 /** |
94 * Makes a road tunnel entrance |
42 * Makes a road tunnel entrance |
95 * @param t the entrance of the tunnel |
43 * @param t the entrance of the tunnel |
96 * @param o the owner of the entrance |
44 * @param o the owner of the entrance |