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

Function ClearTile_Industry

src/industry_cmd.cpp:489–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

487}
488
489static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlags flags)
490{
491 Industry *i = Industry::GetByTile(tile);
492 const IndustrySpec *indspec = GetIndustrySpec(i->type);
493
494 /* water can destroy industries
495 * in editor you can bulldoze industries
496 * with magic_bulldozer cheat you can destroy industries
497 * (area around OILRIG is water, so water shouldn't flood it
498 */
499 if ((_current_company != OWNER_WATER && _game_mode != GM_EDITOR &&
500 !_cheats.magic_bulldozer.value) ||
501 flags.Test(DoCommandFlag::Auto) ||
502 (_current_company == OWNER_WATER &&
503 (indspec->behaviour.Test(IndustryBehaviour::BuiltOnWater) ||
504 HasBit(GetIndustryTileSpec(GetIndustryGfx(tile))->slopes_refused, 5)))) {
505
506 if (flags.Test(DoCommandFlag::Auto)) {
507 return CommandCostWithParam(STR_ERROR_GENERIC_OBJECT_IN_THE_WAY, indspec->name);
508 }
509 return CommandCost(INVALID_STRING_ID);
510 }
511
512 if (flags.Test(DoCommandFlag::Execute)) {
513 AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index));
514 Game::NewEvent(new ScriptEventIndustryClose(i->index));
515 delete i;
516 }
517 return CommandCost(EXPENSES_CONSTRUCTION, indspec->GetRemovalCost());
518}
519
520/**
521 * Move produced cargo from industry to nearby stations.

Callers

nothing calls this directly

Calls 8

GetIndustrySpecFunction · 0.85
HasBitFunction · 0.85
GetIndustryTileSpecFunction · 0.85
GetIndustryGfxFunction · 0.85
CommandCostClass · 0.85
TestMethod · 0.80
CommandCostWithParamFunction · 0.70
GetRemovalCostMethod · 0.45

Tested by

no test coverage detected