Defines the internal data of a functional industry. More...
#include <industry.h>
Public Types | |
typedef PersistentStorageArray < int32, 16 > | PersistentStorage |
typedef bool(* | EnumIndustryProc )(const Industry *ind, void *data) |
Callback function for Industry::GetRandom. | |
Public Member Functions | |
Industry (TileIndex tile=INVALID_TILE) | |
void | RecomputeProductionMultipliers () |
Recompute production_rate for current prod_level. | |
SourceType | GetType () const |
Get the type of this entity. | |
SourceID | GetID () const |
Get the source ID corresponding with this entity. | |
bool | AcceptsCargo (CargoID cid) const |
Is this cargo accepted? | |
bool | SuppliesCargo (CargoID cid) const |
Is this cargo produced? | |
uint | GetDestinationWeight (CargoID cid, byte weight_mod) const |
Get the link weight for this as a destination for a specific cargo. | |
TileArea | GetTileForDestination (CargoID cid) |
Get a random destination tile index for this cargo. | |
Static Public Member Functions | |
static FORCEINLINE Industry * | GetByTile (TileIndex tile) |
Get the industry of the given tile. | |
static Industry * | GetRandom (EnumIndustryProc enum_proc=NULL, IndustryID skip=INVALID_INDUSTRY, void *data=NULL) |
Return a random industry that statisfies some criteria specified with a callback function. | |
static void | PostDestructor (size_t index) |
Invalidating some stuff after removing item from the pool. | |
static void | IncIndustryTypeCount (IndustryType type) |
Increment the count of industries for this type. | |
static void | DecIndustryTypeCount (IndustryType type) |
Decrement the count of industries for this type. | |
static uint16 | GetIndustryTypeCount (IndustryType type) |
Get the count of industries for this type. | |
static void | ResetIndustryCounts () |
Resets industry counts. | |
Data Fields | |
TileArea | location |
Location of the industry. | |
const Town * | town |
Nearest town. | |
CargoID | produced_cargo [2] |
2 production cargo slots | |
uint16 | produced_cargo_waiting [2] |
amount of cargo produced per cargo | |
uint16 | incoming_cargo_waiting [3] |
incoming cargo waiting to be processed | |
byte | production_rate [2] |
production rate for each cargo | |
byte | prod_level |
general production level | |
CargoID | accepts_cargo [3] |
3 input cargo slots | |
uint32 | produced_accepted_mask |
Bit mask of all cargos that are always accepted and also produced. | |
uint16 | this_month_production [2] |
stats of this month's production per cargo | |
uint16 | this_month_transported [2] |
stats of this month's transport per cargo | |
byte | last_month_pct_transported [2] |
percentage transported per cargo in the last full month | |
uint16 | last_month_production [2] |
total units produced per cargo in the last full month | |
uint16 | last_month_transported [2] |
total units transported per cargo in the last full month | |
uint16 | average_production [2] |
average production during the last months | |
uint16 | counter |
used for animation and/or production (if available cargo) | |
IndustryType | type |
type of industry. | |
OwnerByte | owner |
owner of the industry. Which SHOULD always be (imho) OWNER_NONE | |
byte | random_colour |
randomized colour of the industry, for display purpose | |
Year | last_prod_year |
last year of production | |
byte | was_cargo_delivered |
flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry | |
PartOfSubsidyByte | part_of_subsidy |
NOSAVE: is this industry a source/destination of a subsidy? | |
OwnerByte | founder |
Founder of the industry. | |
Date | construction_date |
Date of the construction of the industry. | |
uint8 | construction_type |
Way the industry was constructed (. | |
Date | last_cargo_accepted_at |
Last day cargo was accepted by this industry. | |
byte | selected_layout |
Which tile layout was used when creating the industry. | |
byte | random_triggers |
Triggers for the random. | |
uint16 | random |
Random value used for randomisation of all kinds of things. | |
PersistentStorage | psa |
Persistent storage for NewGRF industries. | |
Static Protected Attributes | |
static uint16 | counts [NUM_INDUSTRYTYPES] |
Number of industries per type ingame. |
Defines the internal data of a functional industry.
Definition at line 41 of file industry.h.
typedef bool(* Industry::EnumIndustryProc)(const Industry *ind, void *data) |
Callback function for Industry::GetRandom.
Definition at line 132 of file industry.h.
static void Industry::DecIndustryTypeCount | ( | IndustryType | type | ) | [inline, static] |
Decrement the count of industries for this type.
type | IndustryType to decrement |
Definition at line 153 of file industry.h.
References counts, and NUM_INDUSTRYTYPES.
Get the industry of the given tile.
tile | the tile to get the industry from |
Definition at line 126 of file industry.h.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::Get(), and GetIndustryIndex().
Referenced by CmdDeleteTown(), CMSAForest(), CMSAMine(), GetIndustryTileResolver(), GetIndustryType(), GetSmallMapIndustriesPixels(), GetSmallMapVegetationPixels(), and IndustryGetVariable().
uint Industry::GetDestinationWeight | ( | CargoID | cid, | |
byte | weight_mod | |||
) | const [virtual] |
Get the link weight for this as a destination for a specific cargo.
Implements CargoSourceSink.
Definition at line 581 of file cargodest.cpp.
References _settings_game, accepts_cargo, average_production, EconomySettings::cargodest, ClampU(), GameSettings::economy, incoming_cargo_waiting, lengthof, MAX_IND_STOCKPILE, CargodestSettings::min_weight_ind, CargodestSettings::weight_scale_ind, WEIGHT_SCALE_IND_PILE, and WEIGHT_SCALE_IND_PROD.
SourceID Industry::GetID | ( | ) | const [inline, virtual] |
Get the source ID corresponding with this entity.
Implements CargoSourceSink.
Definition at line 90 of file industry.h.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::index.
static uint16 Industry::GetIndustryTypeCount | ( | IndustryType | type | ) | [inline, static] |
Get the count of industries for this type.
type | IndustryType to query |
Definition at line 164 of file industry.h.
References counts, and NUM_INDUSTRYTYPES.
Referenced by CheckIndustryCloseDownProtection(), SmallMapWindow::DrawWidget(), GetCountAndDistanceOfClosestInstance(), GetCurrentTotalNumberOfIndustries(), and IndustryBuildData::TryBuildNewIndustry().
Industry * Industry::GetRandom | ( | EnumIndustryProc | enum_proc = NULL , |
|
IndustryID | skip = INVALID_INDUSTRY , |
|||
void * | data = NULL | |||
) | [static] |
Return a random industry that statisfies some criteria specified with a callback function.
enum_proc | Callback function. Return true for a matching industry and false to continue iterating. | |
skip | Skip over this industry id when searching. | |
data | Optional data passed to the callback function. |
Definition at line 200 of file industry_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::GetPoolSize(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::IsValidID(), and MAX_UVALUE.
Referenced by FindIndustryDestination(), FindSupplySource(), IndustryDailyLoop(), and MoveCargoWithDestinationToStationWorker().
Get a random destination tile index for this cargo.
Implements CargoSourceSink.
Definition at line 115 of file industry.h.
References location.
SourceType Industry::GetType | ( | ) | const [inline, virtual] |
Get the type of this entity.
Implements CargoSourceSink.
Definition at line 85 of file industry.h.
References ST_INDUSTRY.
static void Industry::IncIndustryTypeCount | ( | IndustryType | type | ) | [inline, static] |
Increment the count of industries for this type.
type | IndustryType to increment |
Definition at line 142 of file industry.h.
References counts, and NUM_INDUSTRYTYPES.
Referenced by DoCreateNewIndustry().
void Industry::PostDestructor | ( | size_t | index | ) | [static] |
Invalidating some stuff after removing item from the pool.
index | index of deleted item |
Reimplemented from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >.
Definition at line 184 of file industry_cmd.cpp.
References InvalidateWindowData(), and Station::RecomputeIndustriesNearForAll().
void Industry::RecomputeProductionMultipliers | ( | ) |
Recompute production_rate for current prod_level.
This function is only valid when not using smooth economy.
Definition at line 2137 of file industry_cmd.cpp.
References CeilDiv(), GetIndustrySpec(), min(), PRODLEVEL_DEFAULT, production_rate, and IndustrySpec::UsesSmoothEconomy().
Referenced by ChangeIndustryProduction().
static void Industry::ResetIndustryCounts | ( | ) | [inline, static] |
Way the industry was constructed (.
Definition at line 71 of file industry.h.
Referenced by DoCreateNewIndustry(), and IndustryGetVariable().