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

Function TerraformTile_Town

src/town_cmd.cpp:4154–4180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4152});
4153
4154static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
4155{
4156 if (AutoslopeEnabled()) {
4157 HouseID house = GetHouseType(tile);
4158 GetHouseNorthPart(house); // modifies house to the ID of the north tile
4159 const HouseSpec *hs = HouseSpec::Get(house);
4160
4161 /* Here we differ from TTDP by checking BuildingFlag::NotSloped */
4162 if (!hs->building_flags.Test(BuildingFlag::NotSloped) && !IsSteepSlope(tileh_new) &&
4163 (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) {
4164 bool allow_terraform = true;
4165
4166 /* Call the autosloping callback per tile, not for the whole building at once. */
4167 house = GetHouseType(tile);
4168 hs = HouseSpec::Get(house);
4169 if (hs->callback_mask.Test(HouseCallbackMask::Autoslope)) {
4170 /* If the callback fails, allow autoslope. */
4171 uint16_t res = GetHouseCallback(CBID_HOUSE_AUTOSLOPE, 0, 0, house, Town::GetByTile(tile), tile);
4172 if (res != CALLBACK_FAILED && ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_AUTOSLOPE, res)) allow_terraform = false;
4173 }
4174
4175 if (allow_terraform) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
4176 }
4177 }
4178
4179 return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
4180}
4181
4182/** Tile callback functions for a town */
4183extern const TileTypeProcs _tile_type_town_procs = {

Callers

nothing calls this directly

Calls 10

AutoslopeEnabledFunction · 0.85
GetHouseTypeFunction · 0.85
GetHouseNorthPartFunction · 0.85
IsSteepSlopeFunction · 0.85
GetTileMaxZFunction · 0.85
GetSlopeMaxZFunction · 0.85
GetHouseCallbackFunction · 0.85
ConvertBooleanCallbackFunction · 0.85
CommandCostClass · 0.85
TestMethod · 0.80

Tested by

no test coverage detected