4 |
4 |
5 #ifndef ROAD_H |
5 #ifndef ROAD_H |
6 #define ROAD_H |
6 #define ROAD_H |
7 |
7 |
8 #include "helpers.hpp" |
8 #include "helpers.hpp" |
|
9 |
|
10 /** |
|
11 * The different roadtypes we support |
|
12 * @note currently only ROADTYPE_ROAD is supported. |
|
13 */ |
|
14 enum RoadType { |
|
15 ROADTYPE_ROAD = 0, |
|
16 ROADTYPE_TRAM = 1, |
|
17 ROADTYPE_HWAY = 2, ///< Only a placeholder. Not sure what we are going to do with this road type. |
|
18 ROADTYPE_END, |
|
19 INVALID_ROADTYPE = 0xFF |
|
20 }; |
|
21 DECLARE_POSTFIX_INCREMENT(RoadType); |
|
22 |
|
23 /** |
|
24 * The different roadtypes we support, but then a bitmask of them |
|
25 * @note currently only ROADTYPES_ROAD is supported. |
|
26 */ |
|
27 enum RoadTypes { |
|
28 ROADTYPES_NONE = 0, |
|
29 ROADTYPES_ROAD = 1 << ROADTYPE_ROAD, |
|
30 ROADTYPES_TRAM = 1 << ROADTYPE_TRAM, |
|
31 ROADTYPES_HWAY = 1 << ROADTYPE_HWAY, |
|
32 ROADTYPES_ROADTRAM = ROADTYPES_ROAD | ROADTYPES_TRAM, |
|
33 ROADTYPES_ROADHWAY = ROADTYPES_ROAD | ROADTYPES_HWAY, |
|
34 ROADTYPES_TRAMHWAY = ROADTYPES_TRAM | ROADTYPES_HWAY, |
|
35 ROADTYPES_ALL = ROADTYPES_ROAD | ROADTYPES_TRAM | ROADTYPES_HWAY, |
|
36 }; |
|
37 DECLARE_ENUM_AS_BIT_SET(RoadTypes); |
|
38 |
|
39 /** |
|
40 * Whether the given roadtype is valid. |
|
41 * @param rt the roadtype to check for validness |
|
42 * @return true if and only if valid |
|
43 */ |
|
44 static inline bool IsValidRoadType(RoadType rt) |
|
45 { |
|
46 return rt == ROADTYPE_ROAD; |
|
47 } |
|
48 |
|
49 /** |
|
50 * Are the given bits pointing to valid roadtypes? |
|
51 * @param rts the roadtypes to check for validness |
|
52 * @return true if and only if valid |
|
53 */ |
|
54 static inline bool AreValidRoadTypes(RoadTypes rts) |
|
55 { |
|
56 return rts == ROADTYPES_ROAD; |
|
57 } |
|
58 |
|
59 /** |
|
60 * Maps a RoadType to the corresponding RoadTypes value |
|
61 */ |
|
62 static inline RoadTypes RoadTypeToRoadTypes(RoadType rt) |
|
63 { |
|
64 return (RoadTypes)(1 << rt); |
|
65 } |
|
66 |
|
67 static inline RoadTypes ComplementRoadTypes(RoadTypes r) |
|
68 { |
|
69 return (RoadTypes)(ROADTYPES_ALL ^ r); |
|
70 } |
9 |
71 |
10 enum RoadBits { |
72 enum RoadBits { |
11 ROAD_NONE = 0U, |
73 ROAD_NONE = 0U, |
12 ROAD_NW = 1U, |
74 ROAD_NW = 1U, |
13 ROAD_SW = 2U, |
75 ROAD_SW = 2U, |
46 * Is it allowed to remove the given road bits from the given tile? |
108 * Is it allowed to remove the given road bits from the given tile? |
47 * @param tile the tile to remove the road from |
109 * @param tile the tile to remove the road from |
48 * @param remove the roadbits that are going to be removed |
110 * @param remove the roadbits that are going to be removed |
49 * @param owner the actual owner of the roadbits of the tile |
111 * @param owner the actual owner of the roadbits of the tile |
50 * @param edge_road are the removed bits from a town? |
112 * @param edge_road are the removed bits from a town? |
|
113 * @param rt the road type to remove the bits from |
51 * @return true when it is allowed to remove the road bits |
114 * @return true when it is allowed to remove the road bits |
52 */ |
115 */ |
53 bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road); |
116 bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt); |
54 |
117 |
55 #endif /* ROAD_H */ |
118 #endif /* ROAD_H */ |