Loading

Paste #pb3j5htid

  1. static inline void SetCanalOwner(TileIndex t, Owner o)
  2. {
  3.     assert(GetWaterClass(t) == WATER_CLASS_CANAL);
  4.     assert(o != OWNER_TOWN);
  5.     assert(o != OWNER_DEITY);
  6.  
  7.     /* OWNER_NONE (10) and OWNER_WATER (11) is stored as OWNER_TOWN (0F) */
  8.     if (o == OWNER_NONE) o = OWNER_TOWN;
  9.     SB(_me[t].m6, 0, 2, GB(o, 0, 2));
  10.     SB(_me[t].m6, 6, 2, GB(o, 2, 2));
  11. }
  12.  
  13. static inline Owner GetCanalOwner(TileIndex t)
  14. {
  15.     assert(HasTileWaterGround(t) && GetWaterClass(t) == WATER_CLASS_CANAL);
  16.  
  17.     Owner o = (Owner)(GB(_me[t].m6, 0, 2) | (GB(_me[t].m6, 6, 2) << 2));
  18.  
  19.     /* Canals don't need OWNER_TOWN, and remapping OWNER_NONE
  20.     * to OWNER_TOWN makes it use one bit less. */
  21.     return o == OWNER_TOWN ? OWNER_NONE : o;
  22. }

Comments