Loading

Paste #pow6kkx9d

  1. /**
  2.  * Returns the owner of a tile
  3.  *
  4.  * This function returns the owner of a tile. This cannot used
  5.  * for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY
  6.  * as no company owned any of these buildings.
  7.  *
  8.  * @param tile The tile to check
  9.  * @return The owner of the tile
  10.  * @pre IsValidTile(tile)
  11.  * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
  12.  */
  13. static inline Owner GetTileOwner(TileIndex tile)
  14. {
  15.     assert(IsValidTile(tile));
  16.     assert(!IsTileType(tile, MP_HOUSE));
  17.     assert(!IsTileType(tile, MP_INDUSTRY));
  18.     if ((IsTileType(tile, MP_STATION) || IsTileType(tile, MP_WATER) || IsTileType(tile, MP_OBJECT))) {
  19.         Owner co = (Owner)GB(_m[tile].m1, 0, 4);
  20.         return co == OWNER_TOWN ? OWNER_NONE : co;
  21.        
  22.     } else {
  23.         return (Owner)GB(_m[tile].m1, 0, 5);
  24.     }
  25. }
  26.  
  27. /**
  28.  * Sets the owner of a tile
  29.  *
  30.  * This function sets the owner status of a tile. Note that you cannot
  31.  * set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY.
  32.  *
  33.  * @param tile The tile to change the owner status.
  34.  * @param owner The new owner.
  35.  * @pre IsValidTile(tile)
  36.  * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
  37.  */
  38. static inline void SetTileOwner(TileIndex tile, Owner owner)
  39. {
  40.     assert(IsValidTile(tile));
  41.     assert(!IsTileType(tile, MP_HOUSE));
  42.     assert(!IsTileType(tile, MP_INDUSTRY));
  43.     if ((IsTileType(tile, MP_STATION) || IsTileType(tile, MP_WATER) || IsTileType(tile, MP_OBJECT)) && owner == OWNER_TOWN) {
  44.         SB(_m[tile].m1, 0, 4, OWNER_TOWN);
  45.     } else {
  46.         SB(_m[tile].m1, 0, 5, owner);
  47.     }
  48. }

Comments