11 #include "rail.h" |
11 #include "rail.h" |
12 #include "road_map.h" |
12 #include "road_map.h" |
13 #include "tile.h" |
13 #include "tile.h" |
14 |
14 |
15 |
15 |
|
16 /** |
|
17 * Checks if this is a bridge, instead of a tunnel |
|
18 * @param t The tile to analyze |
|
19 * @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
20 * @return true if the structure is a bridge one |
|
21 */ |
16 static inline bool IsBridge(TileIndex t) |
22 static inline bool IsBridge(TileIndex t) |
17 { |
23 { |
18 assert(IsTileType(t, MP_TUNNELBRIDGE)); |
24 assert(IsTileType(t, MP_TUNNELBRIDGE)); |
19 return HASBIT(_m[t].m5, 7); |
25 return HASBIT(_m[t].m5, 7); |
20 } |
26 } |
21 |
27 |
|
28 /** |
|
29 * checks if there is a bridge on this tile |
|
30 * @param t The tile to analyze |
|
31 * @return true if a bridge is present |
|
32 */ |
22 static inline bool IsBridgeTile(TileIndex t) |
33 static inline bool IsBridgeTile(TileIndex t) |
23 { |
34 { |
24 return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t); |
35 return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t); |
25 } |
36 } |
26 |
37 |
27 |
38 /** |
|
39 * checks for the possibility that a bridge may be on this tile |
|
40 * These are in fact all the tile types on which a bridge can be found |
|
41 * @param t The tile to analyze |
|
42 * @return true if a bridge migh be present |
|
43 */ |
28 static inline bool MayHaveBridgeAbove(TileIndex t) |
44 static inline bool MayHaveBridgeAbove(TileIndex t) |
29 { |
45 { |
30 return |
46 return |
31 IsTileType(t, MP_CLEAR) || |
47 IsTileType(t, MP_CLEAR) || |
32 IsTileType(t, MP_RAILWAY) || |
48 IsTileType(t, MP_RAILWAY) || |
34 IsTileType(t, MP_WATER) || |
50 IsTileType(t, MP_WATER) || |
35 IsTileType(t, MP_TUNNELBRIDGE) || |
51 IsTileType(t, MP_TUNNELBRIDGE) || |
36 IsTileType(t, MP_UNMOVABLE); |
52 IsTileType(t, MP_UNMOVABLE); |
37 } |
53 } |
38 |
54 |
39 |
55 /** |
|
56 * checks if a bridge is set above the ground of this tile |
|
57 * @param t The tile to analyze |
|
58 * @return true if a bridge is detected above |
|
59 */ |
40 static inline bool IsBridgeAbove(TileIndex t) |
60 static inline bool IsBridgeAbove(TileIndex t) |
41 { |
61 { |
42 assert(MayHaveBridgeAbove(t)); |
62 assert(MayHaveBridgeAbove(t)); |
43 return GB(_m[t].m6, 6, 2) != 0; |
63 return GB(_m[t].m6, 6, 2) != 0; |
44 } |
64 } |
45 |
65 |
46 |
66 |
47 /** |
67 /** |
48 * Determines the type of bridge on a tile |
68 * Determines the type of bridge on a tile |
49 * @param tile The tile to analyze |
69 * @param t The tile to analyze |
50 * @return The bridge type |
70 * @return The bridge type |
51 */ |
71 */ |
52 static inline uint GetBridgeType(TileIndex t) |
72 static inline uint GetBridgeType(TileIndex t) |
53 { |
73 { |
54 assert(IsBridgeTile(t)); |
74 assert(IsBridgeTile(t)); |
56 } |
76 } |
57 |
77 |
58 |
78 |
59 /** |
79 /** |
60 * Get the direction pointing onto the bridge |
80 * Get the direction pointing onto the bridge |
61 * @param tile The tile to analyze |
81 * @param t The tile to analyze |
62 * @return the above mentionned direction |
82 * @return the above mentionned direction |
63 */ |
83 */ |
64 static inline DiagDirection GetBridgeRampDirection(TileIndex t) |
84 static inline DiagDirection GetBridgeRampDirection(TileIndex t) |
65 { |
85 { |
66 assert(IsBridgeTile(t)); |
86 assert(IsBridgeTile(t)); |