60 static const int THIS_MONTH = 0;
61 static const int LAST_MONTH = 1;
71 uint8_t PctTransported()
const
73 if (this->production == 0)
return 0;
74 return ClampTo<uint8_t>(this->transported * 256 / this->production);
91 using ProducedCargoes = std::vector<ProducedCargo>;
92 using AcceptedCargoes = std::vector<AcceptedCargo>;
148 return slot < this->produced.size() ? this->produced[slot] : empty;
159 return slot < this->accepted.size() ? this->accepted[slot] : empty;
170 return std::find_if(std::begin(this->produced), std::end(this->produced), [&cargo](
const auto &p) {
return p.cargo == cargo; });
181 return std::find_if(std::begin(this->produced), std::end(this->produced), [&cargo](
const auto &p) {
return p.cargo == cargo; });
192 return std::find_if(std::begin(this->accepted), std::end(this->accepted), [&cargo](
const auto &a) {
return a.cargo == cargo; });
203 return std::find_if(std::begin(this->accepted), std::end(this->accepted), [&cargo](
const auto &a) {
return a.cargo == cargo; });
210 bool IsCargoAccepted()
const {
return std::any_of(std::begin(this->accepted), std::end(this->accepted), [](
const auto &a) {
return IsValidCargoID(a.cargo); }); }
216 bool IsCargoProduced()
const {
return std::any_of(std::begin(this->produced), std::end(this->produced), [](
const auto &p) {
return IsValidCargoID(p.cargo); }); }
223 bool IsCargoAccepted(
CargoID cargo)
const {
return std::any_of(std::begin(this->accepted), std::end(this->accepted), [&cargo](
const auto &a) {
return a.cargo == cargo; }); }
230 bool IsCargoProduced(
CargoID cargo)
const {
return std::any_of(std::begin(this->produced), std::end(this->produced), [&cargo](
const auto &p) {
return p.cargo == cargo; }); }
285 inline const std::string &GetCachedName()
const
287 if (this->cached_name.empty()) this->FillCachedName();
292 void FillCachedName()
const;
298 void ClearAllIndustryCachedNames();
300 void PlantRandomFarmField(
const Industry *i);
340 IDIWD_PRODUCTION_CHANGE,
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Owner
Enum for all companies/owners.
IndustryControlFlags
Flags to control/override the behaviour of an industry.
@ INDCTL_EXTERNAL_PROD_LEVEL
Indicates that the production level of the industry is externally controlled.
@ INDCTL_NONE
No flags in effect.
@ INDCTL_NO_CLOSURE
Industry can not close regardless of production level or time since last delivery.
@ INDCTL_NO_PRODUCTION_DECREASE
When industry production change is evaluated, rolls to decrease are ignored.
@ INDCTL_MASK
Mask of all flags set.
@ INDCTL_NO_PRODUCTION_INCREASE
When industry production change is evaluated, rolls to increase are ignored.
static constexpr uint8_t PRODLEVEL_MAXIMUM
the industry is running at full speed
void ReleaseDisastersTargetingIndustry(IndustryID)
Marks all disasters targeting this industry in such a way they won't call Industry::Get(v->dest_tile)...
static constexpr uint8_t PRODLEVEL_DEFAULT
default level set when the industry is created
static const TimerGameEconomy::Year PROCESSING_INDUSTRY_ABANDONMENT_YEARS
If a processing industry doesn't produce for this many consecutive economy years, it may close.
IndustryDirectoryInvalidateWindowData
Special values for the industry list window for the data parameter of InvalidateWindowData.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
IndustryBuildData _industry_builder
In-game manager of industries.
static constexpr uint8_t PRODLEVEL_MINIMUM
below this level, the industry is set to be closing
static constexpr uint8_t PRODLEVEL_CLOSURE
signal set to actually close the industry
void TrimIndustryAcceptedProduced(Industry *ind)
Remove unused industry accepted/produced slots – entries after the last slot with valid cargo.
Accessors for industries.
IndustryID GetIndustryIndex(Tile t)
Get the industry ID of the given tile.
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
Functionality related to the temporary and persistent storage arrays for NewGRFs.
Base classes/functions for stations.
std::set< Station *, StationCompare > StationList
List of stations.
Data for managing the number and type of industries in the game.
void Reset()
Completely reset the industry build data.
void EconomyMonthlyLoop()
Monthly update of industry build data.
uint32_t wanted_inds
Number of wanted industries (bits 31-16), and a fraction (bits 15-0).
void SetupTargetCount()
Decide how many industries of each type are needed.
void TryBuildNewIndustry()
Try to create a random industry, during gameplay.
IndustryTypeBuildData builddata[NUM_INDUSTRYTYPES]
Industry build data for every industry type.
Data for managing the number of industries of a single industry type.
uint32_t probability
Relative probability of building this industry.
uint16_t target_count
Desired number of industries of this type.
uint8_t min_number
Smallest number of industries that should exist (either 0 or 1).
void Reset()
Reset the entry.
bool GetIndustryTypeData(IndustryType it)
Set the probability and min_number fields for the industry type it for a running game.
uint16_t wait_count
Number of turns to wait before trying to build again.
uint16_t max_wait
Starting number of turns to wait (copied to wait_count).
uint16_t waiting
Amount of cargo waiting to processed.
TimerGameEconomy::Date last_accepted
Last day cargo was accepted by this industry.
uint16_t waiting
Amount of cargo produced.
std::array< ProducedHistory, 25 > history
History of cargo produced and transported for this month and 24 previous months.
uint8_t rate
Production rate.
uint16_t transported
Total transported.
uint16_t production
Total produced.
Defines the internal data of a functional industry.
static Industry * GetRandom()
Return a random valid industry.
IndustryType type
type of industry.
Owner exclusive_supplier
Which company has exclusive rights to deliver cargo (INVALID_OWNER = anyone)
TimerGameCalendar::Date construction_date
Date of the construction of the industry.
IndustryControlFlags ctlflags
flags overriding standard behaviours
bool IsCargoAccepted() const
Test if this industry accepts any cargo.
PersistentStorage * psa
Persistent storage for NewGRF industries.
bool IsCargoAccepted(CargoID cargo) const
Test if this industry accepts a specific cargo.
uint8_t prod_level
general production level
Colours random_colour
randomized colour of the industry, for display purpose
void RecomputeProductionMultipliers()
Recompute #production_rate for current prod_level.
AcceptedCargoes::iterator GetCargoAccepted(CargoID cargo)
Get accepted cargo slot for a specific cargo type.
uint8_t construction_type
Way the industry was constructed (.
std::string cached_name
NOSAVE: Cache of the resolved name of the industry.
TimerGameEconomy::Year last_prod_year
last economy year of production
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
ProducedCargoes produced
produced cargo slots
uint16_t random
Random value used for randomisation of all kinds of things.
static void PostDestructor(size_t index)
Invalidating some stuff after removing item from the pool.
Owner founder
Founder of the industry.
uint8_t selected_layout
Which tile layout was used when creating the industry.
AcceptedCargoes accepted
accepted cargo slots
static uint16_t GetIndustryTypeCount(IndustryType type)
Get the count of industries for this type.
std::string text
General text with additional information.
static void ResetIndustryCounts()
Resets industry counts.
Owner owner
owner of the industry. Which SHOULD always be (imho) OWNER_NONE
ProducedCargoes::const_iterator GetCargoProduced(CargoID cargo) const
Get produced cargo slot for a specific cargo type (const-variant).
static void IncIndustryTypeCount(IndustryType type)
Increment the count of industries for this type.
TileArea location
Location of the industry.
Station * neutral_station
Associated neutral station.
static uint16_t counts[NUM_INDUSTRYTYPES]
Number of industries per type ingame.
AcceptedCargoes::const_iterator GetCargoAccepted(CargoID cargo) const
Get accepted cargo slot for a specific cargo type (const-variant).
bool IsCargoProduced(CargoID cargo) const
Test if this industry produces a specific cargo.
StationList stations_near
NOSAVE: List of nearby stations.
bool IsCargoProduced() const
Test if this industry produces any cargo.
Owner exclusive_consumer
Which company has exclusive rights to take cargo (INVALID_OWNER = anyone)
const ProducedCargo & GetProduced(size_t slot) const
Safely get a produced cargo slot, or an empty data if the slot does not exist.
uint16_t counter
used for animation and/or production (if available cargo)
ProducedCargoes::iterator GetCargoProduced(CargoID cargo)
Get produced cargo slot for a specific cargo type.
uint8_t was_cargo_delivered
flag that indicate this has been the closest industry chosen for cargo delivery by a station....
static void DecIndustryTypeCount(IndustryType type)
Decrement the count of industries for this type.
bool TileBelongsToIndustry(TileIndex tile) const
Check if a given tile belongs to this industry.
const AcceptedCargo & GetAccepted(size_t slot) const
Safely get an accepted cargo slot, or an empty data if the slot does not exist.
PartOfSubsidy part_of_subsidy
NOSAVE: is this industry a source/destination of a subsidy?
Represents the covered area of e.g.
Class for pooled persistent storage of data.
Base class for all PoolItems.
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
Base class for all pools.
Templated helper to make a type-safe 'typedef' representing a single POD value.
basic types related to subsidies
PartOfSubsidy
What part of a subsidy is something?
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ MP_INDUSTRY
Part of an industry.
Type for storing the 'area' of something uses on the map.
Definition of the game-calendar-timer.
Definition of the game-economy-timer.