OpenTTD GameScript API  20241118-master-gb8f3d0dd68
Public Types | Static Public Member Functions
GSIndustryType Class Reference

Class that handles all industry-type related functions. More...

Inheritance diagram for GSIndustryType:

Public Types

enum  SpecialIndustryType {
  INDUSTRYTYPE_UNKNOWN ,
  INDUSTRYTYPE_TOWN
}
 Special IndustryTypes. More...
 

Static Public Member Functions

static bool IsValidIndustryType (IndustryType industry_type)
 Checks whether the given industry-type is valid. More...
 
static string GetName (IndustryType industry_type)
 Get the name of an industry-type. More...
 
static GSListGetProducedCargo (IndustryType industry_type)
 Get a list of CargoID possible produced by this industry-type. More...
 
static GSListGetAcceptedCargo (IndustryType industry_type)
 Get a list of CargoID accepted by this industry-type. More...
 
static bool IsRawIndustry (IndustryType industry_type)
 Is this industry type a raw industry? Raw industries usually produce cargo without any prerequisites. More...
 
static bool IsProcessingIndustry (IndustryType industry_type)
 Is this industry type a processing industry? Processing industries usually produce cargo when delivered with input cargo. More...
 
static bool ProductionCanIncrease (IndustryType industry_type)
 Can the production of this industry increase? More...
 
static Money GetConstructionCost (IndustryType industry_type)
 Get the cost for building this industry-type. More...
 
static bool CanBuildIndustry (IndustryType industry_type)
 Can you build this type of industry? More...
 
static bool CanProspectIndustry (IndustryType industry_type)
 Can you prospect this type of industry? More...
 
static bool BuildIndustry (IndustryType industry_type, TileIndex tile)
 Build an industry of the specified type. More...
 
static bool ProspectIndustry (IndustryType industry_type)
 Prospect an industry of this type. More...
 
static bool IsBuiltOnWater (IndustryType industry_type)
 Is this type of industry built on water. More...
 
static bool HasHeliport (IndustryType industry_type)
 Does this type of industry have a heliport? More...
 
static bool HasDock (IndustryType industry_type)
 Does this type of industry have a dock? More...
 
static IndustryType ResolveNewGRFID (int grfid, int grf_local_id)
 Get a specific industry-type from a grf. More...
 

Detailed Description

Class that handles all industry-type related functions.

Member Enumeration Documentation

◆ SpecialIndustryType

Special IndustryTypes.

Enumerator
INDUSTRYTYPE_UNKNOWN 

Unknown/unspecific industrytype. (Usable for GSRail::BuildNewGRFRailStation())

INDUSTRYTYPE_TOWN 

No industry, but town. (Usable for GSRail::BuildNewGRFRailStation())

Member Function Documentation

◆ BuildIndustry()

static bool GSIndustryType::BuildIndustry ( IndustryType  industry_type,
TileIndex  tile 
)
static

Build an industry of the specified type.

Parameters
industry_typeThe type of the industry to build.
tileThe tile to build the industry on.
Precondition
CanBuildIndustry(industry_type).
Returns
True if the industry was successfully build.

◆ CanBuildIndustry()

static bool GSIndustryType::CanBuildIndustry ( IndustryType  industry_type)
static

Can you build this type of industry?

Parameters
industry_typeThe type of the industry.
Precondition
IsValidIndustryType(industry_type).
Returns
True if you can build this type of industry at locations of your choice.
Note
When GSCompanyMode::IsDeity, this method returns false if you can only prospect this type of industry, or not build it at all.
When GSCompanyMode::IsDeity, the script can build as long as the industry type can be built. (a NewGRF can for example reject construction based on current year)

◆ CanProspectIndustry()

static bool GSIndustryType::CanProspectIndustry ( IndustryType  industry_type)
static

Can you prospect this type of industry?

Parameters
industry_typeThe type of the industry.
Precondition
IsValidIndustryType(industry_type).
Returns
True if you can prospect this type of industry.
Note
When GSCompanyMode::IsDeity, and if the setting "Manual primary industry construction method" is set to either "None" or "as other industries" this function always returns false.
When GSCompanyMode::IsDeity, the script can prospect as long as the industry type can be built. (a NewGRF can for example reject construction based on current year)

◆ GetAcceptedCargo()

static GSList* GSIndustryType::GetAcceptedCargo ( IndustryType  industry_type)
static

Get a list of CargoID accepted by this industry-type.

Warning
This function only returns the default cargoes of the industry type. Industries can specify new cargotypes on construction.
Parameters
industry_typeThe type to get the CargoIDs for.
Precondition
IsValidIndustryType(industry_type).
Returns
The CargoIDs of all cargotypes this industry accepts.

◆ GetConstructionCost()

static Money GSIndustryType::GetConstructionCost ( IndustryType  industry_type)
static

