OpenTTD Source
20241121-master-g67a0fccfad
|
Defines the internal data of a functional industry. More...
#include <industry.h>
Data Structures | |
struct | AcceptedCargo |
struct | ProducedCargo |
struct | ProducedHistory |
Public Types | |
using | ProducedCargoes = std::vector< ProducedCargo > |
using | AcceptedCargoes = std::vector< AcceptedCargo > |
Public Types inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool > | |
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero > | Pool |
Type of the pool this item is going to be part of. | |
Public Member Functions | |
Industry (TileIndex tile=INVALID_TILE) | |
void | RecomputeProductionMultipliers () |
Recompute #production_rate for current prod_level. More... | |
bool | TileBelongsToIndustry (TileIndex tile) const |
Check if a given tile belongs to this industry. More... | |
const ProducedCargo & | GetProduced (size_t slot) const |
Safely get a produced cargo slot, or an empty data if the slot does not exist. More... | |
const AcceptedCargo & | GetAccepted (size_t slot) const |
Safely get an accepted cargo slot, or an empty data if the slot does not exist. More... | |
ProducedCargoes::iterator | GetCargoProduced (CargoID cargo) |
Get produced cargo slot for a specific cargo type. More... | |
ProducedCargoes::const_iterator | GetCargoProduced (CargoID cargo) const |
Get produced cargo slot for a specific cargo type (const-variant). More... | |
AcceptedCargoes::iterator | GetCargoAccepted (CargoID cargo) |
Get accepted cargo slot for a specific cargo type. More... | |
AcceptedCargoes::const_iterator | GetCargoAccepted (CargoID cargo) const |
Get accepted cargo slot for a specific cargo type (const-variant). More... | |
bool | IsCargoAccepted () const |
Test if this industry accepts any cargo. More... | |
bool | IsCargoProduced () const |
Test if this industry produces any cargo. More... | |
bool | IsCargoAccepted (CargoID cargo) const |
Test if this industry accepts a specific cargo. More... | |
bool | IsCargoProduced (CargoID cargo) const |
Test if this industry produces a specific cargo. More... | |
const std::string & | GetCachedName () const |
Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool > | |
void * | operator new (size_t size) |
Allocates space for new Titem. More... | |
void * | operator new (size_t size, size_t index) |
Allocates space for new Titem with given index. More... | |
void * | operator new (size_t, void *ptr) |
Allocates space for new Titem at given memory address. More... | |
void | operator delete (void *p) |
Marks Titem as free. More... | |
Static Public Member Functions | |
static Industry * | GetByTile (TileIndex tile) |
Get the industry of the given tile. More... | |
static Industry * | GetRandom () |
Return a random valid industry. More... | |
static void | PostDestructor (size_t index) |
Invalidating some stuff after removing item from the pool. More... | |
static void | IncIndustryTypeCount (IndustryType type) |
Increment the count of industries for this type. More... | |
static void | DecIndustryTypeCount (IndustryType type) |
Decrement the count of industries for this type. More... | |
static uint16_t | GetIndustryTypeCount (IndustryType type) |
Get the count of industries for this type. More... | |
static void | ResetIndustryCounts () |
Resets industry counts. | |
Static Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool > | |
static bool | CanAllocateItem (size_t n=1) |
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() More... | |
static bool | CleaningPool () |
Returns current state of pool cleaning - yes or no. More... | |
static bool | IsValidID (size_t index) |
Tests whether given index can be used to get valid (non-nullptr) Titem. More... | |
static Titem * | Get (size_t index) |
Returns Titem with given index. More... | |
static Titem * | GetIfValid (size_t index) |
Returns Titem with given index. More... | |
static size_t | GetPoolSize () |
Returns first unused index. More... | |
static size_t | GetNumItems () |
Returns number of valid items in the pool. More... | |
static void | PostDestructor ([[maybe_unused]] size_t index) |
Dummy function called after destructor of each member. More... | |
static Pool::IterateWrapper< Titem > | Iterate (size_t from=0) |
Returns an iterable ensemble of all valid Titem. More... | |
Data Fields | |
TileArea | location |
Location of the industry. | |
Town * | town |
Nearest town. | |
Station * | neutral_station |
Associated neutral station. | |
ProducedCargoes | produced |
produced cargo slots | |
AcceptedCargoes | accepted |
accepted cargo slots | |
uint8_t | prod_level |
general production level | |
uint16_t | counter |
used for animation and/or production (if available cargo) | |
IndustryType | type |
type of industry. | |
Owner | owner |
owner of the industry. Which SHOULD always be (imho) OWNER_NONE | |
Colours | random_colour |
randomized colour of the industry, for display purpose | |
TimerGameEconomy::Year | last_prod_year |
last economy year of production | |
uint8_t | was_cargo_delivered |
flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry | |
IndustryControlFlags | ctlflags |
flags overriding standard behaviours | |
PartOfSubsidy | part_of_subsidy |
NOSAVE: is this industry a source/destination of a subsidy? | |
StationList | stations_near |
NOSAVE: List of nearby stations. | |
std::string | cached_name |
NOSAVE: Cache of the resolved name of the industry. | |
Owner | founder |
Founder of the industry. | |
TimerGameCalendar::Date | construction_date |
Date of the construction of the industry. | |
uint8_t | construction_type |
Way the industry was constructed (. More... | |
uint8_t | selected_layout |
Which tile layout was used when creating the industry. | |
Owner | exclusive_supplier |
Which company has exclusive rights to deliver cargo (INVALID_OWNER = anyone) | |
Owner | exclusive_consumer |
Which company has exclusive rights to take cargo (INVALID_OWNER = anyone) | |
std::string | text |
General text with additional information. | |
uint16_t | random |
Random value used for randomisation of all kinds of things. | |
PersistentStorage * | psa |
Persistent storage for NewGRF industries. | |
Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool > | |
Tindex | index |
Index of this pool item. | |
Static Protected Attributes | |
static uint16_t | counts [NUM_INDUSTRYTYPES] |
Number of industries per type ingame. | |
Private Member Functions | |
void | FillCachedName () const |
Defines the internal data of a functional industry.
Definition at line 66 of file industry.h.
|
inlinestatic |
Decrement the count of industries for this type.
type | IndustryType to decrement |
Definition at line 262 of file industry.h.
References counts, NUM_INDUSTRYTYPES, and type.
|
inline |
Safely get an accepted cargo slot, or an empty data if the slot does not exist.
slot | accepted cargo slot to retrieve. |
Definition at line 156 of file industry.h.
Get the industry of the given tile.
tile | the tile to get the industry from |
Definition at line 238 of file industry.h.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::Get(), and GetIndustryIndex().
Referenced by CheckForDockingTile(), CheckIfFarEnoughFromConflictingIndustry(), CMSAMine(), GetAcceptanceAroundTiles(), GetIndustryType(), GetOrderCmdFromTile(), IsShipDestinationTile(), IsTileForestIndustry(), Station::RecomputeCatchment(), NIHIndustryTile::Resolve(), TransportIndustryGoods(), and TriggerIndustryTile().
|
inline |
Get accepted cargo slot for a specific cargo type.
cargo | CargoID to find. |
Definition at line 189 of file industry.h.
References IsValidCargoID().
Referenced by DeliverGoodsToIndustry().
|
inline |
Get accepted cargo slot for a specific cargo type (const-variant).
cargo | CargoID to find. |
Definition at line 200 of file industry.h.
References IsValidCargoID().
|
inline |
Get produced cargo slot for a specific cargo type.
cargo | CargoID to find. |
Definition at line 167 of file industry.h.
References IsValidCargoID().
|
inline |
Get produced cargo slot for a specific cargo type (const-variant).
cargo | CargoID to find. |
Definition at line 178 of file industry.h.
References IsValidCargoID().
|
inlinestatic |
Get the count of industries for this type.
type | IndustryType to query |
Definition at line 273 of file industry.h.
Referenced by CheckIndustries(), GetCurrentTotalNumberOfIndustries(), and IndustryBuildData::TryBuildNewIndustry().
|
inline |
Safely get a produced cargo slot, or an empty data if the slot does not exist.
slot | produced cargo slot to retrieve. |
Definition at line 145 of file industry.h.
|
static |
Return a random valid industry.
Definition at line 221 of file industry_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::GetNumItems(), and RandomRange().
Referenced by FindSubsidyIndustryCargoRoute().
|
inlinestatic |
Increment the count of industries for this type.
type | IndustryType to increment |
Definition at line 251 of file industry.h.
References counts, NUM_INDUSTRYTYPES, and type.
|
inline |
Test if this industry accepts any cargo.
Definition at line 210 of file industry.h.
References IsValidCargoID().
Referenced by Station::AddIndustryToDeliver(), CanCargoServiceIndustry(), and IndustryTemporarilyRefusesCargo().
|
inline |
Test if this industry accepts a specific cargo.
cargo | Cargo type to test. |
Definition at line 223 of file industry.h.
|
inline |
Test if this industry produces any cargo.
Definition at line 216 of file industry.h.
References IsValidCargoID().
Referenced by CanCargoServiceIndustry().
|
inline |
Test if this industry produces a specific cargo.
cargo | Cargo type to test. |
Definition at line 230 of file industry.h.
|
static |
Invalidating some stuff after removing item from the pool.
index | index of deleted item |
Definition at line 210 of file industry_cmd.cpp.
References InvalidateWindowData(), and WC_INDUSTRY_DIRECTORY.
void Industry::RecomputeProductionMultipliers | ( | ) |
Recompute #production_rate for current prod_level.
This function is only valid when not using smooth economy.
Definition at line 2529 of file industry_cmd.cpp.
References CeilDiv(), GetIndustrySpec(), PRODLEVEL_DEFAULT, produced, and IndustrySpec::UsesOriginalEconomy().
Referenced by CmdIndustrySetProduction().
|
inline |
Check if a given tile belongs to this industry.
tile | The tile to check. |
Definition at line 135 of file industry.h.
References GetIndustryIndex(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::index, IsTileType(), and MP_INDUSTRY.
Referenced by ChopLumberMillTrees(), GetIndustryIDAtOffset(), and TriggerIndustry().
uint8_t Industry::construction_type |
Way the industry was constructed (.
Definition at line 115 of file industry.h.