Loading

Canal on River?

  1. /**
  2.  * Bit field layout of m5 for water tiles.
  3.  */
  4. enum WaterTileTypeBitLayout {
  5.     WBL_TYPE_BEGIN        = 4,   ///< Start of the 'type' bitfield.
  6.     WBL_TYPE_COUNT        = 4,   ///< Length of the 'type' bitfield.
  7.  
  8.     WBL_TYPE_NORMAL       = 0x0, ///< Clear water or coast ('type' bitfield).
  9.     WBL_TYPE_LOCK         = 0x1, ///< Lock ('type' bitfield).
  10.     WBL_TYPE_DEPOT        = 0x8, ///< Depot ('type' bitfield).
  11.  
  12.     WBL_COAST_FLAG        = 0,   ///< Flag for coast.
  13.     WBL_RIVER_FLAG        = 0,   ///< Flag for canal on river.
  14.  
  15.     WBL_LOCK_ORIENT_BEGIN = 0,   ///< Start of lock orientiation bitfield.
  16.     WBL_LOCK_ORIENT_COUNT = 2,   ///< Length of lock orientiation bitfield.
  17.     WBL_LOCK_PART_BEGIN   = 2,   ///< Start of lock part bitfield.
  18.     WBL_LOCK_PART_COUNT   = 2,   ///< Length of lock part bitfield.
  19.  
  20.     WBL_DEPOT_PART        = 0,   ///< Depot part flag.
  21.     WBL_DEPOT_AXIS        = 1,   ///< Depot axis flag.
  22. };
  23.  
  24. ......
  25.  
  26. enum CanalType {
  27.     CANAL_NOT_RIVER = 0,    ///<
  28.     CANAL_AND_RIVER = 1,    ///<
  29. };
  30.  
  31.  
  32. .....
  33.  
  34. static inline CanalType GetCanalType(TileIndex t)
  35. {
  36.     assert(HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL);
  37.     return (CanalType)HasBit(_me[t].m6, WBL_RIVER_FLAG) ? CANAL_AND_RIVER : CANAL_NOT_RIVER;
  38. }
  39.  
  40. static inline bool HasTileCanalOnRiver(TileIndex t)
  41. {
  42.     return HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL && GetCanalType(t) == CANAL_AND_RIVER;
  43. }
  44.  
  45. static inline void SetCanalOnRiver(TileIndex t)
  46. {
  47.     assert(HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL);
  48.     SB(_me[t].m6, 0, WBL_RIVER_FLAG, CANAL_AND_RIVER);
  49. }

Comments