* Clear a town house. * @param t The town which owns the house. * @param tile The tile to clear. */
| 3048 | * @param tile The tile to clear. |
| 3049 | */ |
| 3050 | void ClearTownHouse(Town *t, TileIndex tile) |
| 3051 | { |
| 3052 | assert(IsTileType(tile, MP_HOUSE)); |
| 3053 | |
| 3054 | HouseID house = GetHouseType(tile); |
| 3055 | |
| 3056 | /* The northernmost tile of the house is the main house. */ |
| 3057 | tile += GetHouseNorthPart(house); |
| 3058 | |
| 3059 | const HouseSpec *hs = HouseSpec::Get(house); |
| 3060 | |
| 3061 | /* Remove population from the town if the house is finished. */ |
| 3062 | if (IsHouseCompleted(tile)) { |
| 3063 | ChangePopulation(t, -hs->population); |
| 3064 | } |
| 3065 | |
| 3066 | t->cache.num_houses--; |
| 3067 | |
| 3068 | /* Clear flags for houses that only may exist once/town. */ |
| 3069 | if (hs->building_flags.Test(BuildingFlag::IsChurch)) { |
| 3070 | t->flags.Reset(TownFlag::HasChurch); |
| 3071 | } else if (hs->building_flags.Test(BuildingFlag::IsStadium)) { |
| 3072 | t->flags.Reset(TownFlag::HasStadium); |
| 3073 | } |
| 3074 | |
| 3075 | /* Do the actual clearing of tiles */ |
| 3076 | DoClearTownHouseHelper(tile, t, house); |
| 3077 | if (hs->building_flags.Any(BUILDING_2_TILES_Y)) DoClearTownHouseHelper(tile + TileDiffXY(0, 1), t, ++house); |
| 3078 | if (hs->building_flags.Any(BUILDING_2_TILES_X)) DoClearTownHouseHelper(tile + TileDiffXY(1, 0), t, ++house); |
| 3079 | if (hs->building_flags.Any(BUILDING_HAS_4_TILES)) DoClearTownHouseHelper(tile + TileDiffXY(1, 1), t, ++house); |
| 3080 | |
| 3081 | RemoveNearbyStations(t, tile, hs->building_flags); |
| 3082 | |
| 3083 | UpdateTownRadius(t); |
| 3084 | } |
| 3085 | |
| 3086 | /** |
| 3087 | * Rename a town (server-only). |
no test coverage detected