|
OpenTTD Source 20251117-master-g7398d2e290
|
Defines the internal data of a functional industry. More...
#include <industry.h>
Data Structures | |
| struct | AcceptedCargo |
| struct | AcceptedHistory |
| 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, Tpool_type, Tcache >::PoolItem<&_industry_pool > | |
| typedef struct Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache > | 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. | |
| bool | TileBelongsToIndustry (TileIndex tile) const |
| Check if a given tile belongs to this industry. | |
| const ProducedCargo & | GetProduced (size_t slot) const |
| Safely get a produced cargo slot, or an empty data if the slot does not exist. | |
| const AcceptedCargo & | GetAccepted (size_t slot) const |
| Safely get an accepted cargo slot, or an empty data if the slot does not exist. | |
| ProducedCargoes::iterator | GetCargoProduced (CargoType cargo) |
| Get produced cargo slot for a specific cargo type. | |
| ProducedCargoes::const_iterator | GetCargoProduced (CargoType cargo) const |
| Get produced cargo slot for a specific cargo type (const-variant). | |
| AcceptedCargoes::iterator | GetCargoAccepted (CargoType cargo) |
| Get accepted cargo slot for a specific cargo type. | |
| AcceptedCargoes::const_iterator | GetCargoAccepted (CargoType cargo) const |
| Get accepted cargo slot for a specific cargo type (const-variant). | |
| bool | IsCargoAccepted () const |
| Test if this industry accepts any cargo. | |
| bool | IsCargoProduced () const |
| Test if this industry produces any cargo. | |
| bool | IsCargoAccepted (CargoType cargo) const |
| Test if this industry accepts a specific cargo. | |
| bool | IsCargoProduced (CargoType cargo) const |
| Test if this industry produces a specific cargo. | |
| const std::string & | GetCachedName () const |
Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool > | |
| void * | operator new (size_t size) |
| Allocates space for new Titem. | |
| void * | operator new (size_t size, Tindex index) |
| Allocates space for new Titem with given index. | |
| void * | operator new (size_t, void *ptr) |
| Allocates space for new Titem at given memory address. | |
| void | operator delete (void *p, size_t size) |
| Marks Titem as free. | |
Static Public Member Functions | |
| static Industry * | GetByTile (TileIndex tile) |
| Get the industry of the given tile. | |
| static Industry * | GetRandom () |
| Return a random valid industry. | |
| static void | PostDestructor (size_t index) |
| Invalidating some stuff after removing item from the pool. | |
| static uint16_t | GetIndustryTypeCount (IndustryType type) |
| Get the count of industries for this type. | |
Static Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool > | |
| static bool | CanAllocateItem (size_t n=1) |
| Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() | |
| static bool | CleaningPool () |
| Returns current state of pool cleaning - yes or no. | |
| static bool | IsValidID (auto index) |
| Tests whether given index can be used to get valid (non-nullptr) Titem. | |
| static Titem * | Get (auto index) |
| Returns Titem with given index. | |
| static Titem * | GetIfValid (auto index) |
| Returns Titem with given index. | |
| static size_t | GetPoolSize () |
| Returns first unused index. | |
| static size_t | GetNumItems () |
| Returns number of valid items in the pool. | |
| static void | PostDestructor (size_t index) |
| Dummy function called after destructor of each member. | |
| static Pool::IterateWrapper< Titem > | Iterate (size_t from=0) |
| Returns an iterable ensemble of all valid Titem. | |
Data Fields | |
| TileArea | location {INVALID_TILE, 0, 0} |
| Location of the industry. | |
| Town * | town = nullptr |
| Nearest town. | |
| Station * | neutral_station = nullptr |
| Associated neutral station. | |
| ValidHistoryMask | valid_history = 0 |
| Mask of valid history records. | |
| ProducedCargoes | produced {} |
| produced cargo slots | |
| AcceptedCargoes | accepted {} |
| accepted cargo slots | |
| uint8_t | prod_level = 0 |
| general production level | |
| uint16_t | counter = 0 |
| used for animation and/or production (if available cargo) | |
| IndustryType | type = 0 |
| type of industry. | |
| Owner | owner = INVALID_OWNER |
| owner of the industry. Which SHOULD always be (imho) OWNER_NONE | |
| Colours | random_colour = COLOUR_BEGIN |
| randomized colour of the industry, for display purpose | |
| TimerGameEconomy::Year | last_prod_year {} |
| last economy year of production | |
| uint8_t | was_cargo_delivered = 0 |
| flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry | |
| IndustryControlFlags | ctlflags {} |
| flags overriding standard behaviours | |
| PartsOfSubsidy | 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 = INVALID_OWNER |
| Founder of the industry. | |
| TimerGameCalendar::Date | construction_date {} |
| Date of the construction of the industry. | |
| uint8_t | construction_type = 0 |
| Way the industry was constructed (. | |
| uint8_t | selected_layout = 0 |
| Which tile layout was used when creating the industry. | |
| Owner | exclusive_supplier = INVALID_OWNER |
| Which company has exclusive rights to deliver cargo (INVALID_OWNER = anyone) | |
| Owner | exclusive_consumer = INVALID_OWNER |
| Which company has exclusive rights to take cargo (INVALID_OWNER = anyone) | |
| EncodedString | text {} |
| General text with additional information. | |
| uint16_t | random = 0 |
| Random value used for randomisation of all kinds of things. | |
| PersistentStorage * | psa = nullptr |
| Persistent storage for NewGRF industries. | |
Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool > | |
| Tindex | index |
| Index of this pool item. | |
Static Public Attributes | |
| static std::array< FlatSet< IndustryID >, NUM_INDUSTRYTYPES > | industries |
| List of industries of each type. | |
Private Member Functions | |
| void | FillCachedName () const |
Defines the internal data of a functional industry.
Definition at line 62 of file industry.h.
| using Industry::AcceptedCargoes = std::vector<AcceptedCargo> |
Definition at line 104 of file industry.h.
| using Industry::ProducedCargoes = std::vector<ProducedCargo> |
Definition at line 103 of file industry.h.
|
inline |
Definition at line 138 of file industry.h.
| Industry::~Industry | ( | ) |
Definition at line 146 of file industry_cmd.cpp.
|
private |
Definition at line 2595 of file industry_cmd.cpp.
|
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 169 of file industry.h.
References accepted.
Referenced by IndustriesScopeResolver::GetVariable().
Get the industry of the given tile.
| tile | the tile to get the industry from |
Definition at line 251 of file industry.h.
References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::Get(), and GetIndustryIndex().
Referenced by AfterLoadGame(), CheckForDockingTile(), CmdDeleteTown(), CMSAMine(), GetAcceptanceAroundTiles(), GetIndustryType(), GetOrderCmdFromTile(), SmallMapWindow::GetTileColours(), IndustryTileScopeResolver::GetVariable(), IsShipDestinationTile(), IsTileForestIndustry(), Station::RecomputeCatchment(), NIHIndustryTile::Resolve(), TransportIndustryGoods(), and TriggerIndustryTileRandomisation().
|
inline |
Definition at line 270 of file industry.h.
|
inline |
Get accepted cargo slot for a specific cargo type.
| cargo | CargoType to find. |
Definition at line 202 of file industry.h.
References accepted, Industry::AcceptedCargo::cargo, and IsValidCargoType().
Referenced by DeliverGoodsToIndustry(), IndustriesScopeResolver::GetVariable(), and IndustryProductionCallback().
|
inline |
Get accepted cargo slot for a specific cargo type (const-variant).
| cargo | CargoType to find. |
Definition at line 213 of file industry.h.
References accepted, Industry::AcceptedCargo::cargo, and IsValidCargoType().
|
inline |
Get produced cargo slot for a specific cargo type.
| cargo | CargoType to find. |
Definition at line 180 of file industry.h.
References Industry::ProducedCargo::cargo, IsValidCargoType(), and produced.
Referenced by IndustriesScopeResolver::GetVariable(), IndustryProductionCallback(), and IndustryDirectoryWindow::IndustryProductionSorter().
|
inline |
Get produced cargo slot for a specific cargo type (const-variant).
| cargo | CargoType to find. |
Definition at line 191 of file industry.h.
References Industry::ProducedCargo::cargo, IsValidCargoType(), and produced.
|
inlinestatic |
Get the count of industries for this type.
| type | IndustryType to query |
Definition at line 264 of file industry.h.
References industries, NUM_INDUSTRYTYPES, and type.
Referenced by CheckIndustries(), CheckIndustryCloseDownProtection(), BuildIndustryWindow::DrawWidget(), SmallMapWindow::DrawWidget(), GetCountAndDistanceOfClosestInstance(), 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 158 of file industry.h.
References produced.
Referenced by ChangeIndustryProduction(), and IndustriesScopeResolver::GetVariable().
|
static |
Return a random valid industry.
Definition at line 227 of file industry_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::GetPoolSize(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::index, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::IsValidID(), and RandomRange().
Referenced by FindSubsidyCargoDestination(), and FindSubsidyIndustryCargoRoute().
|
inline |
Test if this industry accepts any cargo.
Definition at line 223 of file industry.h.
References accepted, and IsValidCargoType().
Referenced by Station::AddIndustryToDeliver(), CanCargoServiceIndustry(), FindSubsidyCargoDestination(), and IndustryTemporarilyRefusesCargo().
|
inline |
Test if this industry accepts a specific cargo.
| cargo | Cargo type to test. |
Definition at line 236 of file industry.h.
References accepted.
|
inline |
Test if this industry produces any cargo.
Definition at line 229 of file industry.h.
References IsValidCargoType(), and produced.
Referenced by CanCargoServiceIndustry().
|
inline |
Test if this industry produces a specific cargo.
| cargo | Cargo type to test. |
Definition at line 243 of file industry.h.
References produced.
|
static |
Invalidating some stuff after removing item from the pool.
| index | index of deleted item |
Definition at line 216 of file industry_cmd.cpp.
References InvalidateWindowData(), SetWindowDirty(), WC_BUILD_INDUSTRY, 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 2584 of file industry_cmd.cpp.
References CeilDiv(), GetIndustrySpec(), PRODLEVEL_DEFAULT, produced, and IndustrySpec::UsesOriginalEconomy().
Referenced by ChangeIndustryProduction(), CmdIndustrySetProduction(), and DoCreateNewIndustry().
|
inline |
Check if a given tile belongs to this industry.
| tile | The tile to check. |
Definition at line 148 of file industry.h.
References GetIndustryIndex(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::index, IsTileType(), and MP_INDUSTRY.
Referenced by ChopLumberMillTrees(), DoCreateNewIndustry(), GetIndustryIDAtOffset(), IndustriesScopeResolver::GetVariable(), and TriggerIndustryRandomisation().
| AcceptedCargoes Industry::accepted {} |
accepted cargo slots
Definition at line 111 of file industry.h.
Referenced by DeliverGoodsToIndustry(), DoCreateNewIndustry(), IndustryViewWindow::DrawInfo(), GetAccepted(), GetCargoAccepted(), GetCargoAccepted(), IndustriesScopeResolver::GetVariable(), SlIndustryAccepted::GetVector(), IndustryProductionCallback(), IsCargoAccepted(), IsCargoAccepted(), TriggerIndustryProduction(), TrimIndustryAcceptedProduced(), and UpdateIndustryStatistics().
|
mutable |
NOSAVE: Cache of the resolved name of the industry.
Definition at line 124 of file industry.h.
| TimerGameCalendar::Date Industry::construction_date {} |
Date of the construction of the industry.
Definition at line 127 of file industry.h.
Referenced by DoCreateNewIndustry(), and IndustriesScopeResolver::GetVariable().
| uint8_t Industry::construction_type = 0 |
Way the industry was constructed (.
Definition at line 128 of file industry.h.
Referenced by DoCreateNewIndustry(), and IndustriesScopeResolver::GetVariable().
| uint16_t Industry::counter = 0 |
used for animation and/or production (if available cargo)
Definition at line 113 of file industry.h.
Referenced by DoCreateNewIndustry(), and IndustriesScopeResolver::GetVariable().
| IndustryControlFlags Industry::ctlflags {} |
flags overriding standard behaviours
Definition at line 120 of file industry.h.
Referenced by ChangeIndustryProduction(), CmdIndustrySetFlags(), CmdIndustrySetProduction(), DoCreateNewIndustry(), and IndustriesScopeResolver::GetVariable().
| Owner Industry::exclusive_consumer = INVALID_OWNER |
Which company has exclusive rights to take cargo (INVALID_OWNER = anyone)
Definition at line 131 of file industry.h.
Referenced by CmdIndustrySetExclusivity(), DoCreateNewIndustry(), and TransportIndustryGoods().
| Owner Industry::exclusive_supplier = INVALID_OWNER |
Which company has exclusive rights to deliver cargo (INVALID_OWNER = anyone)
Definition at line 130 of file industry.h.
Referenced by CmdIndustrySetExclusivity(), DeliverGoodsToIndustry(), and DoCreateNewIndustry().
| Owner Industry::founder = INVALID_OWNER |
Founder of the industry.
Definition at line 126 of file industry.h.
Referenced by CheckIfCallBackAllowsCreation(), DoCreateNewIndustry(), IndustriesScopeResolver::GetVariable(), and PerformIndustryTileSlopeCheck().
|
static |
List of industries of each type.
Definition at line 276 of file industry.h.
Referenced by CheckIfFarEnoughFromConflictingIndustry(), DoCreateNewIndustry(), FindTownForIndustry(), GetCountAndDistanceOfClosestInstance(), GetCurrentTotalNumberOfIndustries(), GetIndustryTypeCount(), and INDYChunkHandler::Load().
| TimerGameEconomy::Year Industry::last_prod_year {} |
last economy year of production
Definition at line 118 of file industry.h.
Referenced by ChangeIndustryProduction(), DoCreateNewIndustry(), IndustriesScopeResolver::GetVariable(), and UpdateIndustryStatistics().
| TileArea Industry::location {INVALID_TILE, 0, 0} |
Location of the industry.
Definition at line 106 of file industry.h.
Referenced by ChangeIndustryProduction(), CheckIfCallBackAllowsCreation(), ChopLumberMillTrees(), Disaster_CoalMine_Init(), Disaster_Helicopter_Init(), DisasterTick_Aircraft(), DoCreateNewIndustry(), IndustryViewWindow::DrawInfo(), GetCargoSuffix(), GetCountAndDistanceOfClosestInstance(), IndustriesScopeResolver::GetVariable(), IndustryTileScopeResolver::GetVariable(), IndustryProductionCallback(), IndustryTemporarilyRefusesCargo(), IndustryViewWindow::OnClick(), PerformIndustryTileSlopeCheck(), PopulateStationsNearby(), Station::RecomputeCatchment(), NIHIndustry::Resolve(), and TriggerIndustryRandomisation().
| Station* Industry::neutral_station = nullptr |
Associated neutral station.
Definition at line 108 of file industry.h.
Referenced by CheckForDockingTile(), GetAcceptanceAroundTiles(), GetOrderCmdFromTile(), GetProductionAroundTiles(), IsShipDestinationTile(), PopulateStationsNearby(), and Station::RecomputeCatchment().
| Owner Industry::owner = INVALID_OWNER |
owner of the industry. Which SHOULD always be (imho) OWNER_NONE
Definition at line 116 of file industry.h.
Referenced by DoCreateNewIndustry().
| PartsOfSubsidy Industry::part_of_subsidy {} |
NOSAVE: is this industry a source/destination of a subsidy?
Definition at line 122 of file industry.h.
| uint8_t Industry::prod_level = 0 |
general production level
Definition at line 112 of file industry.h.
Referenced by ChangeIndustryProduction(), CmdIndustrySetProduction(), DoCreateNewIndustry(), IndustryViewWindow::DrawInfo(), IndustriesScopeResolver::GetVariable(), IndustryProductionCallback(), IndustryViewWindow::OnClick(), and IndustryViewWindow::OnQueryTextFinished().
| ProducedCargoes Industry::produced {} |
produced cargo slots
Definition at line 110 of file industry.h.
Referenced by ChangeIndustryProduction(), ChopLumberMillTrees(), CMSAMine(), DoCreateNewIndustry(), IndustryViewWindow::DrawInfo(), FindSubsidyIndustryCargoRoute(), GetCargoProduced(), GetCargoProduced(), IndustryDirectoryWindow::GetCargoTransportedSortValue(), IndustryDirectoryWindow::GetIndustryString(), GetProduced(), GetProductionAroundTiles(), IndustriesScopeResolver::GetVariable(), SlIndustryProduced::GetVector(), IndustryProductionCallback(), IndustryDirectoryWindow::IndustryProductionSorter(), IsCargoProduced(), IsCargoProduced(), IsTileForestIndustry(), INDYChunkHandler::Load(), IndustryViewWindow::OnClick(), IndustryViewWindow::OnQueryTextFinished(), ProduceIndustryGoodsHelper(), RecomputeProductionMultipliers(), TransportIndustryGoods(), TriggerIndustryProduction(), TrimIndustryAcceptedProduced(), and UpdateIndustryStatistics().
| PersistentStorage* Industry::psa = nullptr |
Persistent storage for NewGRF industries.
Definition at line 136 of file industry.h.
Referenced by CheckIfCallBackAllowsCreation(), NIHIndustry::GetPSA(), IndustriesScopeResolver::GetVariable(), INDYChunkHandler::Load(), and IndustriesScopeResolver::StorePSA().
| uint16_t Industry::random = 0 |
Random value used for randomisation of all kinds of things.
Definition at line 134 of file industry.h.
Referenced by CheckIfCallBackAllowsCreation(), DoCreateNewIndustry(), DoReseedIndustry(), IndustriesScopeResolver::GetRandomBits(), and PerformIndustryTileSlopeCheck().
| Colours Industry::random_colour = COLOUR_BEGIN |
randomized colour of the industry, for display purpose
Definition at line 117 of file industry.h.
Referenced by DoCreateNewIndustry(), and IndustriesScopeResolver::GetVariable().
| uint8_t Industry::selected_layout = 0 |
Which tile layout was used when creating the industry.
Definition at line 129 of file industry.h.
Referenced by CheckIfCallBackAllowsCreation(), DoCreateNewIndustry(), GetCountAndDistanceOfClosestInstance(), and IndustriesScopeResolver::GetVariable().
| StationList Industry::stations_near {} |
NOSAVE: List of nearby stations.
Definition at line 123 of file industry.h.
Referenced by PopulateStationsNearby(), Station::RecomputeCatchment(), TransportIndustryGoods(), and WhoCanServiceIndustry().
| EncodedString Industry::text {} |
General text with additional information.
Definition at line 132 of file industry.h.
Referenced by CmdIndustrySetText(), and IndustryViewWindow::DrawInfo().
| Town* Industry::town = nullptr |
Nearest town.
Definition at line 107 of file industry.h.
Referenced by AdvertiseIndustryOpening(), ChangeIndustryProduction(), CheckIfCallBackAllowsCreation(), CmdDeleteTown(), CmdIndustrySetProduction(), Disaster_CoalMine_Init(), DisasterTick_Aircraft(), DoCreateNewIndustry(), FormatString(), GetCountAndDistanceOfClosestInstance(), IndustriesResolverObject::GetTown(), and IndustriesScopeResolver::GetVariable().
| IndustryType Industry::type = 0 |
type of industry.
Definition at line 115 of file industry.h.
Referenced by AdvertiseIndustryOpening(), ChangeIndustryProduction(), CheckIfCallBackAllowsCreation(), CmdIndustrySetProduction(), CMSAMine(), Disaster_CoalMine_Init(), Disaster_Helicopter_Init(), DoCreateNewIndustry(), IndustryViewWindow::DrawInfo(), FormatString(), GetCountAndDistanceOfClosestInstance(), IndustryDirectoryWindow::GetIndustryString(), GetIndustryType(), GetIndustryTypeCount(), SmallMapWindow::GetTileColours(), IndustriesScopeResolver::GetVariable(), IndustryProductionCallback(), IndustryTemporarilyRefusesCargo(), IndustryDirectoryWindow::IndustryTypeSorter(), IsTileForestIndustry(), INDYChunkHandler::Load(), IndustryViewWindow::OnClick(), IndustryViewWindow::OnInvalidateData(), PerformIndustryTileSlopeCheck(), NIHIndustry::Resolve(), IndustriesScopeResolver::StorePSA(), TransportIndustryGoods(), and TriggerIndustryProduction().
| ValidHistoryMask Industry::valid_history = 0 |
Mask of valid history records.
Definition at line 109 of file industry.h.
Referenced by DoCreateNewIndustry(), INDYChunkHandler::Load(), and UpdateIndustryStatistics().
| uint8_t Industry::was_cargo_delivered = 0 |
flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
Definition at line 119 of file industry.h.
Referenced by DoCreateNewIndustry(), IndustriesScopeResolver::GetVariable(), and TriggerIndustryProduction().