/**
* Bit field layout of m5 for water tiles.
*/
enum WaterTileTypeBitLayout {
WBL_TYPE_BEGIN = 4, ///< Start of the 'type' bitfield.
WBL_TYPE_COUNT = 4, ///< Length of the 'type' bitfield.
WBL_TYPE_NORMAL = 0x0, ///< Clear water or coast ('type' bitfield).
WBL_TYPE_LOCK = 0x1, ///< Lock ('type' bitfield).
WBL_TYPE_DEPOT = 0x8, ///< Depot ('type' bitfield).
WBL_COAST_FLAG = 0, ///< Flag for coast.
WBL_RIVER_FLAG = 0, ///< Flag for canal on river.
WBL_LOCK_ORIENT_BEGIN = 0, ///< Start of lock orientiation bitfield.
WBL_LOCK_ORIENT_COUNT = 2, ///< Length of lock orientiation bitfield.
WBL_LOCK_PART_BEGIN = 2, ///< Start of lock part bitfield.
WBL_LOCK_PART_COUNT = 2, ///< Length of lock part bitfield.
WBL_DEPOT_PART = 0, ///< Depot part flag.
WBL_DEPOT_AXIS = 1, ///< Depot axis flag.
};
......
enum CanalType {
CANAL_NOT_RIVER = 0, ///<
CANAL_AND_RIVER = 1, ///<
};
.....
static inline CanalType GetCanalType(TileIndex t)
{
assert(HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL);
return (CanalType)HasBit(_me[t].m6, WBL_RIVER_FLAG) ? CANAL_AND_RIVER : CANAL_NOT_RIVER;
}
static inline bool HasTileCanalOnRiver(TileIndex t)
{
return HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL && GetCanalType(t) == CANAL_AND_RIVER;
}
static inline void SetCanalOnRiver(TileIndex t)
{
assert(HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL);
SB(_me[t].m6, 0, WBL_RIVER_FLAG, CANAL_AND_RIVER);
}