Loading

canal owner testing

  1. Index: src/water_map.h
  2. ===================================================================
  3. --- src/water_map.h (revision 27177)
  4. +++ src/water_map.h (working copy)
  5. @@ -346,8 +346,33 @@
  6.     return HasTileWaterClass(t) && IsTileOnWater(t) && !IsCoastTile(t);
  7.  }
  8.  
  9. +/**
  10. + * Comment about getting owner of canal
  11. + */
  12. +static inline Owner GetCanalOwner(TileIndex t)
  13. +{
  14. +   assert(HasTileWaterGround(t));
  15.  
  16. +   if (GetWaterClass(t) != WATER_CLASS_CANAL) {
  17. +       return GetTileOwner(t);
  18. +       } else {
  19. +       Owner co = (Owner)(GB(_me[t].m6, 0, 2) || GB(_me[t].m6, 6, 2));
  20. +       /* Canals don't have OWNER_TOWN, and remapping OWNER_NONE
  21. +       * to OWNER_TOWN makes it use one bit less */
  22. +       return co == OWNER_TOWN ? OWNER_NONE : co;
  23. +   }
  24. +}
  25.  /**
  26. + * Comment about setting owner of canal
  27. + */
  28. +static inline void SetCanalOwner(TileIndex t, Owner co)
  29. +{
  30. +   if (co == OWNER_NONE) co = OWNER_TOWN;
  31. +   SB(_me[t].m6, 0, 2, GB(co, 0, 2));
  32. +   SB(_me[t].m6, 6, 2, GB(co, 2, 2));
  33. +}
  34. +
  35. +/**
  36.   * Helper function to make a coast tile.
  37.   * @param t The tile to change into water
  38.   */
  39. @@ -412,6 +437,7 @@
  40.  static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
  41.  {
  42.     assert(o != OWNER_WATER);
  43. +   if (o == OWNER_NONE) o = OWNER_TOWN;
  44.     MakeWater(t, o, WATER_CLASS_CANAL, random_bits);
  45.  }

Comments