OpenTTD Source  20240919-master-gdf0233f4c2
industry.h File Reference
#include "newgrf_storage.h"
#include "subsidy_type.h"
#include "industry_map.h"
#include "industrytype.h"
#include "tilearea_type.h"
#include "station_base.h"
#include "timer/timer_game_calendar.h"
#include "timer/timer_game_economy.h"

Go to the source code of this file.

Data Structures

struct  Industry
 Defines the internal data of a functional industry. More...
 
struct  Industry::ProducedHistory
 
struct  Industry::ProducedCargo
 
struct  Industry::AcceptedCargo
 
struct  IndustryTypeBuildData
 Data for managing the number of industries of a single industry type. More...
 
struct  IndustryBuildData
 Data for managing the number and type of industries in the game. More...
 

Typedefs

typedef Pool< Industry, IndustryID, 64, 64000 > IndustryPool
 

Enumerations

enum  ProductionLevels { PRODLEVEL_CLOSURE = 0x00, PRODLEVEL_MINIMUM = 0x04, PRODLEVEL_DEFAULT = 0x10, PRODLEVEL_MAXIMUM = 0x80 }
 Production level maximum, minimum and default values. More...
 
enum  IndustryControlFlags : uint8_t {
  INDCTL_NONE = 0, INDCTL_NO_PRODUCTION_DECREASE = 1 << 0, INDCTL_NO_PRODUCTION_INCREASE = 1 << 1, INDCTL_NO_CLOSURE = 1 << 2,
  INDCTL_EXTERNAL_PROD_LEVEL = 1 << 3, INDCTL_MASK = INDCTL_NO_PRODUCTION_DECREASE | INDCTL_NO_PRODUCTION_INCREASE | INDCTL_NO_CLOSURE | INDCTL_EXTERNAL_PROD_LEVEL
}
 Flags to control/override the behaviour of an industry. More...
 
enum  IndustryDirectoryInvalidateWindowData { IDIWD_FORCE_REBUILD, IDIWD_PRODUCTION_CHANGE, IDIWD_FORCE_RESORT }
 Special values for the industry list window for the data parameter of InvalidateWindowData.
 

Functions

 DECLARE_ENUM_AS_BIT_SET (IndustryControlFlags)
 
void ClearAllIndustryCachedNames ()
 
void PlantRandomFarmField (const Industry *i)
 
void ReleaseDisastersTargetingIndustry (IndustryID)
 Marks all disasters targeting this industry in such a way they won't call Industry::Get(v->dest_tile) on invalid industry anymore. More...
 
bool IsTileForestIndustry (TileIndex tile)
 Check whether the tile is a forest. More...
 
void TrimIndustryAcceptedProduced (Industry *ind)
 Remove unused industry accepted/produced slots – entries after the last slot with valid cargo. More...
 

Variables

IndustryPool _industry_pool
 
static const TimerGameEconomy::Year PROCESSING_INDUSTRY_ABANDONMENT_YEARS = 5
 If a processing industry doesn't produce for this many consecutive economy years, it may close.
 
static const int THIS_MONTH = 0
 
static const int LAST_MONTH = 1
 
IndustryBuildData _industry_builder
 In-game manager of industries.
 

Detailed Description

Base of all industries.

Definition in file industry.h.

Enumeration Type Documentation

◆ IndustryControlFlags

enum IndustryControlFlags : uint8_t

Flags to control/override the behaviour of an industry.

These flags are controlled by game scripts.

Enumerator
INDCTL_NONE 

No flags in effect.

INDCTL_NO_PRODUCTION_DECREASE 

When industry production change is evaluated, rolls to decrease are ignored.

INDCTL_NO_PRODUCTION_INCREASE 

When industry production change is evaluated, rolls to increase are ignored.

INDCTL_NO_CLOSURE 

Industry can not close regardless of production level or time since last delivery.

This does not prevent a closure already announced.

INDCTL_EXTERNAL_PROD_LEVEL 

Indicates that the production level of the industry is externally controlled.

INDCTL_MASK 

Mask of all flags set.

Definition at line 44 of file industry.h.

◆ ProductionLevels

Production level maximum, minimum and default values.

It is not a value been really used in order to change, but rather an indicator of how the industry is behaving.

Enumerator
PRODLEVEL_CLOSURE 

signal set to actually close the industry

PRODLEVEL_MINIMUM 

below this level, the industry is set to be closing

PRODLEVEL_DEFAULT 

default level set when the industry is created

PRODLEVEL_MAXIMUM 

the industry is running at full speed

Definition at line 33 of file industry.h.

Function Documentation

◆ IsTileForestIndustry()

bool IsTileForestIndustry ( TileIndex  tile)

Check whether the tile is a forest.

Parameters
tilethe tile to investigate.
Returns
true if and only if the tile is a forest

Definition at line 975 of file industry_cmd.cpp.

References Industry::GetByTile(), GetIndustrySpec(), INDUSTRYLIFE_ORGANIC, IsTileType(), IndustrySpec::life_type, MP_INDUSTRY, Industry::produced, and Industry::type.

◆ ReleaseDisastersTargetingIndustry()

void ReleaseDisastersTargetingIndustry ( IndustryID  i)

Marks all disasters targeting this industry in such a way they won't call Industry::Get(v->dest_tile) on invalid industry anymore.

Parameters
ideleted industry

Definition at line 966 of file disaster_vehicle.cpp.

References Vehicle::dest_tile, SpecializedVehicle< DisasterVehicle, VEH_DISASTER >::Iterate(), ST_AIRPLANE, ST_HELICOPTER, DisasterVehicle::state, and Vehicle::subtype.

◆ TrimIndustryAcceptedProduced()

void TrimIndustryAcceptedProduced ( Industry ind)

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

Parameters
indIndustry to trim slots.

Definition at line 3230 of file industry_cmd.cpp.

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