* Callback function to clear a house tile. * @param tile The tile to clear. * @param flags Type of operation. * @return The cost of this operation or an error. */
| 715 | * @return The cost of this operation or an error. |
| 716 | */ |
| 717 | static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlags flags) |
| 718 | { |
| 719 | if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED); |
| 720 | if (!CanDeleteHouse(tile)) return CommandCost(STR_ERROR_BUILDING_IS_PROTECTED); |
| 721 | |
| 722 | const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile)); |
| 723 | |
| 724 | CommandCost cost(EXPENSES_CONSTRUCTION); |
| 725 | cost.AddCost(hs->GetRemovalCost()); |
| 726 | |
| 727 | int rating = hs->remove_rating_decrease; |
| 728 | Town *t = Town::GetByTile(tile); |
| 729 | |
| 730 | if (Company::IsValidID(_current_company)) { |
| 731 | if (!_cheats.magic_bulldozer.value && !flags.Test(DoCommandFlag::NoTestTownRating)) { |
| 732 | /* NewGRFs can add indestructible houses. */ |
| 733 | if (rating > RATING_MAXIMUM) { |
| 734 | return CommandCost(STR_ERROR_BUILDING_IS_PROTECTED); |
| 735 | } |
| 736 | /* If town authority controls removal, check the company's rating. */ |
| 737 | if (rating > t->ratings[_current_company] && _settings_game.difficulty.town_council_tolerance != TOWN_COUNCIL_PERMISSIVE) { |
| 738 | return CommandCostWithParam(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS, t->index); |
| 739 | } |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM, flags); |
| 744 | if (flags.Test(DoCommandFlag::Execute)) { |
| 745 | ClearTownHouse(t, tile); |
| 746 | } |
| 747 | |
| 748 | return cost; |
| 749 | } |
| 750 | |
| 751 | static void AddProducedCargo_Town(TileIndex tile, CargoArray &produced) |
| 752 | { |
nothing calls this directly
no test coverage detected