Data Structures | Enumerations | Functions | Variables

# 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_commons.h"`

Go to the source code of this file.

## Data Structures
struct | IndustryTileTable
struct | IndustrySpec
| Defines the data structure for constructing industry. More...
struct | IndustryTileSpec
| Defines the data structure of each individual tile of an industry. More...
## Enumerations
enum | IndustryCleanupType { CLEAN_RANDOMSOUNDS, CLEAN_TILELAYOUT }
enum | IndustryLifeType { INDUSTRYLIFE_BLACK_HOLE = 0, INDUSTRYLIFE_EXTRACTIVE = 1 << 0, INDUSTRYLIFE_ORGANIC = 1 << 1, INDUSTRYLIFE_PROCESSING = 1 << 2 }
| Available types of industry lifetimes. More...
enum | CheckProc { CHECK_NOTHING, CHECK_FOREST, CHECK_REFINERY, CHECK_FARM, CHECK_PLANTATION, CHECK_WATER, CHECK_LUMBERMILL, CHECK_BUBBLEGEN, CHECK_OIL_RIG, CHECK_END }
| Available procedures to check whether an industry may build at a given location. More...
enum | IndustryConstructionType { ICT_UNKNOWN, ICT_NORMAL_GAMEPLAY, ICT_MAP_GENERATION, ICT_SCENARIO_EDITOR }
| How was the industry created. More...
enum | IndustryBehaviour { INDUSTRYBEH_NONE = 0, INDUSTRYBEH_PLANT_FIELDS = 1 << 0, INDUSTRYBEH_CUT_TREES = 1 << 1, INDUSTRYBEH_BUILT_ONWATER = 1 << 2, INDUSTRYBEH_TOWN1200_MORE = 1 << 3, INDUSTRYBEH_ONLY_INTOWN = 1 << 4, INDUSTRYBEH_ONLY_NEARTOWN = 1 << 5, INDUSTRYBEH_PLANT_ON_BUILT = 1 << 6, INDUSTRYBEH_DONT_INCR_PROD = 1 << 7, INDUSTRYBEH_BEFORE_1950 = 1 << 8, INDUSTRYBEH_AFTER_1960 = 1 << 9, INDUSTRYBEH_AI_AIRSHIP_ROUTES = 1 << 10, INDUSTRYBEH_AIRPLANE_ATTACKS = 1 << 11, INDUSTRYBEH_CHOPPER_ATTACKS = 1 << 12, INDUSTRYBEH_CAN_SUBSIDENCE = 1 << 13, INDUSTRYBEH_PROD_MULTI_HNDLING = 1 << 14, INDUSTRYBEH_PRODCALLBACK_RANDOM = 1 << 15, INDUSTRYBEH_NOBUILT_MAPCREATION = 1 << 16, INDUSTRYBEH_CANCLOSE_LASTINSTANCE = 1 << 17 }
| Various industry behaviours mostly to represent original TTD specialities. More...
enum | IndustryTileSpecialFlags { INDTILE_SPECIAL_NONE = 0, INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS = 1 << 0 }
| Flags for miscellaneous industry tile specialities. More...
## Functions
const IndustrySpec * | GetIndustrySpec (IndustryType thistype)
| Array of industries data.
const IndustryTileSpec * | GetIndustryTileSpec (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.
static IndustryGfx | GetTranslatedIndustryTileID (IndustryGfx gfx)
| Do industry gfx ID translation for NewGRFs.
## Variables
IndustrySpec | _industry_specs [NUM_INDUSTRYTYPES]
IndustryTileSpec | _industry_tile_specs [NUM_INDUSTRYTILES]
IndustryType | _sorted_industry_types [NUM_INDUSTRYTYPES]
| Industry types sorted by name.
static const uint8 | IT_INVALID = 255

## Detailed Description

Industry type specs.

Definition in file industrytype.h.

## Enumeration Type Documentation

enum CheckProc

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

See also:
  CheckNewIndustryProc, _check_new_industry_procs[]

Enumerator:

  CHECK_NOTHING | Always succeeds.
  CHECK_FOREST | Industry should be build above snow-line in arctic climate.
  CHECK_REFINERY | Industry should be positioned near edge of the map.
  CHECK_FARM | Industry should be below snow-line in arctic.
  CHECK_PLANTATION | Industry should NOT be in the desert.
  CHECK_WATER | Industry should be in the desert.
  CHECK_LUMBERMILL | Industry should be in the rain forest.
  CHECK_BUBBLEGEN | Industry should be in low land.
  CHECK_OIL_RIG | Industries at sea should be positioned near edge of the map.
  CHECK_END | End marker of the industry check procedures.

Definition at line 40 of file industrytype.h.

enum IndustryBehaviour

Various industry behaviours mostly to represent original TTD specialities.

Enumerator:

  INDUSTRYBEH_PLANT_FIELDS | periodically plants fields around itself (temp and arctic farms)
  INDUSTRYBEH_CUT_TREES | cuts trees and produce first output cargo from them (lumber mill)
  INDUSTRYBEH_BUILT_ONWATER | is built on water (oil rig)
  INDUSTRYBEH_TOWN1200_MORE | can only be built in towns larger than 1200 inhabitants (temperate bank)
  INDUSTRYBEH_ONLY_INTOWN | can only be built in towns (arctic/tropic banks, water tower)
  INDUSTRYBEH_ONLY_NEARTOWN | is always built near towns (toy shop)
  INDUSTRYBEH_PLANT_ON_BUILT | Fields are planted around when built (all farms).
  INDUSTRYBEH_DONT_INCR_PROD | do not increase production (oil wells) in the temperate climate
  INDUSTRYBEH_BEFORE_1950 | can only be built before 1950 (oil wells)
  INDUSTRYBEH_AFTER_1960 | can only be built after 1960 (oil rigs)
  INDUSTRYBEH_AI_AIRSHIP_ROUTES | ai will attempt to establish air/ship routes to this industry (oil rig)
  INDUSTRYBEH_AIRPLANE_ATTACKS | can be exploded by a military airplane (oil refinery)
  INDUSTRYBEH_CHOPPER_ATTACKS | can be exploded by a military helicopter (factory)
  INDUSTRYBEH_CAN_SUBSIDENCE | can cause a subsidence (coal mine, shaft that collapses)
  INDUSTRYBEH_PROD_MULTI_HNDLING | Automatic production multiplier handling.
  INDUSTRYBEH_PRODCALLBACK_RANDOM | Production callback needs random bits in var 10.
  INDUSTRYBEH_NOBUILT_MAPCREATION | Do not force one instance of this type to appear on map generation.
  INDUSTRYBEH_CANCLOSE_LASTINSTANCE | Allow closing down the last instance of this type.

Definition at line 62 of file industrytype.h.

enum IndustryCleanupType

Enumerator:

  CLEAN_RANDOMSOUNDS | Free the dynamically allocated sounds table.
  CLEAN_TILELAYOUT | Free the dynamically allocated tile layout structure.

Definition at line 23 of file industrytype.h.

enum IndustryConstructionType

How was the industry created.

Enumerator:

  ICT_UNKNOWN | in previous game version or without newindustries activated
  ICT_NORMAL_GAMEPLAY | either by user or random creation process
  ICT_MAP_GENERATION | during random map creation
  ICT_SCENARIO_EDITOR | while editing a scenario

Definition at line 54 of file industrytype.h.

enum IndustryLifeType

Available types of industry lifetimes.

Enumerator:

  INDUSTRYLIFE_BLACK_HOLE | Like power plants and banks.
  INDUSTRYLIFE_EXTRACTIVE | Like mines.
  INDUSTRYLIFE_ORGANIC | Like forests.
  INDUSTRYLIFE_PROCESSING | Like factories.

Definition at line 29 of file industrytype.h.

enum IndustryTileSpecialFlags

Flags for miscellaneous industry tile specialities.

Enumerator:

  INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS | Callback 0x26 needs random bits.

Definition at line 87 of file industrytype.h.

## Function Documentation

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:

  | 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 113 of file industry_cmd.cpp.

References NUM_INDUSTRYTYPES.

Referenced by IndustryOverrideManager::AddEntityID(), AdvertiseIndustryOpening(), AfterLoadGame(), BuildIndustriesLegend(), CcBuildIndustry(), ChangeIndustryProduction(), CheckIfCallBackAllowsCreation(), CheckIfFarEnoughFromConflictingIndustry(), CheckIfIndustryIsAllowed(), CheckIfIndustryTilesAreFree(), CheckIndustryCloseDownProtection(), CmdBuildIndustry(), 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(), FindNearIndustryName(), FormatString(), GetAiPurchaseCallbackResult(), GetCountAndDistanceOfClosestInstance(), GetGrffile(), NIHIndustry::GetGRFID(), GetIndustryCallback(), GetIndustryGamePlayProbability(), GetIndustryProbabilityCallback(), IndustryDirectoryWindow::GetIndustryString(), GetScaledIndustryGenerationProbability(), GetSmallMapIndustriesPixels(), NIHIndustry::GetSpec(), IndustriesScopeResolver::GetVariable(), IndustryProductionCallback(), IndustryTemporarilyRefusesCargo(), IndustryTypeNameSorter(), NIHIndustry::IsInspectable(), IsTileForestIndustry(), IndustryCargoesWindow::OnClick(), BuildIndustryWindow::OnClick(), IndustryCargoesWindow::OnInit(), IndustryViewWindow::OnInvalidateData(), BuildIndustryWindow::OnInvalidateData(), BuildIndustryWindow::OnPlaceObject(), BuildIndustryWindow::OnTick(), Industry::RecomputeProductionMultipliers(), IndustryCargoesWindow::SetStringParameters(), BuildIndustryWindow::SetStringParameters(), ShowIndustryCargoesWindow(), IndustriesScopeResolver::StorePSA(), TriggerIndustryProduction(), and BuildIndustryWindow::UpdateWidgetSize().

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

Array of industry tiles data.

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 127 of file industry_cmd.cpp.

References INVALID_INDUSTRYTILE.

Referenced by CheckIfIndustryTilesAreFree(), DoCreateNewIndustry(), DoTriggerIndustryTile(), NIHIndustryTile::GetGRFID(), GetIndTileGrffile(), GetIndustryIDAtOffset(), NIHIndustryTile::GetSpec(), and NIHIndustryTile::IsInspectable().

static IndustryGfx GetTranslatedIndustryTileID | ( | IndustryGfx | gfx | ) | `[inline, static]`

Do industry gfx ID translation for NewGRFs.

Parameters:

  | gfx | the type to get the override for.

Returns:
  the gfx to actually work with.

Definition at line 186 of file industrytype.h.

References IndustryTileSpec::grf_prop, INVALID_INDUSTRYTILE, and GRFFileProps::override.

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

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 69 of file industry_cmd.cpp.

References _settings_game, IndustrySpec::enabled, GameSettings::game_creation, HasBit(), GameCreationSettings::landscape, NEW_INDUSTRYOFFSET, and OverrideManagerBase::ResetOverride().

Referenced by ResetNewGRFData().