/**
* Returns the owner of a tile
*
* This function returns the owner of a tile. This cannot used
* for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY
* as no company owned any of these buildings.
*
* @param tile The tile to check
* @return The owner of the tile
* @pre IsValidTile(tile)
* @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
*/
static inline Owner GetTileOwner(TileIndex tile)
{
assert(IsValidTile(tile));
assert(!IsTileType(tile, MP_HOUSE));
assert(!IsTileType(tile, MP_INDUSTRY));
if ((IsTileType(tile, MP_STATION) || IsTileType(tile, MP_WATER) || IsTileType(tile, MP_OBJECT))) {
Owner co = (Owner)GB(_m[tile].m1, 0, 4);
return co == OWNER_TOWN ? OWNER_NONE : co;
} else {
return (Owner)GB(_m[tile].m1, 0, 5);
}
}
/**
* Sets the owner of a tile
*
* This function sets the owner status of a tile. Note that you cannot
* set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY.
*
* @param tile The tile to change the owner status.
* @param owner The new owner.
* @pre IsValidTile(tile)
* @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
*/
static inline void SetTileOwner(TileIndex tile, Owner owner)
{
assert(IsValidTile(tile));
assert(!IsTileType(tile, MP_HOUSE));
assert(!IsTileType(tile, MP_INDUSTRY));
if ((IsTileType(tile, MP_STATION) || IsTileType(tile, MP_WATER) || IsTileType(tile, MP_OBJECT)) && owner == OWNER_TOWN) {
SB(_m[tile].m1, 0, 4, OWNER_TOWN);
} else {
SB(_m[tile].m1, 0, 5, owner);
}
}