OpenTTD Source 20241224-master-gf74b0cf984
|
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. | |
bool | IsValid () const |
Tests for validity of this cargospec. | |
SpriteID | GetCargoIcon () const |
Get sprite for showing cargo of this type. | |
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. | |
static CargoSpec * | Get (size_t index) |
Retrieve cargo details for the given cargo ID. | |
static IterateWrapper | Iterate (size_t from=0) |
Returns an iterable ensemble of all valid CargoSpec. | |
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. | |
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. | |
void | BuildCargoLabelMap () |
Build cargo label map. | |
CargoID | GetCargoIDByLabel (CargoLabel ct) |
void | FinaliseCargoArray () |
Check for invalid cargoes. | |
Specification of a cargo type.
Definition at line 76 of file cargotype.h.
|
inlinestatic |
Retrieve cargo details for the given cargo ID.
index | ID of cargo |
Definition at line 139 of file cargotype.h.
References array, and lengthof.
Referenced by LinkGraphOverlay::AddLinks(), AfterLoadGame(), BuildReplacementVehicle(), CargoChangeInfo(), CmdCreateSubsidy(), CMSAMine(), CargoesRow::ConnectIndustryProduced(), DeliverGoods(), Engine::DetermineCapacity(), CargoesField::Draw(), DrawCargoIconOverlay(), DrawCargoIcons(), IndustryViewWindow::DrawInfo(), NewGRFInspectWindow::DrawMainPanelWidget(), DrawOrderString(), DrawVehicleRefitWindow(), IndustryProductionGraphWindow::DrawWidget(), FindSubsidyTownCargoRoute(), FormatString(), FreightWagonMult(), GetEngineLiveryScheme(), GetLoadAmount(), RoadVehicle::GetMaxWeight(), Train::GetMaxWeight(), GetRefitCostFactor(), VehicleScopeResolver::GetVariable(), GenericScopeResolver::GetVariable(), RoadVehicle::GetWeight(), Train::GetWeight(), IndustryCargoesWindow::HousesCanSupply(), IsCargoInClass(), IsDefaultCargo(), BuildIndustryWindow::MakeCargoListString(), IndustryCargoesWindow::OnTooltip(), LinkGraphOverlay::RebuildCache(), LinkRefresher::RefreshLinks(), ReportNewsProductionChangeIndustry(), IndustryCargoesWindow::SetStringParameters(), CompanyStationsWindow::SetStringParameters(), SetupSubsidyDecodeParam(), StationsWndShowStationRating(), IndustryProductionGraphWindow::UpdateStatistics(), and IndustryProductionGraphWindow::UpdateWidgetSize().
|
inlinestatic |
Total number of cargospecs, both valid and invalid.
Definition at line 129 of file cargotype.h.
References array, and lengthof.
Referenced by FormatString().
SpriteID CargoSpec::GetCargoIcon | ( | ) | const |
Get sprite for showing cargo of this type.
Definition at line 178 of file cargotype.cpp.
References GetCustomCargoSprite(), and sprite.
Referenced by DrawCargoIconOverlay(), and DrawCargoIcons().
|
inline |
Determines index of this cargospec.
Definition at line 110 of file cargotype.h.
References array.
Referenced by BuildLinkStatsLegend(), PaymentRatesGraphWindow::DrawWidget(), TownViewWindow::DrawWidget(), TruncateCargo(), and IndustryProductionGraphWindow::UpdateStatistics().
|
inline |
Tests for validity of this cargospec.
Definition at line 120 of file cargotype.h.
References INVALID_CARGO_BITNUM.
Referenced by LinkGraphOverlay::AddLinks(), CargoChangeInfo(), LinkGraphOverlay::RebuildCache(), and StationsWndShowStationRating().
|
inlinestatic |
Returns an iterable ensemble of all valid CargoSpec.
from | index of the first CargoSpec to consider |
Definition at line 195 of file cargotype.h.
Referenced by BuildCargoTranslationMap(), CalculateRefitMasks(), FindFirstCargoWithTownAcceptanceEffect(), InitializeSortedCargoSpecs(), IndustryCargoesWindow::OnInit(), RecomputePrices(), and StationResolverObject::StationResolverObject().
|
inline |
Definition at line 147 of file cargotype.h.
uint64_t CargoSpec::WeightOfNUnitsInTrain | ( | uint32_t | n | ) | const |
Definition at line 257 of file cargotype.cpp.
|
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 134 of file cargotype.cpp.
|
friend |
Check for invalid cargoes.
Definition at line 9324 of file newgrf.cpp.
|
friend |
Definition at line 219 of file cargotype.h.
|
friend |
Set up the default cargo types for the given landscape type.
l | Landscape |
Definition at line 64 of file cargotype.cpp.
StringID CargoSpec::abbrev |
Two letter abbreviation for this cargo type.
Definition at line 97 of file cargotype.h.
Referenced by CargoChangeInfo(), LinkGraphLegendWindow::DrawWidget(), StationsWndShowStationRating(), and LinkGraphLegendWindow::UpdateWidgetSize().
|
staticprivate |
Array holding all CargoSpecs.
Definition at line 201 of file cargotype.h.
Referenced by Get(), GetArraySize(), and Index().
uint8_t CargoSpec::bitnum = INVALID_CARGO_BITNUM |
Cargo bit number, is INVALID_CARGO_BITNUM for a non-used spec.
Definition at line 78 of file cargotype.h.
Referenced by CargoChangeInfo(), and GenericScopeResolver::GetVariable().
uint8_t CargoSpec::callback_mask |
Bitmask of cargo callbacks that have to be called.
Definition at line 91 of file cargotype.h.
Referenced by CargoChangeInfo().
CargoClasses CargoSpec::classes |
Classes of this cargo type.
Definition at line 83 of file cargotype.h.
Referenced by CargoChangeInfo(), CargoSpecClassSorter(), CMSAMine(), GetRefitCostFactor(), and VehicleScopeResolver::GetVariable().
Money CargoSpec::current_payment |
Definition at line 104 of file cargotype.h.
const struct GRFFile* CargoSpec::grffile |
NewGRF where group belongs to.
Definition at line 101 of file cargotype.h.
Referenced by CargoChangeInfo().
const struct SpriteGroup* CargoSpec::group |
Definition at line 102 of file cargotype.h.
int32_t CargoSpec::initial_payment |
Initial payment rate before inflation is applied.
Definition at line 84 of file cargotype.h.
Referenced by CargoChangeInfo().
bool CargoSpec::is_freight |
Cargo type is considered to be freight (affects train freight multiplier).
Definition at line 87 of file cargotype.h.
Referenced by CargoChangeInfo().
CargoLabel CargoSpec::label |
Unique label of the cargo type.
Definition at line 77 of file cargotype.h.
Referenced by CargoChangeInfo(), and CargoResolverObject::GetDebugID().
|
inlinestaticprivate |
Translation map from CargoLabel to Cargo ID.
Definition at line 202 of file cargotype.h.
uint8_t CargoSpec::legend_colour |
Definition at line 79 of file cargotype.h.
uint16_t CargoSpec::multiplier = 0x100 |
Capacity multiplier for vehicles. (8 fractional bits)
Definition at line 82 of file cargotype.h.
Referenced by CargoChangeInfo(), Engine::DetermineCapacity(), and GetLoadAmount().
StringID CargoSpec::name |
Name of this type of cargo.
Definition at line 93 of file cargotype.h.
Referenced by BuildLinkStatsLegend(), BuildReplacementVehicle(), CargoChangeInfo(), CargoSpecNameSorter(), CargoesField::Draw(), IndustryViewWindow::DrawInfo(), NewGRFInspectWindow::DrawMainPanelWidget(), DrawOrderString(), DrawVehicleRefitWindow(), PaymentRatesGraphWindow::DrawWidget(), IndustryProductionGraphWindow::DrawWidget(), TownViewWindow::DrawWidget(), LinkGraphLegendWindow::OnTooltip(), CompanyStationsWindow::SetStringParameters(), SetupSubsidyDecodeParam(), and IndustryProductionGraphWindow::UpdateWidgetSize().
StringID CargoSpec::name_single |
Name of a single entity of this type of cargo.
Definition at line 94 of file cargotype.h.
Referenced by CargoChangeInfo().
StringID CargoSpec::quantifier |
Text for multiple units of cargo of this type.
Definition at line 96 of file cargotype.h.
Referenced by CargoChangeInfo(), and FormatString().
uint8_t CargoSpec::rating_colour |
Definition at line 80 of file cargotype.h.
SpriteID CargoSpec::sprite |
Icon to display this cargo type, may be 0xFFF
(which means to resolve an action123 chain).
Definition at line 99 of file cargotype.h.
Referenced by CargoChangeInfo(), and GetCargoIcon().
TownAcceptanceEffect CargoSpec::town_acceptance_effect |
The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
Definition at line 88 of file cargotype.h.
Referenced by AfterLoadGame(), CargoChangeInfo(), and DeliverGoods().
|
static |
List of cargo specs for each Town Product Effect.
Definition at line 27 of file cargotype.h.
Referenced by TownViewWindow::DrawWidget(), FindSubsidyPassengerRoute(), FindSubsidyTownCargoRoute(), TownViewWindow::GetDesiredInfoHeight(), InitializeSortedCargoSpecs(), TownGenerateCargoBinominal(), TownGenerateCargoOriginal(), and UpdateTownMaxPass().
TownProductionEffect CargoSpec::town_production_effect = INVALID_TPE |
The effect on town cargo production.
Definition at line 89 of file cargotype.h.
Referenced by CargoChangeInfo(), CargoesRow::ConnectIndustryProduced(), and IndustryCargoesWindow::HousesCanSupply().
uint16_t CargoSpec::town_production_multiplier = TOWN_PRODUCTION_DIVISOR |
Town production multipler, if commanded by TownProductionEffect.
Definition at line 90 of file cargotype.h.
Referenced by CargoChangeInfo().
uint8_t CargoSpec::transit_periods[2] |
Definition at line 85 of file cargotype.h.
StringID CargoSpec::units_volume |
Name of a single unit of cargo of this type.
Definition at line 95 of file cargotype.h.
Referenced by CargoChangeInfo(), and FormatString().
uint8_t CargoSpec::weight |
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
Definition at line 81 of file cargotype.h.
Referenced by CargoChangeInfo(), and VehicleScopeResolver::GetVariable().