OpenTTD Source: src/industry_cmd.cpp File Reference

OpenTTD Source 15.0-RC2

Data Structures | Typedefs | Functions | Variables
industry_cmd.cpp File Reference

Handling of industry tiles. More...

`#include "stdafx.h"`
`#include "misc/history_type.hpp"`
`#include "misc/history_func.hpp"`
`#include "clear_map.h"`
`#include "industry.h"`
`#include "station_base.h"`
`#include "landscape.h"`
`#include "viewport_func.h"`
`#include "command_func.h"`
`#include "town.h"`
`#include "news_func.h"`
`#include "cheat_type.h"`
`#include "company_base.h"`
`#include "genworld.h"`
`#include "tree_map.h"`
`#include "newgrf_cargo.h"`
`#include "newgrf_debug.h"`
`#include "newgrf_industrytiles.h"`
`#include "autoslope.h"`
`#include "water.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "vehicle_func.h"`
`#include "sound_func.h"`
`#include "animated_tile_func.h"`
`#include "effectvehicle_func.h"`
`#include "effectvehicle_base.h"`
`#include "ai/ai.hpp"`
`#include "core/pool_func.hpp"`
`#include "subsidy_func.h"`
`#include "core/backup_type.hpp"`
`#include "object_base.h"`
`#include "game/game.hpp"`
`#include "error.h"`
`#include "string_func.h"`
`#include "industry_cmd.h"`
`#include "landscape_cmd.h"`
`#include "terraform_cmd.h"`
`#include "map_func.h"`
`#include "timer/timer.h"`
`#include "timer/timer_game_calendar.h"`
`#include "timer/timer_game_economy.h"`
`#include "timer/timer_game_tick.h"`
`#include "table/strings.h"`
`#include "table/industry_land.h"`
`#include "table/build_industry.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | IndustryGenerationProbabilities

## Typedefs
typedef void | IndustryDrawTileProc(const TileInfo *ti)
typedef CommandCost | CheckNewIndustryProc(TileIndex tile)
| Industrytype check function signature.

## Functions
void | ShowIndustryViewWindow (IndustryID industry)
void | BuildOilRig (TileIndex tile)
static int | WhoCanServiceIndustry (Industry *ind)
| Compute who can service the industry.
void | ResetIndustries ()
| This function initialize the spec arrays of both industry and industry tiles.
IndustryType | GetIndustryType (Tile tile)
| Retrieve the type for this industry.
const IndustrySpec * | GetIndustrySpec (IndustryType thistype)
| Accessor for array _industry_specs.
const IndustryTileSpec * | GetIndustryTileSpec (IndustryGfx gfx)
| Accessor for array _industry_tile_specs.
static void | IndustryDrawSugarMine (const TileInfo *ti)
static void | IndustryDrawToffeeQuarry (const TileInfo *ti)
static void | IndustryDrawBubbleGenerator (const TileInfo *ti)
static void | IndustryDrawToyFactory (const TileInfo *ti)
static void | IndustryDrawCoalPlantSparks (const TileInfo *ti)
static void | DrawTile_Industry (TileInfo *ti)
static int | GetSlopePixelZ_Industry (TileIndex tile, uint, uint, bool)
static Foundation | GetFoundation_Industry (TileIndex tile, Slope tileh)
static void | AddAcceptedCargo_Industry (TileIndex tile, CargoArray &acceptance, CargoTypes &always_accepted)
static void | GetTileDesc_Industry (TileIndex tile, TileDesc &td)
static CommandCost | ClearTile_Industry (TileIndex tile, DoCommandFlags flags)
static bool | TransportIndustryGoods (TileIndex tile)
| Move produced cargo from industry to nearby stations.
static void | AnimateSugarSieve (TileIndex tile)
static void | AnimateToffeeQuarry (TileIndex tile)
static void | AnimateBubbleCatcher (TileIndex tile)
static void | AnimatePowerPlantSparks (TileIndex tile)
static void | AnimateToyFactory (TileIndex tile)
static void | AnimatePlasticFountain (TileIndex tile, IndustryGfx gfx)
static void | AnimateOilWell (TileIndex tile, IndustryGfx gfx)
static void | AnimateMineTower (TileIndex tile)
static void | AnimateTile_Industry (TileIndex tile)
static void | CreateChimneySmoke (TileIndex tile)
static void | MakeIndustryTileBigger (TileIndex tile)
static void | TileLoopIndustry_BubbleGenerator (TileIndex tile)
static void | TileLoop_Industry (TileIndex tile)
static bool | ClickTile_Industry (TileIndex tile)
static TrackStatus | GetTileTrackStatus_Industry (TileIndex, TransportType, uint, DiagDirection)
static void | ChangeTileOwner_Industry (TileIndex tile, Owner old_owner, Owner new_owner)
bool | IsTileForestIndustry (TileIndex tile)
| Check whether the tile is a forest.
static bool | IsSuitableForFarmField (TileIndex tile, bool allow_fields, bool allow_rough)
| Check whether the tile can be replaced by a farm field.
static void | SetupFarmFieldFence (TileIndex tile, int size, uint8_t type, DiagDirection side)
| Build farm field fence.
static void | PlantFarmField (TileIndex tile, IndustryID industry)
void | PlantRandomFarmField (const Industry *i)
static void | ChopLumberMillTrees (Industry *i)
| Perform a circular search around the Lumber Mill in order to find trees to cut.
static void | ProduceIndustryGoodsHelper (Industry *i, bool scale)
| Helper for ProduceIndustryGoods that scales and produces cargos.
static void | ProduceIndustryGoods (Industry *i)
void | OnTick_Industry ()
static CommandCost | CheckNewIndustry_NULL (TileIndex)
| Check the conditions of CHECK_NOTHING (Always succeeds).
static CommandCost | CheckNewIndustry_Forest (TileIndex tile)
| Check the conditions of CHECK_FOREST (Industry should be build above snow-line in arctic climate).
static bool | CheckScaledDistanceFromEdge (TileIndex tile, uint maxdist)
| Check if a tile is within a distance from map edges, scaled by map dimensions independently.
static CommandCost | CheckNewIndustry_OilRefinery (TileIndex tile)
| Check the conditions of CHECK_REFINERY (Industry should be positioned near edge of the map).
static CommandCost | CheckNewIndustry_OilRig (TileIndex tile)
| Check the conditions of CHECK_OIL_RIG (Industries at sea should be positioned near edge of the map).
static CommandCost | CheckNewIndustry_Farm (TileIndex tile)
| Check the conditions of CHECK_FARM (Industry should be below snow-line in arctic).
static CommandCost | CheckNewIndustry_Plantation (TileIndex tile)
| Check the conditions of CHECK_PLANTATION (Industry should NOT be in the desert).
static CommandCost | CheckNewIndustry_Water (TileIndex tile)
| Check the conditions of CHECK_WATER (Industry should be in the desert).
static CommandCost | CheckNewIndustry_Lumbermill (TileIndex tile)
| Check the conditions of CHECK_LUMBERMILL (Industry should be in the rainforest).
static CommandCost | CheckNewIndustry_BubbleGen (TileIndex tile)
| Check the conditions of CHECK_BUBBLEGEN (Industry should be in low land).
static CommandCost | FindTownForIndustry (TileIndex tile, IndustryType type, Town **t)
| Find a town for the industry, while checking for multiple industries in the same town.
bool | IsSlopeRefused (Slope current, Slope refused)
static CommandCost | CheckIfIndustryTilesAreFree (TileIndex tile, const IndustryTileLayout &layout, IndustryType type)
| Are the tiles of the industry free?
static CommandCost | CheckIfIndustryTileSlopes (TileIndex tile, const IndustryTileLayout &layout, size_t layout_index, IndustryType type, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type, bool *custom_shape_check=nullptr)
| Check slope requirements for industry tiles.
static CommandCost | CheckIfIndustryIsAllowed (TileIndex tile, IndustryType type, const Town *t)
| Is the industry allowed to be built at this place for the town?
static bool | CheckCanTerraformSurroundingTiles (TileIndex tile, uint height, int internal)
static bool | CheckIfCanLevelIndustryPlatform (TileIndex tile, DoCommandFlags flags, const IndustryTileLayout &layout)
| This function tries to flatten out the land below an industry, without damaging the surroundings too much.
static CommandCost | CheckIfFarEnoughFromConflictingIndustry (TileIndex tile, IndustryType type)
| Check that the new industry is far enough from conflicting industries.
static void | AdvertiseIndustryOpening (const Industry *ind)
| Advertise about a new industry opening.
static void | PopulateStationsNearby (Industry *ind)
| Populate an industry's list of nearby stations, and if it accepts any cargo, also add the industry to each station's nearby industry list.
static void | DoCreateNewIndustry (Industry *i, TileIndex tile, IndustryType type, const IndustryTileLayout &layout, size_t layout_index, Town *t, Owner founder, uint16_t initial_random_bits)
| Put an industry on the map.
static CommandCost | CreateNewIndustryHelper (TileIndex tile, IndustryType type, DoCommandFlags flags, const IndustrySpec *indspec, size_t layout_index, uint32_t random_var8f, uint16_t random_initial_bits, Owner founder, IndustryAvailabilityCallType creation_type, Industry **ip)
| Helper function for Build/Fund an industry.
CommandCost | CmdBuildIndustry (DoCommandFlags flags, TileIndex tile, IndustryType it, uint32_t first_layout, bool fund, uint32_t seed)
| Build/Fund an industry.
CommandCost | CmdIndustrySetFlags (DoCommandFlags flags, IndustryID ind_id, IndustryControlFlags ctlflags)
| Set industry control flags.
CommandCost | CmdIndustrySetProduction (DoCommandFlags flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const EncodedString &custom_news)
| Set industry production.
CommandCost | CmdIndustrySetExclusivity (DoCommandFlags flags, IndustryID ind_id, Owner company_id, bool consumer)
| Change exclusive consumer or supplier for the industry.
CommandCost | CmdIndustrySetText (DoCommandFlags flags, IndustryID ind_id, const EncodedString &text)
| Change additional industry text.
static Industry * | CreateNewIndustry (TileIndex tile, IndustryType type, IndustryAvailabilityCallType creation_type)
| Create a new industry of random layout.
static uint32_t | GetScaledIndustryGenerationProbability (IndustryType it, std::optional< bool > water, bool *force_at_least_one)
| Compute the appearance probability for an industry during map creation.
static uint16_t | GetIndustryGamePlayProbability (IndustryType it, uint8_t *min_number)
| Compute the probability for constructing a new industry during game play.
static uint | GetNumberOfIndustries ()
| Get wanted number of industries on the map.
static Industry * | PlaceIndustry (IndustryType type, IndustryAvailabilityCallType creation_type, bool try_hard)
| Try to place the industry in the game.
static void | PlaceInitialIndustry (IndustryType type, bool water, bool try_hard)
| Try to build a industry on the map.
static uint | GetCurrentTotalNumberOfIndustries ()
| Get total number of industries existing in the game.
static IndustryGenerationProbabilities | GetScaledProbabilities (bool water)
| Get scaled industry generation probabilities.
void | GenerateIndustries ()
| This function will create random industries during game creation.
template<>
Industry::ProducedHistory | SumHistory (std::span< const Industry::ProducedHistory > history)
template<>
Industry::AcceptedHistory | SumHistory (std::span< const Industry::AcceptedHistory > history)
static void | UpdateIndustryStatistics (Industry *i)
| Monthly update of industry statistics.
void | ClearAllIndustryCachedNames ()
static bool | CheckIndustryCloseDownProtection (IndustryType type)
| Protects an industry from closure if the appropriate flags and conditions are met CanCloseLastInstance must be set (which, by default, it is not) and the count of industries of this type must one (or lower) in order to be protected against closure.
static void | CanCargoServiceIndustry (CargoType cargo, Industry *ind, bool *c_accepts, bool *c_produces)
| Can given cargo type be accepted or produced by the industry?
static void | ReportNewsProductionChangeIndustry (Industry *ind, CargoType cargo, int percent)
| Report news that industry production has changed significantly.
static void | ChangeIndustryProduction (Industry *i, bool monthly)
| Change industry production or do closure.
void | InitializeIndustries ()
void | CheckIndustries ()
| Verify whether the generated industries are complete, and warn the user if not.
static CommandCost | TerraformTile_Industry (TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
void | TrimIndustryAcceptedProduced (Industry *ind)
| Remove unused industry accepted/produced slots – entries after the last slot with valid cargo.

## Variables
IndustryPool | _industry_pool ("Industry")
static uint8_t | _industry_sound_ctr
static TileIndex | _industry_sound_tile
IndustrySpec | _industry_specs [NUM_INDUSTRYTYPES]
IndustryTileSpec | _industry_tile_specs [NUM_INDUSTRYTILES]
IndustryBuildData | _industry_builder
| In-game manager of industries.
static IndustryDrawTileProc *const | _industry_draw_tile_procs [5]
static const uint8_t | _plantfarmfield_type [] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6}
bool | _ignore_industry_restrictions
static CheckNewIndustryProc *const | _check_new_industry_procs [CHECK_END]
| Check functions for different types of industry.
static const uint | PERCENT_TRANSPORTED_60 = 153
static const uint | PERCENT_TRANSPORTED_80 = 204
static const IntervalTimer< TimerGameEconomy > | _economy_industries_daily ({TimerGameEconomy::DAY, TimerGameEconomy::Priority::INDUSTRY}, [](auto) { _economy.industry_daily_change_counter+=_economy.industry_daily_increment;uint16_t change_loop=_economy.industry_daily_change_counter > > 16;_economy.industry_daily_change_counter &=0xFFFF;if(change_loop==0) { return;} Backup< CompanyID > cur_company(_current_company, OWNER_NONE);uint perc=3;if((_industry_builder.wanted_inds > > 16) > GetCurrentTotalNumberOfIndustries()) { perc=std::min(9u, perc+(_industry_builder.wanted_inds > > 16) - GetCurrentTotalNumberOfIndustries());} for(uint16_t j=0;j< change_loop;j++) { if(Chance16(perc, 100)) { _industry_builder.TryBuildNewIndustry();} else { Industry *i=Industry::GetRandom();if(i !=nullptr) { ChangeIndustryProduction(i, false);SetWindowDirty(WC_INDUSTRY_VIEW, i->index);} } } cur_company.Restore();InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE);})
| Every economy day handler for the industry changes Taking the original map size of 256*256, the number of random changes was always of just one unit.
static const IntervalTimer< TimerGameEconomy > | _economy_industries_monthly ({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::INDUSTRY}, [](auto) { Backup< CompanyID > cur_company(_current_company, OWNER_NONE);_industry_builder.EconomyMonthlyLoop();for(Industry *i :Industry::Iterate()) { UpdateIndustryStatistics(i);if(i->prod_level==PRODLEVEL_CLOSURE) { delete i;} else { ChangeIndustryProduction(i, true);SetWindowDirty(WC_INDUSTRY_VIEW, i->index);} } cur_company.Restore();InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE);})
const TileTypeProcs | _tile_type_industry_procs

## Detailed Description

Handling of industry tiles.

Definition in file industry_cmd.cpp.

## Typedef Documentation

## ◆ CheckNewIndustryProc

typedef CommandCost CheckNewIndustryProc(TileIndex tile)

Industrytype check function signature.

Parameters

  tile | Tile to check.

Returns
  Succeeded or failed command.

Definition at line 1407 of file industry_cmd.cpp.

## ◆ IndustryDrawTileProc

typedef void IndustryDrawTileProc(const TileInfo *ti)

Definition at line 320 of file industry_cmd.cpp.

## Function Documentation

## ◆ AddAcceptedCargo_Industry()

static void AddAcceptedCargo_Industry | ( | TileIndex | tile,
|  | CargoArray & | acceptance,
|  | CargoTypes & | always_accepted
| ) |  |
| static

Definition at line 412 of file industry_cmd.cpp.

## ◆ AdvertiseIndustryOpening()

static void AdvertiseIndustryOpening | ( | const Industry * | ind | ) |
| static

Advertise about a new industry opening.

Parameters

  ind | Industry being opened.

Definition at line 1714 of file industry_cmd.cpp.

References AI::BroadcastNewEvent(), GetEncodedString(), GetIndustrySpec(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, IndustryOpen, IndustrySpec::name, IndustrySpec::new_industry_text, Game::NewEvent(), Industry::town, and Industry::type.

Referenced by CmdBuildIndustry(), and IndustryBuildData::TryBuildNewIndustry().

## ◆ AnimateBubbleCatcher()

static void AnimateBubbleCatcher | ( | TileIndex | tile | ) |
| static

Definition at line 588 of file industry_cmd.cpp.

## ◆ AnimateMineTower()

static void AnimateMineTower | ( | TileIndex | tile | ) |
| static

Definition at line 659 of file industry_cmd.cpp.

## ◆ AnimateOilWell()

static void AnimateOilWell | ( | TileIndex | tile,
|  | IndustryGfx | gfx
| ) |  |
| static

Definition at line 644 of file industry_cmd.cpp.

## ◆ AnimatePlasticFountain()

static void AnimatePlasticFountain | ( | TileIndex | tile,
|  | IndustryGfx | gfx
| ) |  |
| static

Definition at line 637 of file industry_cmd.cpp.

## ◆ AnimatePowerPlantSparks()

static void AnimatePowerPlantSparks | ( | TileIndex | tile | ) |
| static

Definition at line 601 of file industry_cmd.cpp.

## ◆ AnimateSugarSieve()

static void AnimateSugarSieve | ( | TileIndex | tile | ) |
| static

Definition at line 551 of file industry_cmd.cpp.

## ◆ AnimateTile_Industry()

static void AnimateTile_Industry | ( | TileIndex | tile | ) |
| static

Definition at line 691 of file industry_cmd.cpp.

## ◆ AnimateToffeeQuarry()

static void AnimateToffeeQuarry | ( | TileIndex | tile | ) |
| static

Definition at line 571 of file industry_cmd.cpp.

## ◆ AnimateToyFactory()

static void AnimateToyFactory | ( | TileIndex | tile | ) |
| static

Definition at line 613 of file industry_cmd.cpp.

## ◆ BuildOilRig()

void BuildOilRig | ( | TileIndex | tile | ) |

Definition at line 4696 of file station_cmd.cpp.

## ◆ CanCargoServiceIndustry()

static void CanCargoServiceIndustry | ( | CargoType | cargo,
|  | Industry * | ind,
|  | bool * | c_accepts,
|  | bool * | c_produces
| ) |  |
| static

Can given cargo type be accepted or produced by the industry?

Parameters

  cargo | Cargo type
  ind | Industry
  *c_accepts | Pointer to boolean for acceptance of cargo
  *c_produces | Pointer to boolean for production of cargo

Returns
  : `*c_accepts` is set when industry accepts the cargo type, `*c_produces` is set when the industry produces the cargo type

Definition at line 2767 of file industry_cmd.cpp.

References IndustryTemporarilyRefusesCargo(), Industry::IsCargoAccepted(), Industry::IsCargoProduced(), and IsValidCargoType().

Referenced by WhoCanServiceIndustry().

## ◆ ChangeIndustryProduction()

static void ChangeIndustryProduction | ( | Industry * | i,
|  | bool | monthly
| ) |  |
| static

Change industry production or do closure.

Parameters

  i | Industry for which changes are performed
  monthly | true if it's the monthly call, false if it's the random call

< reinitialize production_rate to match prod_level

Definition at line 2871 of file industry_cmd.cpp.

References _settings_game, abs(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), IndustrySpec::behaviour, AI::BroadcastNewEvent(), CALLBACK_FAILED, IndustrySpec::callback_mask, CBID_INDUSTRY_MONTHLYPROD_CHANGE, CBID_INDUSTRY_PRODUCTION_CHANGE, Chance16(), Chance16I(), CheckIndustryCloseDownProtection(), Clamp(), ClampU(), IndustrySpec::closure_text, CT_PASSENGERS, Industry::ctlflags, DontIncrProd, GameSettings::economy, ExternalProdLevel, GameSettings::game_creation, GB(), GetEncodedString(), GetIndustryCallback(), GetIndustrySpec(), Industry::GetProduced(), IndustrySpec::grf_prop, GRFFilePropsBase::grfid, HasBit(), Industry::ProducedCargo::history, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, IndustryClose, IndustryCompany, INDUSTRYLIFE_BLACK_HOLE, IndustryNobody, IndustryOther, IsValidCargoType(), GameCreationSettings::landscape, Industry::last_prod_year, IndustrySpec::life_type, Industry::location, MapGRFStringID(), MonthlyProdChange, IndustrySpec::name, Game::NewEvent(), NoClosure, NoPaxProdClamp, NoProductionDecrease, NoProductionIncrease, Processing, PROCESSING_INDUSTRY_ABANDONMENT_YEARS, Industry::prod_level, PRODLEVEL_CLOSURE, PRODLEVEL_MAXIMUM, PRODLEVEL_MINIMUM, Industry::produced, IndustrySpec::production_down_text, IndustrySpec::production_up_text, ProductionChange, Random, RandomRange(), Industry::RecomputeProductionMultipliers(), ReportNewsProductionChangeIndustry(), SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), OrthogonalTileArea::tile, TileDiffXY(), Industry::town, Industry::type, EconomySettings::type, IndustrySpec::UsesOriginalEconomy(), WC_INDUSTRY_VIEW, WhoCanServiceIndustry(), and TimerGameEconomy::year.

## ◆ ChangeTileOwner_Industry()

static void ChangeTileOwner_Industry | ( | TileIndex | tile,
|  | Owner | old_owner,
|  | Owner | new_owner
| ) |  |
| static

Definition at line 963 of file industry_cmd.cpp.

## ◆ CheckCanTerraformSurroundingTiles()

static bool CheckCanTerraformSurroundingTiles | ( | TileIndex | tile,
|  | uint | height,
|  | int | internal
| ) |  |
| static

Definition at line 1589 of file industry_cmd.cpp.

## ◆ CheckIfCanLevelIndustryPlatform()

static bool CheckIfCanLevelIndustryPlatform | ( | TileIndex | tile,
|  | DoCommandFlags | flags,
|  | const IndustryTileLayout & | layout
| ) |  |
| static

This function tries to flatten out the land below an industry, without damaging the surroundings too much.

Definition at line 1620 of file industry_cmd.cpp.

References _current_company, _settings_game, GameSettings::construction, Execute, GFX_WATERTILE_SPECIALCHECK, OrthogonalTileArea::h, ConstructionSettings::industry_platform, Map::MaxX(), Map::MaxY(), OWNER_TOWN, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), Backup< T >::Restore(), SLOPE_N, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), OrthogonalTileArea::tile, TileDiffXY(), TileHeight(), TileX(), TileY(), and OrthogonalTileArea::w.

Referenced by CreateNewIndustryHelper().

## ◆ CheckIfFarEnoughFromConflictingIndustry()

static CommandCost CheckIfFarEnoughFromConflictingIndustry | ( | TileIndex | tile,
|  | IndustryType | type
| ) |  |
| static

Check that the new industry is far enough from conflicting industries.

Parameters

  tile | Tile to construct the industry.
  type | Type of the new industry.

Returns
  Succeeded or failed command.

Definition at line 1693 of file industry_cmd.cpp.

References IndustrySpec::conflicting, DistanceMax(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::Get(), GetIndustrySpec(), and Industry::industries.

Referenced by CreateNewIndustryHelper().

## ◆ CheckIfIndustryIsAllowed()

static CommandCost CheckIfIndustryIsAllowed | ( | TileIndex | tile,
|  | IndustryType | type,
|  | const Town * | t
| ) |  |
| static

Is the industry allowed to be built at this place for the town?

Parameters

  tile | Tile to construct the industry.
  type | Type of the industry.
  t | Town authority that the industry belongs to.

Returns
  Succeeded or failed command.

Definition at line 1576 of file industry_cmd.cpp.

References Town::cache, DistanceMax(), GetIndustrySpec(), OnlyNearTown, TownCache::population, Town1200More, and Town::xy.

Referenced by CreateNewIndustryHelper().

## ◆ CheckIfIndustryTilesAreFree()

static CommandCost CheckIfIndustryTilesAreFree | ( | TileIndex | tile,
|  | const IndustryTileLayout & | layout,
|  | IndustryType | type
| ) |  |
| static

Are the tiles of the industry free?

Parameters

  tile | Position to check.
  layout | Industry tiles table.
  type | Type of the industry.

Returns
  Failed or succeeded command.

Definition at line 1472 of file industry_cmd.cpp.

References _current_company, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Auto, IndustrySpec::behaviour, BuiltOnWater, EnsureNoVehicleOnGround(), CommandCost::Failed(), GetIndustrySpec(), GetIndustryTileSpec(), GetTranslatedIndustryTileID(), GFX_WATERTILE_SPECIALCHECK, HasBit(), HasTileWaterClass(), IsBridgeAbove(), IsTileFlat(), IsTileOnWater(), IsTileType(), IsValidTile(), IsWaterTile(), MP_HOUSE, NoModifyTownRating, NoTestTownRating, OnlyNearTown, OWNER_TOWN, Backup< T >::Restore(), IndustryTileSpec::slopes_refused, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and TileAddWrap().

Referenced by CreateNewIndustryHelper().

## ◆ CheckIfIndustryTileSlopes()

static CommandCost CheckIfIndustryTileSlopes | ( | TileIndex | tile,
|  | const IndustryTileLayout & | layout,
|  | size_t | layout_index,
|  | IndustryType | type,
|  | uint16_t | initial_random_bits,
|  | Owner | founder,
|  | IndustryAvailabilityCallType | creation_type,
|  | bool * | custom_shape_check = `nullptr`
| ) |  |
| static

Check slope requirements for industry tiles.

Parameters

  | tile | Position to check.
  | layout | Industry tiles table.
  | layout_index | The index of the layout to build/fund
  | type | Type of the industry.
  | initial_random_bits | The random bits the industry is going to have after construction.
  | founder | Industry founder
  | creation_type | The circumstances the industry is created under.
  [out] | custom_shape_check | Perform custom check for the site.

Returns
  Failed or succeeded command.

Definition at line 1534 of file industry_cmd.cpp.

References _generating_world, _settings_game, IndustryTileSpec::callback_mask, CommandCost::Failed(), GameSettings::game_creation, GetIndustryTileSpec(), GetTileSlope(), GetTranslatedIndustryTileID(), GFX_WATERTILE_SPECIALCHECK, IsValidTile(), GameCreationSettings::land_generator, LG_TERRAGENESIS, PerformIndustryTileSlopeCheck(), ShapeCheck, IndustryTileSpec::slopes_refused, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and TileAddWrap().

Referenced by CreateNewIndustryHelper().

## ◆ CheckIndustries()

void CheckIndustries | ( |  | ) |

Verify whether the generated industries are complete, and warn the user if not.

Definition at line 3159 of file industry_cmd.cpp.

References GetEncodedString(), GetIndustrySpec(), Industry::GetIndustryTypeCount(), GetScaledIndustryGenerationProbability(), IndustrySpec::name, NUM_INDUSTRYTYPES, ShowErrorMessage(), and WL_WARNING.

## ◆ CheckIndustryCloseDownProtection()

static bool CheckIndustryCloseDownProtection | ( | IndustryType | type | ) |
| static

Protects an industry from closure if the appropriate flags and conditions are met CanCloseLastInstance must be set (which, by default, it is not) and the count of industries of this type must one (or lower) in order to be protected against closure.

Parameters

  type | IndustryType been queried

Returns
  true if protection is on, false otherwise (except for oil wells)

Definition at line 2749 of file industry_cmd.cpp.

References _settings_game, IndustrySpec::behaviour, CanCloseLastInstance, DontIncrProd, GameSettings::game_creation, GetIndustrySpec(), Industry::GetIndustryTypeCount(), GameCreationSettings::landscape, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by ChangeIndustryProduction().

## ◆ CheckNewIndustry_BubbleGen()

static CommandCost CheckNewIndustry_BubbleGen | ( | TileIndex | tile | ) |
| static

Check the conditions of CHECK_BUBBLEGEN (Industry should be in low land).

Parameters

  tile | Tile to perform the checking.

Returns
  Succeeded or failed command.

Definition at line 1394 of file industry_cmd.cpp.

References GetTileZ().

## ◆ CheckNewIndustry_Farm()

static CommandCost CheckNewIndustry_Farm | ( | TileIndex | tile | ) |
| static

Check the conditions of CHECK_FARM (Industry should be below snow-line in arctic).

Parameters

  tile | Tile to perform the checking.

Returns
  Succeeded or failed command.

Definition at line 1340 of file industry_cmd.cpp.

References _settings_game, GameSettings::game_creation, GetTileZ(), HighestSnowLine(), and GameCreationSettings::landscape.

## ◆ CheckNewIndustry_Forest()

static CommandCost CheckNewIndustry_Forest | ( | TileIndex | tile | ) |
| static

Check the conditions of CHECK_FOREST (Industry should be build above snow-line in arctic climate).

Parameters

  tile | Tile to perform the checking.

Returns
  Succeeded or failed command.

Definition at line 1271 of file industry_cmd.cpp.

References _settings_game, GameSettings::game_creation, GetTileZ(), HighestSnowLine(), and GameCreationSettings::landscape.

## ◆ CheckNewIndustry_Lumbermill()

static CommandCost CheckNewIndustry_Lumbermill | ( | TileIndex | tile | ) |
| static

Check the conditions of CHECK_LUMBERMILL (Industry should be in the rainforest).

Parameters

  tile | Tile to perform the checking.

Returns
  Succeeded or failed command.

Definition at line 1381 of file industry_cmd.cpp.

References GetTropicZone(), and TROPICZONE_RAINFOREST.

## ◆ CheckNewIndustry_NULL()

static CommandCost CheckNewIndustry_NULL | ( | TileIndex |  | ) |
| static

Check the conditions of CHECK_NOTHING (Always succeeds).

Returns
  Succeeded or failed command.

Definition at line 1261 of file industry_cmd.cpp.

## ◆ CheckNewIndustry_OilRefinery()

static CommandCost CheckNewIndustry_OilRefinery | ( | TileIndex | tile | ) |
| static

Check the conditions of CHECK_REFINERY (Industry should be positioned near edge of the map).

Parameters

  tile | Tile to perform the checking.

Returns
  Succeeded or failed command.

Definition at line 1309 of file industry_cmd.cpp.

References _settings_game, CheckScaledDistanceFromEdge(), GameSettings::game_creation, GameCreationSettings::oil_refinery_limit, and TileAddXY().

## ◆ CheckNewIndustry_OilRig()

static CommandCost CheckNewIndustry_OilRig | ( | TileIndex | tile | ) |
| static

Check the conditions of CHECK_OIL_RIG (Industries at sea should be positioned near edge of the map).

Parameters

  tile | Tile to perform the checking.

Returns
  Succeeded or failed command.

Definition at line 1325 of file industry_cmd.cpp.

References _settings_game, CheckScaledDistanceFromEdge(), GameSettings::game_creation, GameCreationSettings::oil_refinery_limit, TileAddXY(), and TileHeight().

## ◆ CheckNewIndustry_Plantation()

static CommandCost CheckNewIndustry_Plantation | ( | TileIndex | tile | ) |
| static

Check the conditions of CHECK_PLANTATION (Industry should NOT be in the desert).

Parameters

  tile | Tile to perform the checking.

Returns
  Succeeded or failed command.

Definition at line 1355 of file industry_cmd.cpp.

References GetTropicZone(), and TROPICZONE_DESERT.

## ◆ CheckNewIndustry_Water()

static CommandCost CheckNewIndustry_Water | ( | TileIndex | tile | ) |
| static

Check the conditions of CHECK_WATER (Industry should be in the desert).

Parameters

  tile | Tile to perform the checking.

Returns
  Succeeded or failed command.

Definition at line 1368 of file industry_cmd.cpp.

References GetTropicZone(), and TROPICZONE_DESERT.

## ◆ CheckScaledDistanceFromEdge()

static bool CheckScaledDistanceFromEdge | ( | TileIndex | tile,
|  | uint | maxdist
| ) |  |
| static

Check if a tile is within a distance from map edges, scaled by map dimensions independently.

Each dimension is checked independently, and dimensions smaller than 256 are not scaled.

Parameters

  tile | Which tile to check distance of.
  maxdist | Normal distance on a 256x256 map.

Returns
  True if the tile is near the map edge.

Definition at line 1288 of file industry_cmd.cpp.

References DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DistanceFromEdgeDir(), Map::SizeX(), and Map::SizeY().

Referenced by CheckNewIndustry_OilRefinery(), and CheckNewIndustry_OilRig().

## ◆ ChopLumberMillTrees()

static void ChopLumberMillTrees | ( | Industry * | i | ) |
| static

Perform a circular search around the Lumber Mill in order to find trees to cut.

Parameters

  i | industry

Definition at line 1113 of file industry_cmd.cpp.

References _current_company, _settings_client, SoundSettings::ambient, Execute, GetTreeGrowth(), Grown, IsIndustryCompleted(), IsTileType(), IsValidCargoType(), Industry::location, MP_TREES, OWNER_NONE, Industry::produced, ScaleByCargoScale(), SND_38_LUMBER_MILL_1, ClientSettings::sound, OrthogonalTileArea::tile, and Industry::TileBelongsToIndustry().

## ◆ ClearAllIndustryCachedNames()

void ClearAllIndustryCachedNames | ( |  | ) |

Definition at line 2608 of file industry_cmd.cpp.

## ◆ ClearTile_Industry()

static CommandCost ClearTile_Industry | ( | TileIndex | tile,
|  | DoCommandFlags | flags
| ) |  |
| static

Definition at line 489 of file industry_cmd.cpp.

## ◆ ClickTile_Industry()

static bool ClickTile_Industry | ( | TileIndex | tile | ) |
| static

Definition at line 952 of file industry_cmd.cpp.

## ◆ CmdBuildIndustry()

CommandCost CmdBuildIndustry | ( | DoCommandFlags | flags,
|  | TileIndex | tile,
|  | IndustryType | it,
|  | uint32_t | first_layout,
|  | bool | fund,
|  | uint32_t | seed
| ) |  |

Build/Fund an industry.

Parameters

  flags | of operations to conduct
  tile | tile where industry is built
  it | industry type see build_industry.h and see industry.h
  first_layout | first layout to try
  fund | false = prospect, true = fund (only valid if current company is DEITY)
  seed | seed to use for desyncfree randomisations

Returns
  the cost of this operation or an error

Definition at line 2064 of file industry_cmd.cpp.

References _current_company, _settings_game, AdvertiseIndustryOpening(), CMD_ERROR, GameSettings::construction, CreateNewIndustryHelper(), IndustrySpec::enabled, Execute, EXPENSES_OTHER, CommandCost::Failed(), GB(), IndustrySpec::GetConstructionCost(), GetEncodedString(), GetIndustryProbabilityCallback(), GetIndustrySpec(), Backup< T >::GetOriginalValue(), IACT_PROSPECTCREATION, IACT_RANDOMCREATION, IACT_USERCREATION, IsLocalCompany(), IndustrySpec::IsRawIndustry(), IndustrySpec::layouts, Randomizer::Next(), NUM_INDUSTRYTYPES, OWNER_DEITY, OWNER_TOWN, IndustrySpec::prospecting_chance, Random, RandomRange(), RandomTile, ConstructionSettings::raw_industry_construction, Backup< T >::Restore(), Randomizer::SetSeed(), ShowErrorMessage(), CommandCost::Succeeded(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WL_INFO.

## ◆ CmdIndustrySetExclusivity()

CommandCost CmdIndustrySetExclusivity | ( | DoCommandFlags | flags,
|  | IndustryID | ind_id,
|  | Owner | company_id,
|  | bool | consumer
| ) |  |

Change exclusive consumer or supplier for the industry.

Parameters

  flags | Type of operation.
  ind_id | IndustryID
  company_id | CompanyID to set or INVALID_OWNER (available to everyone) or OWNER_NONE (neutral stations only) or OWNER_DEITY (no one)
  consumer | Set exclusive consumer if true, supplier if false.

Returns
  Empty cost or an error.

Definition at line 2233 of file industry_cmd.cpp.

References _current_company, CMD_ERROR, Industry::exclusive_consumer, Industry::exclusive_supplier, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::GetIfValid(), INVALID_OWNER, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), OWNER_DEITY, OWNER_NONE, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

## ◆ CmdIndustrySetFlags()

CommandCost CmdIndustrySetFlags | ( | DoCommandFlags | flags,
|  | IndustryID | ind_id,
|  | IndustryControlFlags | ctlflags
| ) |  |

Set industry control flags.

Parameters

  flags | Type of operation.
  ind_id | IndustryID
  ctlflags | IndustryControlFlags

Returns
  Empty cost or an error.

Definition at line 2156 of file industry_cmd.cpp.

References _current_company, CMD_ERROR, Industry::ctlflags, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::GetIfValid(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::IsValid(), OWNER_DEITY, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

## ◆ CmdIndustrySetProduction()

CommandCost CmdIndustrySetProduction | ( | DoCommandFlags | flags,
|  | IndustryID | ind_id,
|  | uint8_t | prod_level,
|  | bool | show_news,
|  | const EncodedString & | custom_news
| ) |  |

Set industry production.

Parameters

  flags | Type of operation.
  ind_id | IndustryID
  prod_level | Production level.
  show_news | Show a news message on production change.
  custom_news | Custom news message text.

Returns
  Empty cost or an error.

Definition at line 2178 of file industry_cmd.cpp.

References _current_company, CMD_ERROR, Industry::ctlflags, Execute, ExternalProdLevel, GetEncodedString(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::GetIfValid(), GetIndustrySpec(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, IndustryCompany, IndustryNobody, IndustryOther, IndustrySpec::name, OWNER_DEITY, Industry::prod_level, PRODLEVEL_MAXIMUM, IndustrySpec::production_down_text, IndustrySpec::production_up_text, Industry::RecomputeProductionMultipliers(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Industry::town, Industry::type, and WhoCanServiceIndustry().

## ◆ CmdIndustrySetText()

CommandCost CmdIndustrySetText | ( | DoCommandFlags | flags,
|  | IndustryID | ind_id,
|  | const EncodedString & | text
| ) |  |

Change additional industry text.

Parameters

  flags | Type of operation.
  ind_id | IndustryID
  text | - Additional industry text.

Returns
  Empty cost or an error.

Definition at line 2262 of file industry_cmd.cpp.

References _current_company, CMD_ERROR, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, InvalidateWindowData(), OWNER_DEITY, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Industry::text, and WC_INDUSTRY_VIEW.

## ◆ CreateChimneySmoke()

static void CreateChimneySmoke | ( | TileIndex | tile | ) |
| static

Definition at line 742 of file industry_cmd.cpp.

## ◆ CreateNewIndustry()

static Industry * CreateNewIndustry | ( | TileIndex | tile,
|  | IndustryType | type,
|  | IndustryAvailabilityCallType | creation_type
| ) |  |
| static

Create a new industry of random layout.

Parameters

  tile | The location to build the industry.
  type | The industry type to build.
  creation_type | The circumstances the industry is created under.

Returns
  the created industry or nullptr if it failed.

Definition at line 2285 of file industry_cmd.cpp.

References CreateNewIndustryHelper(), Execute, CommandCost::Failed(), GB(), GetIndustrySpec(), IndustrySpec::layouts, OWNER_NONE, Random, and RandomRange().

Referenced by PlaceIndustry().

## ◆ CreateNewIndustryHelper()

static CommandCost CreateNewIndustryHelper | ( | TileIndex | tile,
|  | IndustryType | type,
|  | DoCommandFlags | flags,
|  | const IndustrySpec * | indspec,
|  | size_t | layout_index,
|  | uint32_t | random_var8f,
|  | uint16_t | random_initial_bits,
|  | Owner | founder,
|  | IndustryAvailabilityCallType | creation_type,
|  | Industry ** | ip
| ) |  |
| static

Helper function for Build/Fund an industry.

Parameters

  | tile | tile where industry is built
  | type | of industry to build
  | flags | of operations to conduct
  | indspec | pointer to industry specifications
  | layout_index | the index of the itsepc to build/fund
  | random_var8f | random seed (possibly) used by industries
  | random_initial_bits | The random bits the industry is going to have after construction.
  | founder | Founder of the industry
  | creation_type | The circumstances the industry is created under.
  [out] | ip | Pointer to store newly created industry.

Returns
  Succeeded or failed command.

Postcondition
  `*ip` contains the newly created industry if all checks are successful and the flags request actual creation, else it contains `nullptr` afterwards.

Definition at line 2000 of file industry_cmd.cpp.

References _check_new_industry_procs, _generating_world, _settings_game, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::CanAllocateItem(), IndustrySpec::check_proc, CheckIfCallBackAllowsCreation(), CheckIfCanLevelIndustryPlatform(), CheckIfFarEnoughFromConflictingIndustry(), CheckIfIndustryIsAllowed(), CheckIfIndustryTilesAreFree(), CheckIfIndustryTileSlopes(), DoCreateNewIndustry(), Execute, CommandCost::Failed(), FindTownForIndustry(), GameSettings::game_creation, GetIndustrySpec(), GameCreationSettings::land_generator, IndustrySpec::layouts, LG_TERRAGENESIS, Location, NoWater, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by CmdBuildIndustry(), and CreateNewIndustry().

## ◆ DoCreateNewIndustry()

static void DoCreateNewIndustry | ( | Industry * | i,
|  | TileIndex | tile,
|  | IndustryType | type,
|  | const IndustryTileLayout & | layout,
|  | size_t | layout_index,
|  | Town * | t,
|  | Owner | founder,
|  | uint16_t | initial_random_bits
| ) |  |
| static

Put an industry on the map.

Parameters

  i | Just allocated poolitem, mostly empty.
  tile | North tile of the industry.
  type | Type of the industry.
  layout | Industrylayout to build.
  layout_index | Number of the industry layout.
  t | Nearest town.
  founder | Founder of the industry; OWNER_NONE in case of random construction.
  initial_random_bits | Random bits for the industry.

Definition at line 1762 of file industry_cmd.cpp.

References _generating_world, Industry::accepted, IndustrySpec::accepts_cargo, OrthogonalTileArea::Add(), AddAnimatedTile(), IndustryTileSpec::animation, IndustrySpec::behaviour, CALLBACK_FAILED, IndustrySpec::callback_mask, Industry::ProducedCargo::cargo, Industry::AcceptedCargo::cargo, CargoTypesUnlimited, CBID_INDUSTRY_DECIDE_COLOUR, CBID_INDUSTRY_INPUT_CARGO_TYPES, CBID_INDUSTRY_OUTPUT_CARGO_TYPES, CBID_INDUSTRY_PROD_CHANGE_BUILD, Industry::construction_date, Industry::construction_type, Industry::counter, Industry::ctlflags, TimerGameCalendar::date, DecideColour, ErrorUnknownCallbackResult(), Industry::exclusive_consumer, Industry::exclusive_supplier, Execute, Industry::founder, GB(), GetCargoTranslation(), GetIndustryCallback(), GetIndustrySpec(), GetIndustryTileSpec(), GetTranslatedIndustryTileID(), GetWaterClass(), GFX_WATERTILE_SPECIALCHECK, IndustrySpec::grf_prop, GRFFilePropsBase::grffile, GRFFilePropsBase::grfid, ICT_MAP_GENERATION, ICT_NORMAL_GAMEPLAY, ICT_SCENARIO_EDITOR, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Industry::industries, INDUSTRY_NUM_INPUTS, INDUSTRY_NUM_OUTPUTS, IndustryProductionCallback(), InputCargoTypes, Invalid, INVALID_OWNER, INVALID_TILE, InvalidateWindowData(), IsValidCargoType(), IsWaterTile(), Industry::last_prod_year, Industry::location, MakeIndustry(), TimerGameEconomy::month, NoAnimation, NoModifyTownRating, NoTestTownRating, OutputCargoTypes, Industry::owner, OWNER_NONE, PlantOnBuild, PopulateStationsNearby(), Industry::prod_level, ProdChangeBuild, PRODLEVEL_DEFAULT, PRODLEVEL_MAXIMUM, Industry::produced, Production256Ticks, Industry::random, Random, Industry::random_colour, RandomRange(), Industry::ProducedCargo::rate, Industry::RecomputeProductionMultipliers(), ScaleByCargoScale(), Industry::selected_layout, SetIndustryConstructionCounter(), SetIndustryConstructionStage(), SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Industry::TileBelongsToIndustry(), ToTileIndexDiff(), Industry::town, Industry::type, UpdateValidHistory(), IndustrySpec::UsesOriginalEconomy(), Industry::valid_history, Industry::was_cargo_delivered, WC_BUILD_INDUSTRY, WC_INDUSTRY_DIRECTORY, and TimerGameEconomy::year.

Referenced by CreateNewIndustryHelper().

## ◆ DrawTile_Industry()

static void DrawTile_Industry | ( | TileInfo * | ti | ) |
| static

Definition at line 329 of file industry_cmd.cpp.

## ◆ FindTownForIndustry()

static CommandCost FindTownForIndustry | ( | TileIndex | tile,
|  | IndustryType | type,
|  | Town ** | t
| ) |  |
| static

Find a town for the industry, while checking for multiple industries in the same town.

Parameters

  | tile | Position of the industry to build.
  | type | Industry type.
  [out] | t | Pointer to return town for the new industry, `nullptr` is written if no good town can be found.

Returns
  Succeeded or failed command.

Precondition
  `*t` != nullptr

Postcondition
  `*t` points to a town on success, and `nullptr` on failure.

Definition at line 1432 of file industry_cmd.cpp.

References _settings_game, ClosestTownFromTile(), GameSettings::economy, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::Get(), Industry::industries, and EconomySettings::multiple_industry_per_town.

Referenced by CreateNewIndustryHelper().

## ◆ GenerateIndustries()

void GenerateIndustries | ( |  | ) |

This function will create random industries during game creation.

It will scale the amount of industries by mapsize and difficulty level.

Definition at line 2488 of file industry_cmd.cpp.

References _industry_builder, _settings_game, GameSettings::difficulty, GetNumberOfIndustries(), GetScaledProbabilities(), GWP_LAND_INDUSTRY, GWP_WATER_INDUSTRY, ID_CUSTOM, ID_FUND_ONLY, DifficultySettings::industry_density, NUM_INDUSTRYTYPES, PlaceInitialIndustry(), RandomRange(), IndustryBuildData::Reset(), Map::ScaleByLandProportion(), and SetGeneratingWorldProgress().

Referenced by _GenerateWorld().

## ◆ GetCurrentTotalNumberOfIndustries()

static uint GetCurrentTotalNumberOfIndustries | ( |  | ) |
| static

Get total number of industries existing in the game.

Returns
  Number of industries currently in the game.

Definition at line 2415 of file industry_cmd.cpp.

References Industry::industries.

Referenced by IndustryBuildData::EconomyMonthlyLoop(), and IndustryBuildData::Reset().

## ◆ GetFoundation_Industry()

static Foundation GetFoundation_Industry | ( | TileIndex | tile,
|  | Slope | tileh
| ) |  |
| static

Definition at line 394 of file industry_cmd.cpp.

## ◆ GetIndustryGamePlayProbability()

static uint16_t GetIndustryGamePlayProbability | ( | IndustryType | it,
|  | uint8_t * | min_number
| ) |  |
| static

Compute the probability for constructing a new industry during game play.

Parameters

  | it | Industry type to compute.
  [out] | min_number | Minimal number of industries that should exist at the map.

Returns
  Relative probability for the industry to appear.

Definition at line 2333 of file industry_cmd.cpp.

References _settings_game, After1960, IndustrySpec::appear_ingame, Before1950, IndustrySpec::behaviour, CanCloseLastInstance, GameSettings::difficulty, IndustrySpec::enabled, GameSettings::game_creation, GetIndustryProbabilityCallback(), GetIndustrySpec(), IACT_RANDOMCREATION, ID_FUND_ONLY, DifficultySettings::industry_density, GameCreationSettings::landscape, IndustrySpec::layouts, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), to_underlying(), and TimerGameCalendar::year.

Referenced by IndustryTypeBuildData::GetIndustryTypeData().

## ◆ GetIndustrySpec()

const IndustrySpec * GetIndustrySpec | ( | IndustryType | thistype | ) |

Accessor for array _industry_specs.

Array of industries data.

This will ensure at once : proper access and not allowing modifications of it.

Parameters

  thistype | of industry (which is the index in _industry_specs)

Precondition
  thistype < NUM_INDUSTRYTYPES

Returns
  a pointer to the corresponding industry spec

Definition at line 126 of file industry_cmd.cpp.

References NUM_INDUSTRYTYPES.

Referenced by IndustryOverrideManager::AddEntityID(), AdvertiseIndustryOpening(), AfterLoadGame(), BuildIndustriesLegend(), ChangeIndustryProduction(), CheckIfCallBackAllowsCreation(), CheckIfFarEnoughFromConflictingIndustry(), CheckIfIndustryIsAllowed(), CheckIfIndustryTilesAreFree(), CheckIndustries(), CheckIndustryCloseDownProtection(), CmdBuildIndustry(), CmdIndustrySetProduction(), CMSAMine(), IndustryCargoesWindow::ComputeCargoDisplay(), IndustryCargoesWindow::ComputeIndustryDisplay(), CargoesRow::ConnectIndustryAccepted(), CargoesRow::ConnectIndustryProduced(), IndustryCargoesWindow::CountMatchingAcceptingIndustries(), IndustryCargoesWindow::CountMatchingProducingIndustries(), CreateNewIndustry(), CreateNewIndustryHelper(), Disaster_CoalMine_Init(), Disaster_Helicopter_Init(), DisasterTick_Aircraft(), DoCreateNewIndustry(), CargoesField::Draw(), IndustryViewWindow::DrawInfo(), BuildIndustryWindow::DrawWidget(), FormatString(), GenerateStationName(), GetAiPurchaseCallbackResult(), NIHIndustry::GetBadges(), GetCountAndDistanceOfClosestInstance(), IndustriesResolverObject::GetDebugID(), GetGrffile(), NIHIndustry::GetGRFID(), GetIndustryGamePlayProbability(), GetIndustryProbabilityCallback(), IndustryDirectoryWindow::GetIndustryString(), GetScaledIndustryGenerationProbability(), NIHIndustry::GetSpec(), SmallMapWindow::GetTileColours(), IndustriesScopeResolver::GetVariable(), BuildIndustryWindow::GetWidgetString(), IndustryCargoesWindow::GetWidgetString(), IndustriesResolverObject::IndustriesResolverObject(), IndustryProductionCallback(), IndustryTemporarilyRefusesCargo(), IndustryTypeNameSorter(), NIHIndustry::IsInspectable(), IsTileForestIndustry(), BuildIndustryWindow::OnClick(), IndustryCargoesWindow::OnClick(), IndustryCargoesWindow::OnInit(), IndustryViewWindow::OnInvalidateData(), BuildIndustryWindow::OnPlaceObject(), Industry::RecomputeProductionMultipliers(), ShowIndustryCargoesWindow(), IndustriesScopeResolver::StorePSA(), TransportIndustryGoods(), TriggerIndustryProduction(), and BuildIndustryWindow::UpdateWidgetSize().

## ◆ GetIndustryTileSpec()

const IndustryTileSpec * GetIndustryTileSpec | ( | IndustryGfx | gfx | ) |

Accessor for array _industry_tile_specs.

Array of industry tiles data.

This will ensure at once : proper access and not allowing modifications of it.

Parameters

  gfx | of industrytile (which is the index in _industry_tile_specs)

Precondition
  gfx < INVALID_INDUSTRYTILE

Returns
  a pointer to the corresponding industrytile spec

Definition at line 140 of file industry_cmd.cpp.

References NUM_INDUSTRYTILES.

Referenced by CheckIfIndustryTilesAreFree(), CheckIfIndustryTileSlopes(), DoCreateNewIndustry(), DoTriggerIndustryTileRandomisation(), NIHIndustryTile::GetBadges(), IndustryTileResolverObject::GetDebugID(), NIHIndustryTile::GetGRFID(), GetIndTileGrffile(), GetIndustryIDAtOffset(), NIHIndustryTile::GetSpec(), IndustryTileScopeResolver::GetVariable(), IndustryTileResolverObject::IndustryTileResolverObject(), and NIHIndustryTile::IsInspectable().

## ◆ GetIndustryType()

IndustryType GetIndustryType | ( | Tile | tile | ) |

Retrieve the type for this industry.

Although it is accessed by a tile, it will return the general type of industry, and not the sprite index as would do GetIndustryGfx.

Parameters

  tile | that is queried

Precondition
  IsTileType(tile, MP_INDUSTRY)

Returns
  general type for this industry, as defined in industry.h

Definition at line 109 of file industry_cmd.cpp.

References Industry::GetByTile(), IsTileType(), MP_INDUSTRY, and Industry::type.

Referenced by AfterLoadGame(), and GenerateStationName().

## ◆ GetNumberOfIndustries()

static uint GetNumberOfIndustries | ( |  | ) |
| static

Get wanted number of industries on the map.

Returns
  Wanted number of industries at the map.

Definition at line 2357 of file industry_cmd.cpp.

References _settings_game, GameCreationSettings::custom_industry_number, GameSettings::difficulty, GameSettings::game_creation, ID_CUSTOM, ID_END, ID_VERY_LOW, DifficultySettings::industry_density, lengthof, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::MAX_SIZE, and Map::ScaleBySize().

Referenced by GenerateIndustries().

## ◆ GetScaledIndustryGenerationProbability()

static uint32_t GetScaledIndustryGenerationProbability | ( | IndustryType | it,
|  | std::optional< bool > | water,
|  | bool * | force_at_least_one
| ) |  |
| static

Compute the appearance probability for an industry during map creation.

Parameters

  | it | Industry type to compute.
  | water | Whether to get probability of land-based, water-based, (or both, if std::nullopt), industry types.
  [out] | force_at_least_one | Returns whether at least one instance should be forced on map creation.

Returns
  Relative probability for the industry to appear.

Definition at line 2305 of file industry_cmd.cpp.

References _settings_game, IndustrySpec::appear_creation, IndustrySpec::behaviour, BuiltOnWater, CHECK_OIL_RIG, IndustrySpec::check_proc, CHECK_REFINERY, GameSettings::difficulty, IndustrySpec::enabled, GameSettings::game_creation, GetIndustryProbabilityCallback(), GetIndustrySpec(), IACT_MAPGENERATION, ID_FUND_ONLY, DifficultySettings::industry_density, GameCreationSettings::landscape, IndustrySpec::layouts, NoBuildMapCreation, Map::ScaleBySize(), Map::ScaleBySize1D(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and to_underlying().

Referenced by CheckIndustries(), and GetScaledProbabilities().

## ◆ GetScaledProbabilities()

static IndustryGenerationProbabilities GetScaledProbabilities | ( | bool | water | ) |
| static

Get scaled industry generation probabilities.

Parameters

  water | Whether to get land or water industry probabilities.

Returns
  Probability information.

Definition at line 2471 of file industry_cmd.cpp.

References GetScaledIndustryGenerationProbability(), and NUM_INDUSTRYTYPES.

Referenced by GenerateIndustries().

## ◆ GetSlopePixelZ_Industry()

static int GetSlopePixelZ_Industry | ( | TileIndex | tile,
|  | uint | ,
|  | uint | ,
|  | bool |
| ) |  |
| static

Definition at line 389 of file industry_cmd.cpp.

## ◆ GetTileDesc_Industry()

static void GetTileDesc_Industry | ( | TileIndex | tile,
|  | TileDesc & | td
| ) |  |
| static

Definition at line 472 of file industry_cmd.cpp.

## ◆ GetTileTrackStatus_Industry()

static TrackStatus GetTileTrackStatus_Industry | ( | TileIndex | ,
|  | TransportType | ,
|  | uint | ,
|  | DiagDirection |
| ) |  |
| static

Definition at line 958 of file industry_cmd.cpp.

## ◆ IndustryDrawBubbleGenerator()

static void IndustryDrawBubbleGenerator | ( | const TileInfo * | ti | ) |
| static

Definition at line 281 of file industry_cmd.cpp.

## ◆ IndustryDrawCoalPlantSparks()

static void IndustryDrawCoalPlantSparks | ( | const TileInfo * | ti | ) |
| static

Definition at line 305 of file industry_cmd.cpp.

## ◆ IndustryDrawSugarMine()

static void IndustryDrawSugarMine | ( | const TileInfo * | ti | ) |
| static

Definition at line 248 of file industry_cmd.cpp.

## ◆ IndustryDrawToffeeQuarry()

static void IndustryDrawToffeeQuarry | ( | const TileInfo * | ti | ) |
| static

Definition at line 266 of file industry_cmd.cpp.

## ◆ IndustryDrawToyFactory()

static void IndustryDrawToyFactory | ( | const TileInfo * | ti | ) |
| static

Definition at line 289 of file industry_cmd.cpp.

## ◆ InitializeIndustries()

void InitializeIndustries | ( |  | ) |

Definition at line 3150 of file industry_cmd.cpp.

## ◆ IsSlopeRefused()

bool IsSlopeRefused | ( | Slope | current,
|  | Slope | refused
| ) |  |

Definition at line 1448 of file industry_cmd.cpp.

## ◆ IsSuitableForFarmField()

static bool IsSuitableForFarmField | ( | TileIndex | tile,
|  | bool | allow_fields,
|  | bool | allow_rough
| ) |  |
| static

Check whether the tile can be replaced by a farm field.

Parameters

  tile | The tile to investigate.
  allow_fields | Can we replace an existing field?
  allow_rough | Can we build on rough tiles? (clear or trees)

Returns
  true if the tile can become a farm field

Definition at line 1001 of file industry_cmd.cpp.

References CLEAR_DESERT, CLEAR_FIELDS, CLEAR_ROUGH, CLEAR_SNOW, GetClearGround(), GetTileType(), GetTreeGround(), MP_CLEAR, MP_TREES, TREE_GROUND_ROUGH, and TREE_GROUND_SHORE.

## ◆ IsTileForestIndustry()

bool IsTileForestIndustry | ( | TileIndex | tile | ) |

Check whether the tile is a forest.

Parameters

  tile | the tile to investigate.

Returns
  true if and only if the tile is a forest

Definition at line 978 of file industry_cmd.cpp.

References Industry::GetByTile(), GetIndustrySpec(), IsTileType(), IndustrySpec::life_type, MP_INDUSTRY, Organic, Industry::produced, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Industry::type.

Referenced by GenerateStationName(), and GetSmallMapVegetationPixels().

## ◆ MakeIndustryTileBigger()

static void MakeIndustryTileBigger | ( | TileIndex | tile | ) |
| static

Definition at line 751 of file industry_cmd.cpp.

## ◆ OnTick_Industry()

void OnTick_Industry | ( |  | ) |

Definition at line 1233 of file industry_cmd.cpp.

## ◆ PlaceIndustry()

static Industry * PlaceIndustry | ( | IndustryType | type,
|  | IndustryAvailabilityCallType | creation_type,
|  | bool | try_hard
| ) |  |
| static

Try to place the industry in the game.

Since there is no feedback why placement fails, there is no other option than to try a few times before concluding it does not work.

Parameters

  type | Industry type of the desired industry.
  try_hard | Try very hard to find a place. (Used to place at least one industry per type.)

Returns
  Pointer to created industry, or `nullptr` if creation failed.

Definition at line 2386 of file industry_cmd.cpp.

References CreateNewIndustry(), and RandomTile.

Referenced by PlaceInitialIndustry(), and IndustryBuildData::TryBuildNewIndustry().

## ◆ PlaceInitialIndustry()

static void PlaceInitialIndustry | ( | IndustryType | type,
|  | bool | water,
|  | bool | try_hard
| ) |  |
| static

Try to build a industry on the map.

Parameters

  type | IndustryType of the desired industry
  try_hard | Try very hard to find a place. (Used to place at least one industry per type)

Definition at line 2401 of file industry_cmd.cpp.

References _current_company, GWP_LAND_INDUSTRY, GWP_WATER_INDUSTRY, IACT_MAPGENERATION, IncreaseGeneratingWorldProgress(), OWNER_NONE, PlaceIndustry(), and Backup< T >::Restore().

Referenced by GenerateIndustries().

## ◆ PlantFarmField()

static void PlantFarmField | ( | TileIndex | tile,
|  | IndustryID | industry
| ) |  |
| static

Definition at line 1048 of file industry_cmd.cpp.

## ◆ PlantRandomFarmField()

void PlantRandomFarmField | ( | const Industry * | i | ) |

Definition at line 1099 of file industry_cmd.cpp.

## ◆ PopulateStationsNearby()

static void PopulateStationsNearby | ( | Industry * | ind | ) |
| static

Populate an industry's list of nearby stations, and if it accepts any cargo, also add the industry to each station's nearby industry list.

Parameters

  ind | Industry

Definition at line 1733 of file industry_cmd.cpp.

References _settings_game, ForAllStationsAroundTiles(), Station::industries_near, Industry::location, Industry::neutral_station, StationSettings::serve_neutral_industries, GameSettings::station, and Industry::stations_near.

Referenced by DoCreateNewIndustry().

## ◆ ProduceIndustryGoods()

static void ProduceIndustryGoods | ( | Industry * | i | ) |
| static

Definition at line 1160 of file industry_cmd.cpp.

## ◆ ProduceIndustryGoodsHelper()

static void ProduceIndustryGoodsHelper | ( | Industry * | i,
|  | bool | scale
| ) |  |
| static

Helper for ProduceIndustryGoods that scales and produces cargos.

Parameters

  i | The industry
  scale | Should we scale production of this cargo directly?

Definition at line 1148 of file industry_cmd.cpp.

References IsValidCargoType(), Industry::produced, and ScaleByCargoScale().

## ◆ ReportNewsProductionChangeIndustry()

static void ReportNewsProductionChangeIndustry | ( | Industry * | ind,
|  | CargoType | cargo,
|  | int | percent
| ) |  |
| static

Report news that industry production has changed significantly.

Parameters

  ind | Industry with changed production
  cargo | Cargo type that has changed
  percent | Percentage of change (>0 means increase, <0 means decrease)

Definition at line 2844 of file industry_cmd.cpp.

References abs(), CargoSpec::Get(), GetEncodedString(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, IndustryCompany, IndustryNobody, IndustryOther, CargoSpec::name, and WhoCanServiceIndustry().

Referenced by ChangeIndustryProduction().

## ◆ ResetIndustries()

void ResetIndustries | ( |  | ) |

This function initialize the spec arrays of both industry and industry tiles.

It adjusts the enabling of the industry too, based on climate availability. This will allow for clearer testings

Definition at line 83 of file industry_cmd.cpp.

References _settings_game, GameSettings::game_creation, GameCreationSettings::landscape, and OverrideManagerBase::ResetOverride().

Referenced by ResetNewGRFData().

## ◆ SetupFarmFieldFence()

static void SetupFarmFieldFence | ( | TileIndex | tile,
|  | int | size,
|  | uint8_t | type,
|  | DiagDirection | side
| ) |  |
| static

Build farm field fence.

Parameters

  tile | the tile to position the fence on
  size | the size of the field being planted in tiles
  type | type of fence to set
  side | the side of the tile to attempt placement

Definition at line 1024 of file industry_cmd.cpp.

References Chance16(), CLEAR_FIELDS, DiagDirToAxis(), GetFence(), IsClearGround(), IsTileType(), MP_CLEAR, OtherAxis(), ReverseDiagDir(), SetFence(), TileOffsByAxis(), TileOffsByDiagDir(), and Map::WrapToMap().

## ◆ ShowIndustryViewWindow()

void ShowIndustryViewWindow | ( | IndustryID | industry | ) |

Definition at line 1239 of file industry_gui.cpp.

## ◆ SumHistory() [1/2]

template<>

Industry::AcceptedHistory SumHistory | ( | std::span< const Industry::AcceptedHistory > | history | ) |

Definition at line 2553 of file industry_cmd.cpp.

## ◆ SumHistory() [2/2]

template<>

Industry::ProducedHistory SumHistory | ( | std::span< const Industry::ProducedHistory > | history | ) |

Definition at line 2544 of file industry_cmd.cpp.

## ◆ TerraformTile_Industry()

static CommandCost TerraformTile_Industry | ( | TileIndex | tile,
|  | DoCommandFlags | flags,
|  | int | z_new,
|  | Slope | tileh_new
| ) |  |
| static

Definition at line 3235 of file industry_cmd.cpp.

## ◆ TileLoop_Industry()

static void TileLoop_Industry | ( | TileIndex | tile | ) |
| static

Definition at line 833 of file industry_cmd.cpp.

## ◆ TileLoopIndustry_BubbleGenerator()

static void TileLoopIndustry_BubbleGenerator | ( | TileIndex | tile | ) |
| static

Definition at line 811 of file industry_cmd.cpp.

## ◆ TransportIndustryGoods()

static bool TransportIndustryGoods | ( | TileIndex | tile | ) |
| static

Move produced cargo from industry to nearby stations.

Parameters

  tile | Industry tile

Returns
  true if any cargo was moved.

Definition at line 525 of file industry_cmd.cpp.

References EconomyIsInRecession(), Industry::exclusive_consumer, Industry::GetByTile(), GetIndustrySpec(), IsValidCargoType(), IndustrySpec::minimal_cargo, Industry::produced, Industry::stations_near, and Industry::type.

## ◆ TrimIndustryAcceptedProduced()

void TrimIndustryAcceptedProduced | ( | Industry * | ind | ) |

Remove unused industry accepted/produced slots – entries after the last slot with valid cargo.

Parameters

  ind | Industry to trim slots.

Definition at line 3292 of file industry_cmd.cpp.

References Industry::accepted, and Industry::produced.

Referenced by AfterLoadGame().

## ◆ UpdateIndustryStatistics()

static void UpdateIndustryStatistics | ( | Industry * | i | ) |
| static

Monthly update of industry statistics.

Parameters

  i | Industry to update.

Definition at line 2565 of file industry_cmd.cpp.

References Industry::accepted, IsValidCargoType(), Industry::last_prod_year, TimerGameEconomy::month, Industry::produced, RotateHistory(), UpdateValidHistory(), Industry::valid_history, and TimerGameEconomy::year.

## ◆ WhoCanServiceIndustry()

int WhoCanServiceIndustry | ( | Industry * | ind | ) |
| static

Compute who can service the industry.

Here, 'can service' means that they have trains and stations close enough to the industry with the right cargo type and the right orders (ie has the technical means).

Parameters

  ind | Industry being investigated.

Returns
  : 0 if nobody can service the industry, 2 if the local company can service the industry, and 1 otherwise (only competitors can service the industry)

Definition at line 2791 of file industry_cmd.cpp.

References _local_company, CanCargoServiceIndustry(), Vehicle::cargo_type, SpecializedStation< Station, false >::Get(), Vehicle::IsFrontEngine(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::Iterate(), SpecializedVehicle< T, Type >::Next(), Vehicle::owner, Industry::stations_near, Transfer, BaseVehicle::type, Unload, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by ChangeIndustryProduction(), CmdIndustrySetProduction(), and ReportNewsProductionChangeIndustry().

## Variable Documentation

## ◆ _check_new_industry_procs

CheckNewIndustryProc* const _check_new_industry_procs[CHECK_END]
| static

Initial value:
= {
CheckNewIndustry_NULL,
CheckNewIndustry_Forest,
CheckNewIndustry_OilRefinery,
CheckNewIndustry_Farm,
CheckNewIndustry_Plantation,
CheckNewIndustry_Water,
CheckNewIndustry_Lumbermill,
CheckNewIndustry_BubbleGen,
CheckNewIndustry_OilRig,
}
CheckNewIndustry_Water
static CommandCost CheckNewIndustry_Water(TileIndex tile)
Check the conditions of CHECK_WATER (Industry should be in the desert).
Definition industry_cmd.cpp:1368
CheckNewIndustry_OilRefinery
static CommandCost CheckNewIndustry_OilRefinery(TileIndex tile)
Check the conditions of CHECK_REFINERY (Industry should be positioned near edge of the map).
Definition industry_cmd.cpp:1309
CheckNewIndustry_BubbleGen
static CommandCost CheckNewIndustry_BubbleGen(TileIndex tile)
Check the conditions of CHECK_BUBBLEGEN (Industry should be in low land).
Definition industry_cmd.cpp:1394
CheckNewIndustry_Farm
static CommandCost CheckNewIndustry_Farm(TileIndex tile)
Check the conditions of CHECK_FARM (Industry should be below snow-line in arctic).
Definition industry_cmd.cpp:1340
CheckNewIndustry_Plantation
static CommandCost CheckNewIndustry_Plantation(TileIndex tile)
Check the conditions of CHECK_PLANTATION (Industry should NOT be in the desert).
Definition industry_cmd.cpp:1355
CheckNewIndustry_Forest
static CommandCost CheckNewIndustry_Forest(TileIndex tile)
Check the conditions of CHECK_FOREST (Industry should be build above snow-line in arctic climate).
Definition industry_cmd.cpp:1271
CheckNewIndustry_OilRig
static CommandCost CheckNewIndustry_OilRig(TileIndex tile)
Check the conditions of CHECK_OIL_RIG (Industries at sea should be positioned near edge of the map).
Definition industry_cmd.cpp:1325
CheckNewIndustry_NULL
static CommandCost CheckNewIndustry_NULL(TileIndex)
Check the conditions of CHECK_NOTHING (Always succeeds).
Definition industry_cmd.cpp:1261
CheckNewIndustry_Lumbermill
static CommandCost CheckNewIndustry_Lumbermill(TileIndex tile)
Check the conditions of CHECK_LUMBERMILL (Industry should be in the rainforest).
Definition industry_cmd.cpp:1381

Check functions for different types of industry.

Definition at line 1410 of file industry_cmd.cpp.

Referenced by CreateNewIndustryHelper().

## ◆ _economy_industries_daily

const IntervalTimer< TimerGameEconomy > _economy_industries_daily({TimerGameEconomy::DAY, TimerGameEconomy::Priority::INDUSTRY},[](auto) { _economy.industry_daily_change_counter+=_economy.industry_daily_increment; uint16_t change_loop=_economy.industry_daily_change_counter > > 16; _economy.industry_daily_change_counter &=0xFFFF;if(change_loop==0) { return; } Backup< CompanyID > cur_company(_current_company, OWNER_NONE); uint perc=3; if((_industry_builder.wanted_inds > > 16) > GetCurrentTotalNumberOfIndustries()) { perc=std::min(9u, perc+(_industry_builder.wanted_inds > > 16) - GetCurrentTotalNumberOfIndustries());} for(uint16_t j=0;j< change_loop;j++) { if(Chance16(perc, 100)) { _industry_builder.TryBuildNewIndustry();} else { Industry *i=Industry::GetRandom();if(i !=nullptr) { ChangeIndustryProduction(i, false);SetWindowDirty(WC_INDUSTRY_VIEW, i->index);} } } cur_company.Restore(); InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE);}) | ( | {TimerGameEconomy::DAY, TimerGameEconomy::Priority::INDUSTRY} | ,
|  | [] (auto) { _economy.industry_daily_change_counter+=_economy.industry_daily_increment;uint16_t change_loop=_economy.industry_daily_change_counter > > 16;_economy.industry_daily_change_counter &=0xFFFF;if(change_loop==0) { return;} Backup< CompanyID > cur_company(_current_company, OWNER_NONE);uint perc=3;if((_industry_builder.wanted_inds > > 16) > GetCurrentTotalNumberOfIndustries()) { perc=std::min(9u, perc+(_industry_builder.wanted_inds > > 16) - GetCurrentTotalNumberOfIndustries());} for(uint16_t j=0;j< change_loop;j++) { if(Chance16(perc, 100)) { _industry_builder.TryBuildNewIndustry();} else { Industry *i=Industry::GetRandom();if(i !=nullptr) { ChangeIndustryProduction(i, false);SetWindowDirty(WC_INDUSTRY_VIEW, i->index);} } } cur_company.Restore();InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE);} |
| ) |  |
| static

Every economy day handler for the industry changes Taking the original map size of 256*256, the number of random changes was always of just one unit.

But it cannot be the same on smaller or bigger maps. That number has to be scaled up or down. For small maps, it implies that less than one change per month is required, while on bigger maps, it would be way more. The daily loop handles those changes.

## ◆ _ignore_industry_restrictions

bool _ignore_industry_restrictions
| extern

Definition at line 61 of file industry_gui.cpp.

## ◆ _industry_builder

IndustryBuildData _industry_builder

In-game manager of industries.

Definition at line 73 of file industry_cmd.cpp.

Referenced by AfterLoadGame(), GenerateIndustries(), ITBLChunkHandler::Load(), and ITBLChunkHandler::Save().

## ◆ _industry_draw_tile_procs

IndustryDrawTileProc* const _industry_draw_tile_procs[5]
| static

Initial value:
= {
IndustryDrawSugarMine,
IndustryDrawToffeeQuarry,
IndustryDrawBubbleGenerator,
IndustryDrawToyFactory,
IndustryDrawCoalPlantSparks,
}

Definition at line 321 of file industry_cmd.cpp.

## ◆ _industry_sound_ctr

uint8_t _industry_sound_ctr
| static

Definition at line 66 of file industry_cmd.cpp.

## ◆ _industry_sound_tile

TileIndex _industry_sound_tile
| static

Definition at line 67 of file industry_cmd.cpp.

## ◆ _industry_specs

IndustrySpec _industry_specs[NUM_INDUSTRYTYPES]

Definition at line 71 of file industry_cmd.cpp.

## ◆ _industry_tile_specs

IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES]

Definition at line 72 of file industry_cmd.cpp.

## ◆ _plantfarmfield_type

const uint8_t _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6}
| static

Definition at line 992 of file industry_cmd.cpp.

## ◆ _tile_type_industry_procs

const TileTypeProcs _tile_type_industry_procs
| extern

Initial value:
= {
DrawTile_Industry,
GetSlopePixelZ_Industry,
ClearTile_Industry,
AddAcceptedCargo_Industry,
GetTileDesc_Industry,
GetTileTrackStatus_Industry,
ClickTile_Industry,
AnimateTile_Industry,
TileLoop_Industry,
ChangeTileOwner_Industry,
nullptr,
nullptr,
GetFoundation_Industry,
TerraformTile_Industry,
nullptr,
}

Definition at line 59 of file landscape.cpp.

## ◆ PERCENT_TRANSPORTED_60

const uint PERCENT_TRANSPORTED_60 = 153
| static

Definition at line 2863 of file industry_cmd.cpp.

## ◆ PERCENT_TRANSPORTED_80

const uint PERCENT_TRANSPORTED_80 = 204
| static

Definition at line 2864 of file industry_cmd.cpp.