MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ClearTownHouse

Function ClearTownHouse

src/town_cmd.cpp:3050–3084  ·  view source on GitHub ↗

* Clear a town house. * @param t The town which owns the house. * @param tile The tile to clear. */

Source from the content-addressed store, hash-verified

3048 * @param tile The tile to clear.
3049 */
3050void 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).

Callers 4

NewHouseTileLoopFunction · 0.85
TileLoop_TownFunction · 0.85
ClearTile_TownFunction · 0.85
CmdPlaceHouseFunction · 0.85

Calls 12

IsTileTypeFunction · 0.85
GetHouseTypeFunction · 0.85
GetHouseNorthPartFunction · 0.85
IsHouseCompletedFunction · 0.85
ChangePopulationFunction · 0.85
DoClearTownHouseHelperFunction · 0.85
TileDiffXYFunction · 0.85
RemoveNearbyStationsFunction · 0.85
UpdateTownRadiusFunction · 0.85
TestMethod · 0.80
AnyMethod · 0.80
ResetMethod · 0.45

Tested by

no test coverage detected