OpenTTD Source 20260512-master-g20b387b91f
industrytype.h File Reference

Industry type specs. More...

#include "map_type.h"
#include "slope_type.h"
#include "industry_type.h"
#include "landscape_type.h"
#include "cargo_type.h"
#include "newgrf_animation_type.h"
#include "newgrf_badge_type.h"
#include "newgrf_callbacks.h"
#include "newgrf_commons.h"

Go to the source code of this file.

Data Structures

struct  IndustryTileLayoutTile
 Definition of one tile in an industry tile layout. More...
struct  IndustrySpec
 Defines the data structure for constructing industry. More...
struct  IndustryTileSpec
 Defines the data structure of each individual tile of an industry. More...

Typedefs

using IndustryLifeTypes = EnumBitSet<IndustryLifeType, uint8_t>
using IndustryBehaviours = EnumBitSet<IndustryBehaviour, uint32_t>
using IndustryTileSpecialFlags = EnumBitSet<IndustryTileSpecialFlag, uint8_t>
using IndustryTileLayout = std::vector<IndustryTileLayoutTile>
 A complete tile layout for an industry is a list of tiles.

Enumerations

enum class  IndustryLifeType : uint8_t { Extractive = 0 , Organic = 1 , Processing = 2 }
 Available types of industry lifetimes. More...
enum class  IndustryCheck : uint8_t {
  None , Forest , Refinery , Farm ,
  Plantation , Water , Lumbermill , BubbleGen ,
  OilRig , End
}
 Available procedures to check whether an industry may build at a given location. More...
enum class  IndustryConstructionType : uint8_t { Unknown , Gameplay , MapGeneration , ScenarioEditor }
 How was the industry created. More...
enum class  IndustryBehaviour : uint8_t {
  PlantFields = 0 , CutTrees = 1 , BuiltOnWater = 2 , Town1200More = 3 ,
  OnlyInTown = 4 , OnlyNearTown = 5 , PlantOnBuild = 6 , DontIncrProd = 7 ,
  Before1950 = 8 , After1960 = 9 , AIAirShipRoutes = 10 , AirplaneAttacks = 11 ,
  ChopperAttacks = 12 , CanSubsidence = 13 , ProdMultiHandling = 14 , ProdCallbackRandom = 15 ,
  NoBuildMapCreation = 16 , CanCloseLastInstance = 17 , CargoTypesUnlimited = 18 , NoPaxProdClamp = 19
}
 Various industry behaviours mostly to represent original TTD specialities. More...
enum class  IndustryTileSpecialFlag : uint8_t { NextFrameRandomBits = 0 , AcceptsAllCargo = 1 }
 Flags for miscellaneous industry tile specialities. More...

Functions

const IndustrySpecGetIndustrySpec (IndustryType thistype)
 Array of industries data.
const IndustryTileSpecGetIndustryTileSpec (IndustryGfx gfx)
 Array of industry tiles data.
void ResetIndustries ()
 This function initialize the spec arrays of both industry and industry tiles.
void SortIndustryTypes ()
 Initialize the list of sorted industry types.
IndustryGfx GetTranslatedIndustryTileID (IndustryGfx gfx)
 Do industry gfx ID translation for NewGRFs.

Variables

static constexpr IndustryLifeTypes INDUSTRYLIFE_BLACK_HOLE {}
 Like power plants and banks.
IndustrySpec _industry_specs [NUM_INDUSTRYTYPES]
IndustryTileSpec _industry_tile_specs [NUM_INDUSTRYTILES]
std::array< IndustryType, NUM_INDUSTRYTYPES_sorted_industry_types
 Industry types sorted by name.

Detailed Description

Industry type specs.

Definition in file industrytype.h.

Typedef Documentation

◆ IndustryBehaviours

using IndustryBehaviours = EnumBitSet<IndustryBehaviour, uint32_t>

Definition at line 82 of file industrytype.h.

◆ IndustryLifeTypes

using IndustryLifeTypes = EnumBitSet<IndustryLifeType, uint8_t>

Definition at line 29 of file industrytype.h.

◆ IndustryTileLayout

A complete tile layout for an industry is a list of tiles.

Definition at line 98 of file industrytype.h.

◆ IndustryTileSpecialFlags

using IndustryTileSpecialFlags = EnumBitSet<IndustryTileSpecialFlag, uint8_t>

Definition at line 89 of file industrytype.h.

Enumeration Type Documentation

◆ IndustryBehaviour

enum class IndustryBehaviour : uint8_t
strong

Various industry behaviours mostly to represent original TTD specialities.

Enumerator
PlantFields 

periodically plants fields around itself (temp and arctic farms)

CutTrees 

cuts trees and produce first output cargo from them (lumber mill)

BuiltOnWater 

is built on water (oil rig)

Town1200More 

can only be built in towns larger than 1200 inhabitants (temperate bank)

OnlyInTown 

can only be built in towns (arctic/tropic banks, water tower)

OnlyNearTown 

is always built near towns (toy shop)

PlantOnBuild 

Fields are planted around when built (all farms).

DontIncrProd 

do not increase production (oil wells) in the temperate climate

Before1950 

can only be built before 1950 (oil wells)

After1960 

can only be built after 1960 (oil rigs)

AIAirShipRoutes 

