OpenTTD Source: src/industry_cmd.h File Reference

OpenTTD Source 15.3

Functions
industry_cmd.h File Reference

Command definitions related to industries. More...

`#include "command_type.h"`
`#include "company_type.h"`
`#include "industry_type.h"`
`#include "industry.h"`

Go to the source code of this file.

## Functions
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 | 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.
CommandCost | CmdIndustrySetProduction (DoCommandFlags flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const EncodedString &text)
| Set industry production.

## Detailed Description

Command definitions related to industries.

Definition in file industry_cmd.h.

## Function Documentation

## ◆ 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.