|
1 /* $Id$ */ |
|
2 |
|
3 /** @file tunnelbridge_map.h Functions that have tunnels and bridges in common */ |
|
4 |
|
5 #ifndef TUNNELBRIDGE_MAP_H |
|
6 #define TUNNELBRIDGE_MAP_H |
|
7 |
|
8 #include "direction_func.h" |
|
9 #include "core/bitmath_func.hpp" |
|
10 #include "tile_map.h" |
|
11 #include "bridge_map.h" |
|
12 #include "tunnel_map.h" |
|
13 |
|
14 |
|
15 /** |
|
16 * Tunnel: Get the direction facing out of the tunnel |
|
17 * Bridge: Get the direction pointing onto the bridge |
|
18 * @param t The tile to analyze |
|
19 * @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
20 * @return the above mentionned direction |
|
21 */ |
|
22 static inline DiagDirection GetTunnelBridgeDirection(TileIndex t) |
|
23 { |
|
24 assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
25 return (DiagDirection)GB(_m[t].m5, 0, 2); |
|
26 } |
|
27 |
|
28 /** |
|
29 * Tunnel: Get the transport type of the tunnel (road or rail) |
|
30 * Bridge: Get the transport type of the bridge's ramp |
|
31 * @param t The tile to analyze |
|
32 * @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
33 * @return the transport type in the tunnel/bridge |
|
34 */ |
|
35 static inline TransportType GetTunnelBridgeTransportType(TileIndex t) |
|
36 { |
|
37 assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
38 return (TransportType)GB(_m[t].m5, 2, 2); |
|
39 } |
|
40 |
|
41 /** |
|
42 * Tunnel: Is this tunnel entrance in a snowy or desert area? |
|
43 * Bridge: Does the bridge ramp lie in a snow or desert area? |
|
44 * @param t The tile to analyze |
|
45 * @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
46 * @return true if and only if the tile is in a snowy/desert area |
|
47 */ |
|
48 static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t) |
|
49 { |
|
50 assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
51 return HasBit(_m[t].m4, 7); |
|
52 } |
|
53 |
|
54 /** |
|
55 * Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there. |
|
56 * Bridge: Sets whether the bridge ramp lies in a snow or desert area. |
|
57 * @param t the tunnel entrance / bridge ramp tile |
|
58 * @param snow_or_desert is the entrance/ramp in snow or desert (true), when |
|
59 * not in snow and not in desert false |
|
60 * @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
61 */ |
|
62 static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert) |
|
63 { |
|
64 assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
65 SB(_m[t].m4, 7, 1, snow_or_desert); |
|
66 } |
|
67 |
|
68 /** |
|
69 * Determines type of the wormhole and returns its other end |
|
70 * @param t one end |
|
71 * @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
72 * @return other end |
|
73 */ |
|
74 static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t) |
|
75 { |
|
76 assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
77 return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t); |
|
78 } |
|
79 |
|
80 #endif /* TUNNELBRIDGE_MAP_H */ |