Old revision #ptzeplxmx | New revision #p7c0fpuuh | ||
---|---|---|---|
24 | 24 | ||
25 | - WBL_COAST_FLAG = 0, ///< Flag for coast. | 25 | - WBL_COAST_FLAG = 0, ///< Flag for coast. |
26 | + WBL_COAST_FLAG = 0, ///< Flag for coast, in m5. | 26 | + WBL_COAST_FLAG = 0, ///< Flag for coast, in m5. |
27 | + WBL_RIVER_FLAG | 27 | + WBL_RIVER_FLAG = 0, ///< Flag for canal on river, in m6. |
28 | 28 | ||
29 | - WBL_LOCK_ORIENT_BEGIN = 0, ///< Start of lock orientiation bitfield. | 29 | - WBL_LOCK_ORIENT_BEGIN = 0, ///< Start of lock orientiation bitfield. |
30 | - WBL_LOCK_ORIENT_COUNT = 2, ///< Length of lock orientiation bitfield. | 30 | - WBL_LOCK_ORIENT_COUNT = 2, ///< Length of lock orientiation bitfield. | … | … |
48 | 48 | ||
49 | +/** Bases of a canal (for #WATER_CLASS_CANAL class of water). */ | 49 | +/** Bases of a canal (for #WATER_CLASS_CANAL class of water). */ |
50 | +enum CanalBase { | 50 | +enum CanalBase { |
51 | + WCC_WITHOUT_RIVER | 51 | + WCC_WITHOUT_RIVER = 0, ///< Without a river under it |
52 | + WCC_WITH_RIVER | 52 | + WCC_WITH_RIVER = 1, ///< With a river under it |
53 | +}; | 53 | +}; |
54 | + | 54 | + |
55 | /** Sections of the water depot. */ | 55 | /** Sections of the water depot. */ |
56 | enum DepotPart { | 56 | enum DepotPart { |
57 | DEPOT_PART_NORTH = 0, ///< Northern part of a depot. | 57 | DEPOT_PART_NORTH = 0, ///< Northern part of a depot. |
58 | @@ -121,6 +128,27 @@ | 58 | @@ -122,6 +129,40 @@ |
59 | SB(_m[t].m1, 5, 2, wc); | ||
60 | } | 59 | } |
61 | 60 | ||
62 | + | 61 | /** |
63 | + | 62 | + * Get the base of the canal at a tile. |
63 | + * @param t Water tile to query. | ||
64 | + * @pre GetWaterClass(t) == WATER_CLASS_CANAL | ||
65 | + * @return Base of the canal at the tile. | ||
66 | + */ | ||
64 | +static inline CanalBase GetCanalBase(TileIndex t) | 67 | +static inline CanalBase GetCanalBase(TileIndex t) |
65 | +{ | 68 | +{ |
66 | + assert( | 66 | + assert(GetWaterClass(t) == WATER_CLASS_CANAL); |
67 | + return (CanalBase)HasBit(_me[t].m6, WBL_RIVER_FLAG) ? WCC_WITH_RIVER : WCC_WITHOUT_RIVER; | 70 | + return (CanalBase)HasBit(_me[t].m6, WBL_RIVER_FLAG) ? WCC_WITH_RIVER : WCC_WITHOUT_RIVER; |
68 | +} | 71 | +} |
69 | + | 72 | + |
73 | +/** | ||
74 | + * Set the base of the canal to indicate there is a river under a tile. | ||
75 | + * @param t Water tile of water class canal to query. | ||
76 | + * @pre GetWaterClass(t) == WATER_CLASS_CANAL | ||
77 | + */ | ||
78 | +static inline void SetCanalOnRiver(TileIndex t) | ||
79 | +{ | ||
80 | + assert(GetWaterClass(t) == WATER_CLASS_CANAL); | ||
81 | + SB(_me[t].m6, 0, WBL_RIVER_FLAG, WCC_WITH_RIVER); | ||
82 | +} | ||
83 | + | ||
84 | +/** | ||
85 | + * Checks whether the canal at a tile has a river under it. | ||
86 | + * @param t Water tile of water class canal to query. | ||
87 | + * @pre GetWaterClass(t) == WATER_CLASS_CANAL | ||
88 | + * @return true if the canal has a river under it. | ||
89 | + */ | ||
70 | +static inline bool HasTileCanalOnRiver(TileIndex t) | 90 | +static inline bool HasTileCanalOnRiver(TileIndex t) |
71 | +{ | 91 | +{ |
72 | + return HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL && GetCanalBase(t) == WCC_WITH_RIVER; | 92 | + return HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL && GetCanalBase(t) == WCC_WITH_RIVER; |
73 | +} | 93 | +} |
74 | + | 94 | + |
75 | +static inline void SetCanalOnRiver(TileIndex t) | 75 | +/** |
76 | +{ | ||
77 | + assert(HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL); | ||
78 | + SB(_me[t].m6, 0, WBL_RIVER_FLAG, WCC_WITH_RIVER); | ||
79 | +} | ||
80 | + | ||
81 | + | ||
82 | + | ||
83 | /** | ||
84 | * Tests if the tile was built on water. | 96 | * Tests if the tile was built on water. |
85 | * @param t the tile to check | 97 | * @param t the tile to check |
86 | @@ -165,6 +193,12 @@ | 86 | * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT) |
87 | return IsWater(t) && GetWaterClass(t) == WATER_CLASS_CANAL; | ||
88 | } | ||
89 | |||
90 | +static inline bool IsCanalOnRiver(TileIndex t) | ||
91 | +{ | ||
92 | + assert(IsCanal(t)); | ||
93 | + return HasBit(_me[t].m6, WBL_RIVER_FLAG); | ||
94 | +} | ||
95 | + | ||
96 | /** | ||
97 | * Is it a river water tile? | ||
98 | * @param t Water tile to query. |