|
OpenTTD Source 20261112-master-gbcbec5e63f
|
Specification of a cargo type. More...
#include <cargotype.h>
Data Structures | |
| struct | Iterator |
| Iterator to iterate all valid CargoSpec. More... | |
| struct | IterateWrapper |
| Iterable ensemble of all valid CargoSpec. More... | |
Public Member Functions | |
| CargoType | 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 |
| Calculate the weight of n units of cargo. | |
| uint64_t | WeightOfNUnitsInTrain (uint32_t n) const |
| Calculate the weight of n units of cargo inside a train wagon. | |
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 type. | |
| 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. | |
| PixelColour | legend_colour |
| Colour in legends and graphs. | |
| PixelColour | rating_colour |
| Colour used for box representing the amount of cargo waiting at the station in the station rating view. | |
| 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] |
| Values used to calculate timefactor for cargo payment alghoritm. | |
| 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 = TownProductionEffect::Invalid |
| The effect on town cargo production. | |
| uint16_t | town_production_multiplier = TOWN_PRODUCTION_DIVISOR |
| Town production multiplier, if commanded by TownProductionEffect. | |
| CargoCallbackMasks | 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 |
| Group of sprites used for drawing the cargo. | |
| Money | current_payment |
| Payment rate scaled by inflation. | |
Static Public Attributes | |
| static EnumIndexArray< std::vector< const CargoSpec * >, TownProductionEffect, TownProductionEffect::End > | 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, CargoType > | label_map {} |
| Translation map from CargoLabel to Cargo type. | |
Friends | |
| void | SetupCargoForClimate (LandscapeType l) |
| Set up the default cargo types for the given landscape type. | |
| void | BuildCargoLabelMap () |
| Build cargo label map. | |
| CargoType | GetCargoTypeByLabel (CargoLabel label) |
| Get cargo assigned to a label. | |
| 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 type.
| index | ID of cargo. |
Definition at line 140 of file cargotype.h.
References array, and lengthof.
Referenced by LinkGraphOverlay::AddLinks(), AfterLoadGame(), Subsidy::AwardTo(), BuildReplacementVehicle(), CargoReserveInfo(), CmdCreateSubsidy(), CMSAMine(), CreateSubsidy(), DeliverGoods(), Engine::DetermineCapacity(), AcceptsProducesChainField::Draw(), CargoChainField::Draw(), ConnectionChainField::Draw(), DrawCargoIconOverlay(), StationViewWindow::DrawCargoIcons(), DrawOrderString(), DrawVehicleRefitWindow(), SubsidyListWindow::DrawWidget(), FindSubsidyTownCargoRoute(), FormatString(), FreightWagonMult(), GetEngineLiveryScheme(), GetLoadAmount(), RoadVehicle::GetMaxWeight(), Train::GetMaxWeight(), GetRefitCostFactor(), GenericScopeResolver::GetVariable(), VehicleScopeResolver::GetVariable(), RoadVehicle::GetWeight(), Train::GetWeight(), CompanyStationsWindow::GetWidgetString(), IndustryCargoesWindow::GetWidgetString(), IsCargoInClass(), IsDefaultCargo(), BuildIndustryWindow::MakeCargoListString(), CargoMapSpriteGroupHandler::MapDefault(), IndustryCargoesWindow::OnTooltip(), CargoSpec::Iterator::operator*(), LinkGraphOverlay::RebuildCache(), LinkRefresher::RefreshLinks(), ReportNewsProductionChangeIndustry(), StationsWndShowStationRating(), IndustryProductionGraphWindow::UpdateStatistics(), TownCargoGraphWindow::UpdateStatistics(), BaseCargoGraphWindow::UpdateWidgetSize(), and CargoSpec::Iterator::ValidateIndex().
|
inlinestatic |
Total number of cargospecs, both valid and invalid.
Definition at line 129 of file cargotype.h.
References array, and lengthof.
Referenced by CargoSpec::IterateWrapper::end(), FormatString(), and CargoSpec::Iterator::ValidateIndex().
| SpriteID CargoSpec::GetCargoIcon | ( | ) | const |
Get sprite for showing cargo of this type.
Definition at line 175 of file cargotype.cpp.
References GetCustomCargoSprite(), SPR_CARGO_GOODS, and sprite.
Referenced by DrawCargoIconOverlay(), and StationViewWindow::DrawCargoIcons().
|
inline |
Determines index of this cargospec.
Definition at line 110 of file cargotype.h.
References array.
Referenced by BuildLinkStatsLegend(), CargoReserveInfo(), TownViewWindow::DrawWidget(), TruncateCargo(), IndustryProductionGraphWindow::UpdateStatistics(), and TownCargoGraphWindow::UpdateStatistics().
|
inline |
Tests for validity of this cargospec.
Definition at line 120 of file cargotype.h.
References INVALID_CARGO_BITNUM.
Referenced by CargoReserveInfo(), StationsWndShowStationRating(), and CargoSpec::Iterator::ValidateIndex().
|
inlinestatic |
Returns an iterable ensemble of all valid CargoSpec.
| from | index of the first CargoSpec to consider |
Definition at line 239 of file cargotype.h.
Referenced by BuildCargoTranslationMap(), CalculateRefitMasks(), ConDumpCargoTypes(), FindFirstCargoWithTownAcceptanceEffect(), InitializeSortedCargoSpecs(), RecomputePrices(), and UpdateStationRating().
|
inline |
Calculate the weight of n units of cargo.
| n | For how many units of cargo calculate the weight. |
Definition at line 153 of file cargotype.h.
Referenced by RoadVehicle::GetMaxWeight(), RoadVehicle::GetWeight(), and WeightOfNUnitsInTrain().
| uint64_t CargoSpec::WeightOfNUnitsInTrain | ( | uint32_t | n | ) | const |
Calculate the weight of n units of cargo inside a train wagon.
| n | For how many units of cargo calculate the weight. |
Definition at line 259 of file cargotype.cpp.
References _settings_game, is_freight, and WeightOfNUnits().
Referenced by Train::GetMaxWeight(), and Train::GetWeight().
|
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 131 of file cargotype.cpp.
References array, CT_INVALID, and label_map.
|
friend |
Check for invalid cargoes.
Definition at line 938 of file newgrf.cpp.
References array, CT_MAIL, CT_PASSENGERS, Invalid, Mail, None, and Passengers.
|
friend |
Get cargo assigned to a label.
| label | The label to deduce cargo for. |
Definition at line 268 of file cargotype.h.
References INVALID_CARGO, label, and label_map.
|
friend |
Set up the default cargo types for the given landscape type.
| l | Landscape to set up the default cargoes for. |
Definition at line 61 of file cargotype.cpp.
References _cargo_mask, _climate_dependent_cargo_labels, _climate_independent_cargo_labels, _default_cargo, _default_cargo_labels, _default_climate_cargo, array, BuildCargoLabelMap(), CT_INVALID, label, and to_underlying().
| StringID CargoSpec::abbrev |
Two letter abbreviation for this cargo type.
Definition at line 97 of file cargotype.h.
Referenced by CargoReserveInfo(), LinkGraphLegendWindow::DrawWidget(), StationsWndShowStationRating(), and LinkGraphLegendWindow::UpdateWidgetSize().
|
staticprivate |
Array holding all CargoSpecs.
Definition at line 245 of file cargotype.h.
Referenced by BuildCargoLabelMap, FinaliseCargoArray, Get(), GetArraySize(), Index(), and SetupCargoForClimate.
| 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 CargoReserveInfo(), CargoSpecNameSorter(), and GenericScopeResolver::GetVariable().
| CargoCallbackMasks CargoSpec::callback_mask |
Bitmask of cargo callbacks that have to be called.
Definition at line 91 of file cargotype.h.
Referenced by CargoReserveInfo().
| CargoClasses CargoSpec::classes |
Classes of this cargo type.
Definition at line 83 of file cargotype.h.
Referenced by CargoReserveInfo(), CargoSpecClassSorter(), GetRefitCostFactor(), VehicleScopeResolver::GetVariable(), and IsCargoInClass().
| Money CargoSpec::current_payment |
Payment rate scaled by inflation.
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 CargoReserveInfo(), and CargoMapSpriteGroupHandler::MapDefault().
| const struct SpriteGroup* CargoSpec::group |
Group of sprites used for drawing the cargo.
Definition at line 102 of file cargotype.h.
Referenced by CargoResolverObject::CargoResolverObject(), and CargoMapSpriteGroupHandler::MapDefault().
| int32_t CargoSpec::initial_payment |
Initial payment rate before inflation is applied.
Definition at line 84 of file cargotype.h.
Referenced by CargoReserveInfo().
| 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 CargoReserveInfo(), and WeightOfNUnitsInTrain().
| CargoLabel CargoSpec::label |
Unique label of the cargo type.
Definition at line 77 of file cargotype.h.
Referenced by CargoReserveInfo(), GetCargoTypeByLabel, and SetupCargoForClimate.
|
inlinestaticprivate |
Translation map from CargoLabel to Cargo type.
Definition at line 246 of file cargotype.h.
Referenced by BuildCargoLabelMap, and GetCargoTypeByLabel.
| PixelColour CargoSpec::legend_colour |
Colour in legends and graphs.
Definition at line 79 of file cargotype.h.
Referenced by BuildLinkStatsLegend(), CargoReserveInfo(), ConnectionChainField::Draw(), LinkGraphLegendWindow::DrawWidget(), IndustryProductionGraphWindow::UpdateStatistics(), and TownCargoGraphWindow::UpdateStatistics().
| uint16_t CargoSpec::multiplier = 0x100 |
Capacity multiplier for vehicles. (8 fractional bits).
Definition at line 82 of file cargotype.h.
Referenced by CargoReserveInfo(), and Engine::DetermineCapacity().
| StringID CargoSpec::name |
Name of this type of cargo.
Definition at line 93 of file cargotype.h.
Referenced by Subsidy::AwardTo(), BuildLinkStatsLegend(), CargoReserveInfo(), CargoSpecNameSorter(), CreateSubsidy(), SubsidyListWindow::DrawWidget(), TownViewWindow::DrawWidget(), LinkGraphLegendWindow::OnTooltip(), and BaseCargoGraphWindow::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 CargoReserveInfo().
| StringID CargoSpec::quantifier |
Text for multiple units of cargo of this type.
Definition at line 96 of file cargotype.h.
Referenced by CargoReserveInfo().
| PixelColour CargoSpec::rating_colour |
Colour used for box representing the amount of cargo waiting at the station in the station rating view.
Definition at line 80 of file cargotype.h.
Referenced by CargoReserveInfo(), and StationsWndShowStationRating().
| 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 CargoReserveInfo(), 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(), CargoReserveInfo(), and DeliverGoods().
|
inlinestatic |
List of cargo specs for each Town Product Effect.
Definition at line 242 of file cargotype.h.
Referenced by AddProducedCargo_Town(), TownViewWindow::DrawWidget(), FindSubsidyPassengerRoute(), FindSubsidyTownCargoRoute(), TownViewWindow::GetDesiredInfoHeight(), GetProducedCargoOfHouse(), InitializeSortedCargoSpecs(), TownGenerateCargoBinomial(), TownGenerateCargoOriginal(), and UpdateTownMaxPass().
| TownProductionEffect CargoSpec::town_production_effect = TownProductionEffect::Invalid |
The effect on town cargo production.
Definition at line 89 of file cargotype.h.
Referenced by CargoReserveInfo().
| uint16_t CargoSpec::town_production_multiplier = TOWN_PRODUCTION_DIVISOR |
Town production multiplier, if commanded by TownProductionEffect.
Definition at line 90 of file cargotype.h.
Referenced by CargoReserveInfo().
| uint8_t CargoSpec::transit_periods[2] |
Values used to calculate timefactor for cargo payment alghoritm.
Definition at line 85 of file cargotype.h.
Referenced by CargoReserveInfo().
| StringID CargoSpec::units_volume |
Name of a single unit of cargo of this type.
Definition at line 95 of file cargotype.h.
Referenced by CargoReserveInfo(), 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 CargoReserveInfo(), and VehicleScopeResolver::GetVariable().