OpenTTD Source
20241121-master-g67a0fccfad
|
Specification of a cargo type. More...
#include <cargotype.h>
Data Structures | |
struct | IterateWrapper |
struct | Iterator |
Iterator to iterate all valid CargoSpec. More... | |
Public Member Functions | |
CargoID | Index () const |
Determines index of this cargospec. More... | |
bool | IsValid () const |
Tests for validity of this cargospec. More... | |
SpriteID | GetCargoIcon () const |
Get sprite for showing cargo of this type. More... | |
uint64_t | WeightOfNUnits (uint32_t n) const |
uint64_t | WeightOfNUnitsInTrain (uint32_t n) const |
Static Public Member Functions | |
static size_t | GetArraySize () |
Total number of cargospecs, both valid and invalid. More... | |
static CargoSpec * | Get (size_t index) |
Retrieve cargo details for the given cargo ID. More... | |
static IterateWrapper | Iterate (size_t from=0) |
Returns an iterable ensemble of all valid CargoSpec. More... | |
Data Fields | |
CargoLabel | label |
Unique label of the cargo type. | |
uint8_t | bitnum = INVALID_CARGO_BITNUM |
Cargo bit number, is INVALID_CARGO_BITNUM for a non-used spec. | |
uint8_t | legend_colour |
uint8_t | rating_colour |
uint8_t | weight |
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg). | |
uint16_t | multiplier = 0x100 |
Capacity multiplier for vehicles. (8 fractional bits) | |
CargoClasses | classes |
Classes of this cargo type. More... | |
int32_t | initial_payment |
Initial payment rate before inflation is applied. | |
uint8_t | transit_periods [2] |
bool | is_freight |
Cargo type is considered to be freight (affects train freight multiplier). | |
TownAcceptanceEffect | town_acceptance_effect |
The effect that delivering this cargo type has on towns. Also affects destination of subsidies. | |
TownProductionEffect | town_production_effect = INVALID_TPE |
The effect on town cargo production. | |
uint16_t | town_production_multiplier = TOWN_PRODUCTION_DIVISOR |
Town production multipler, if commanded by TownProductionEffect. | |
uint8_t | callback_mask |
Bitmask of cargo callbacks that have to be called. | |
StringID | name |
Name of this type of cargo. | |
StringID | name_single |
Name of a single entity of this type of cargo. | |
StringID | units_volume |
Name of a single unit of cargo of this type. | |
StringID | quantifier |
Text for multiple units of cargo of this type. | |
StringID | abbrev |
Two letter abbreviation for this cargo type. | |
SpriteID | sprite |
Icon to display this cargo type, may be 0xFFF (which means to resolve an action123 chain). | |
const struct GRFFile * | grffile |
NewGRF where #group belongs to. | |
const struct SpriteGroup * | group |
Money | current_payment |
Static Public Attributes | |
static std::array< std::vector< const CargoSpec * >, NUM_TPE > | town_production_cargoes {} |
List of cargo specs for each Town Product Effect. | |
Static Private Attributes | |
static CargoSpec | array [NUM_CARGO] |
Array holding all CargoSpecs. | |
static std::map< CargoLabel, CargoID > | label_map {} |
Translation map from CargoLabel to Cargo ID. | |
Friends | |
void | SetupCargoForClimate (LandscapeID l) |
Set up the default cargo types for the given landscape type. More... | |
void | BuildCargoLabelMap () |
Build cargo label map. More... | |
CargoID | GetCargoIDByLabel (CargoLabel ct) |
void | FinaliseCargoArray () |
Check for invalid cargoes. | |
Specification of a cargo type.
Definition at line 71 of file cargotype.h.
|
inlinestatic |
Retrieve cargo details for the given cargo ID.
index | ID of cargo |
Definition at line 134 of file cargotype.h.
References array, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_spritegroup_pool >::index, and lengthof.
Referenced by BuildReplacementVehicle(), CmdCreateSubsidy(), CMSAMine(), FreightWagonMult(), GetRefitCostFactor(), VehicleScopeResolver::GetVariable(), GenericScopeResolver::GetVariable(), IndustryCargoesWindow::HousesCanSupply(), IsCargoInClass(), IsDefaultCargo(), BuildIndustryWindow::MakeCargoListString(), SetupSubsidyDecodeParam(), and IndustryProductionGraphWindow::UpdateStatistics().
|
inlinestatic |
Total number of cargospecs, both valid and invalid.
Definition at line 124 of file cargotype.h.
SpriteID CargoSpec::GetCargoIcon | ( | ) | const |
Get sprite for showing cargo of this type.
Definition at line 169 of file cargotype.cpp.
References GetCustomCargoSprite(), and sprite.
|
inline |
Determines index of this cargospec.
Definition at line 105 of file cargotype.h.
References array.
Referenced by BuildLinkStatsLegend(), and TruncateCargo().
|
inline |
Tests for validity of this cargospec.
Definition at line 115 of file cargotype.h.
References INVALID_CARGO_BITNUM.
|
inlinestatic |
Returns an iterable ensemble of all valid CargoSpec.
from | index of the first CargoSpec to consider |
Definition at line 190 of file cargotype.h.
Referenced by FindFirstCargoWithTownAcceptanceEffect(), InitializeSortedCargoSpecs(), IndustryCargoesWindow::OnInit(), and StationResolverObject::StationResolverObject().
|
friend |
Build cargo label map.
This is called multiple times during NewGRF initialization as cargos are defined, so that TranslateRefitMask() and GetCargoTranslation(), also used during initialization, get the correct information.
Definition at line 125 of file cargotype.cpp.
|
friend |
Set up the default cargo types for the given landscape type.
l | Landscape |
Definition at line 62 of file cargotype.cpp.
CargoClasses CargoSpec::classes |
Classes of this cargo type.
Definition at line 78 of file cargotype.h.
Referenced by BuildCargoLabelMap(), CMSAMine(), GetRefitCostFactor(), and VehicleScopeResolver::GetVariable().