44 | /** Available water tile types. */
| 44 | /** Available water tile types. */ |
---|
45 | @@ -55,6 +56,12 @@
| | |
---|
46 | /** Helper information for extract tool. */
| | |
---|
47 | template <> struct EnumPropsT<WaterClass> : MakeEnumPropsT<WaterClass, byte, WATER_CLASS_SEA, WATER_CLASS_INVALID, WATER_CLASS_INVALID, 2> {};
| | |
---|
48 |
| | |
---|
49 | +/** Bases of a canal (for #WATER_CLASS_CANAL class of water). */
| | |
---|
50 | +enum CanalBase {
| | |
---|
51 | + WCC_WITHOUT_RIVER = 0, ///< Without a river under it
| | |
---|
52 | + WCC_WITH_RIVER = 1, ///< With a river under it
| | |
---|
53 | +};
| | |
---|
54 | +
| | |
---|
55 | /** Sections of the water depot. */
| | |
---|
56 | enum DepotPart {
| | |
---|
57 | DEPOT_PART_NORTH = 0, ///< Northern part of a depot.
| | |
---|
58 | @@ -121,6 +128,27 @@
| | |
---|
59 | SB(_m[t].m1, 5, 2, wc);
| | |
---|
60 | }
| | |
---|
61 |
| | |
---|
62 | +
| | |
---|
63 | +
| | |
---|
64 | +static inline CanalBase GetCanalBase(TileIndex t)
| | |
---|
65 | +{
| | |
---|
66 | + assert(HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL);
| | |
---|
67 | + return (CanalBase)HasBit(_me[t].m6, WBL_RIVER_FLAG) ? WCC_WITH_RIVER : WCC_WITHOUT_RIVER;
| | |
---|
68 | +}
| | |
---|
69 | +
| | |
---|
70 | +static inline bool HasTileCanalOnRiver(TileIndex t)
| | |
---|
71 | +{
| | |
---|
72 | + return HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL && GetCanalBase(t) == WCC_WITH_RIVER;
| | |
---|
73 | +}
| | |
---|
74 | +
| | |
---|
75 | +static inline void SetCanalOnRiver(TileIndex t)
| | |
---|
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.
| | |
---|
85 | * @param t the tile to check
| | |
---|
86 | @@ -165,6 +193,12 @@
| | |
---|
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. | | |
---|