ai will attempt to establish air/ship routes to this industry (oil rig)

AirplaneAttacks 

can be exploded by a military airplane (oil refinery)

ChopperAttacks 

can be exploded by a military helicopter (factory)

CanSubsidence 

can cause a subsidence (coal mine, shaft that collapses)

ProdMultiHandling 

Automatic production multiplier handling.

ProdCallbackRandom 

Production callback needs random bits in var 10.

NoBuildMapCreation 

Do not force one instance of this type to appear on map generation.

CanCloseLastInstance 

Allow closing down the last instance of this type.

CargoTypesUnlimited 

Allow produced/accepted cargoes callbacks to supply more than 2 and 3 types.

NoPaxProdClamp 

Do not clamp production of passengers. (smooth economy only).

Definition at line 59 of file industrytype.h.

◆ IndustryCheck

enum class IndustryCheck : uint8_t
strong

Available procedures to check whether an industry may build at a given location.

See also
CheckNewIndustryProc, _check_new_industry_procs
Enumerator
None 

Always succeeds.

Forest 

Industry should be build above snow-line in arctic climate.

Refinery 

Industry should be positioned near edge of the map.

Farm 

Industry should be below snow-line in arctic.

Plantation 

Industry should NOT be in the desert.

Water 

Industry should be in the desert.

Lumbermill 

Industry should be in the rainforest.

BubbleGen 

Industry should be in low land.

OilRig 

Industries at sea should be positioned near edge of the map.

End 

End marker of the industry check procedures.

Definition at line 37 of file industrytype.h.

◆ IndustryConstructionType

enum class IndustryConstructionType : uint8_t
strong

How was the industry created.

Enumerator
Unknown 

in previous game version or without newindustries activated

Gameplay 

either by user or random creation process

MapGeneration 

during random map creation

ScenarioEditor 

while editing a scenario

Definition at line 51 of file industrytype.h.

◆ IndustryLifeType

enum class IndustryLifeType : uint8_t
strong

Available types of industry lifetimes.

Enumerator
Extractive 

Like mines.

Organic 

Like forests.

Processing 

Like factories.

Definition at line 24 of file industrytype.h.

◆ IndustryTileSpecialFlag

enum class IndustryTileSpecialFlag : uint8_t
strong

Flags for miscellaneous industry tile specialities.

Enumerator
NextFrameRandomBits 

Callback 0x26 needs random bits.

AcceptsAllCargo 

Tile always accepts all cargoes the associated industry accepts.

Definition at line 85 of file industrytype.h.

Function Documentation

◆ GetIndustrySpec()

const IndustrySpec * GetIndustrySpec ( IndustryType thistype)

Array of industries data.

Array of industries data.

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

Parameters
thistypeof 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(), ClearTile_Industry(), CmdBuildIndustry(), CmdIndustrySetProduction(), CMSAMine(), IndustryCargoesWindow::ComputeCargoDisplay(), IndustryCargoesWindow::ComputeIndustryDisplay(), CargoesRow::ConnectIndustryAccepted(), CargoesRow::ConnectIndustryProduced(), IndustryCargoesWindow::CountMatchingAcceptingIndustries(), IndustryCargoesWindow::CountMatchingProducingIndustries(), CreateNewIndustry(), CreateNewIndustryHelper(), Disaster_Airplane_Init(), 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(), GetTileDesc_Industry(), GetTileDesc_Station(), 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(), BuildIndustryWindow::UpdateWidgetSize(), and Industry::~Industry().

◆ GetIndustryTileSpec()

const IndustryTileSpec * GetIndustryTileSpec ( IndustryGfx gfx)

◆ GetTranslatedIndustryTileID()

IndustryGfx GetTranslatedIndustryTileID ( IndustryGfx gfx)
inline

Do industry gfx ID translation for NewGRFs.

Parameters
gfxthe type to get the override for.
Returns
the gfx to actually work with.

Definition at line 192 of file industrytype.h.

References IndustryTileSpec::grf_prop, INVALID_INDUSTRYTILE, NUM_INDUSTRYTILES, and SubstituteGRFFileProps::override_id.

Referenced by CheckIfIndustryTilesAreFree(), CheckIfIndustryTileSlopes(), DoCreateNewIndustry(), and GetIndustryGfx().

◆ 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 _origin_industry_specs, and _settings_game.

Referenced by ResetNewGRFData().

◆ SortIndustryTypes()

void SortIndustryTypes ( )

Initialize the list of sorted industry types.

Definition at line 251 of file industry_gui.cpp.

References _sorted_industry_types, IndustryTypeNameSorter(), and NUM_INDUSTRYTYPES.

Referenced by AfterLoadGRFs(), and ReadLanguagePack().

Variable Documentation

◆ _industry_specs

IndustrySpec _industry_specs[NUM_INDUSTRYTYPES]
extern

Definition at line 71 of file industry_cmd.cpp.

◆ _industry_tile_specs

IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES]
extern

Definition at line 72 of file industry_cmd.cpp.

◆ _sorted_industry_types

◆ INDUSTRYLIFE_BLACK_HOLE

IndustryLifeTypes INDUSTRYLIFE_BLACK_HOLE {}
staticconstexpr

Like power plants and banks.

Definition at line 31 of file industrytype.h.

Referenced by ChangeIndustryProduction().