Get the cost for building this industry-type.

Parameters
industry_typeThe type of the industry.
Precondition
IsValidIndustryType(industry_type).
Returns
The cost for building this industry-type.

◆ GetName()

static string GSIndustryType::GetName ( IndustryType  industry_type)
static

Get the name of an industry-type.

Parameters
industry_typeThe type to get the name for.
Precondition
IsValidIndustryType(industry_type).
Returns
The name of an industry.

◆ GetProducedCargo()

static GSList* GSIndustryType::GetProducedCargo ( IndustryType  industry_type)
static

Get a list of CargoID possible produced by this industry-type.

Warning
This function only returns the default cargoes of the industry type. Industries can specify new cargotypes on construction.
Parameters
industry_typeThe type to get the CargoIDs for.
Precondition
IsValidIndustryType(industry_type).
Returns
The CargoIDs of all cargotypes this industry could produce.

◆ HasDock()

static bool GSIndustryType::HasDock ( IndustryType  industry_type)
static

Does this type of industry have a dock?

Parameters
industry_typeThe type of the industry.
Precondition
IsValidIndustryType(industry_type).
Returns
True when this type has a dock.

◆ HasHeliport()

static bool GSIndustryType::HasHeliport ( IndustryType  industry_type)
static

Does this type of industry have a heliport?

Parameters
industry_typeThe type of the industry.
Precondition
IsValidIndustryType(industry_type).
Returns
True when this type has a heliport.

◆ IsBuiltOnWater()

static bool GSIndustryType::IsBuiltOnWater ( IndustryType  industry_type)
static

Is this type of industry built on water.

Parameters
industry_typeThe type of the industry.
Precondition
IsValidIndustryType(industry_type).
Returns
True when this type is built on water.

◆ IsProcessingIndustry()

static bool GSIndustryType::IsProcessingIndustry ( IndustryType  industry_type)
static

Is this industry type a processing industry? Processing industries usually produce cargo when delivered with input cargo.

("Usually" means that advanced NewGRF industry concepts might not fit the "raw"/"processing" classification, so it's up to the interpretation of the NewGRF author.)

Parameters
industry_typeThe type of the industry.
Precondition
IsValidIndustryType(industry_type).
Returns
True if it is a processing industry.
Note
Industries might be neither raw nor processing. This is usually the case for industries which produce nothing (e.g. power plants), but also for weird industries like temperate banks and tropic lumber mills.

◆ IsRawIndustry()

static bool GSIndustryType::IsRawIndustry ( IndustryType  industry_type)
static

Is this industry type a raw industry? Raw industries usually produce cargo without any prerequisites.

("Usually" means that advanced NewGRF industry concepts might not fit the "raw"/"processing" classification, so it's up to the interpretation of the NewGRF author.)

Parameters
industry_typeThe type of the industry.
Precondition
IsValidIndustryType(industry_type).
Returns
True if it should be handled as a raw industry.
Note
Industries might be neither raw nor processing. This is usually the case for industries which produce nothing (e.g. power plants), but also for weird industries like temperate banks and tropic lumber mills.

◆ IsValidIndustryType()

static bool GSIndustryType::IsValidIndustryType ( IndustryType  industry_type)
static

Checks whether the given industry-type is valid.

Parameters
industry_typeThe type check.
Returns
True if and only if the industry-type is valid.

◆ ProductionCanIncrease()

static bool GSIndustryType::ProductionCanIncrease ( IndustryType  industry_type)
static

Can the production of this industry increase?

Parameters
industry_typeThe type of the industry.
Precondition
IsValidIndustryType(industry_type).
Returns
True if the production of this industry can increase.

◆ ProspectIndustry()

static bool GSIndustryType::ProspectIndustry ( IndustryType  industry_type)
static

Prospect an industry of this type.

Prospecting an industries let the game try to create an industry on a random place on the map.

Parameters
industry_typeThe type of the industry.
Precondition
CanProspectIndustry(industry_type).
Returns
True if no error occurred while trying to prospect.
Note
Even if true is returned there is no guarantee a new industry is build.
If true is returned the money is paid, whether a new industry was build or not.
When GSCompanyMode::IsDeity, prospection will not fail due to the general chance that prospection may fail. However prospection can still fail if OpenTTD is unable to find a suitable location to place the industry.

◆ ResolveNewGRFID()

static IndustryType GSIndustryType::ResolveNewGRFID ( int  grfid,
int  grf_local_id 
)
static

Get a specific industry-type from a grf.

Parameters
grfidThe ID of the NewGRF.
grf_local_idThe ID of the industry, local to the NewGRF.
Precondition
0x00 <= grf_local_id < NUM_INDUSTRYTYPES_PER_GRF.
Returns
the industry-type ID, local to the current game (this diverges from the grf_local_id).