|
OpenTTD Source 20261112-master-gbcbec5e63f
|
Types/functions related to cargoes. More...
#include "economy_type.h"#include "cargo_type.h"#include "gfx_type.h"#include "newgrf_callbacks.h"#include "strings_type.h"#include "landscape_type.h"Go to the source code of this file.
Data Structures | |
| struct | CargoSpec |
| Specification of a cargo type. More... | |
| struct | CargoSpec::Iterator |
| Iterator to iterate all valid CargoSpec. More... | |
| struct | CargoSpec::IterateWrapper |
| Iterable ensemble of all valid CargoSpec. More... | |
| struct | CargoTypeComparator |
| Comparator to sort CargoType by according to desired order. More... | |
Typedefs | |
| using | CargoClasses = EnumBitSet<CargoClass, uint16_t> |
Bitset of CargoClass elements. | |
Enumerations | |
| enum class | TownAcceptanceEffect : uint8_t { Begin = 0 , None = TownAcceptanceEffect::Begin , Passengers , Mail , Goods , Water , Food , End } |
| Town growth effect when delivering cargo. More... | |
| enum class | TownProductionEffect : uint8_t { None , Passengers , Mail , End , Invalid } |
| Town effect when producing cargo. More... | |
| enum class | CargoClass : uint8_t { Passengers = 0 , Mail = 1 , Express = 2 , Armoured = 3 , Bulk = 4 , PieceGoods = 5 , Liquid = 6 , Refrigerated = 7 , Hazardous = 8 , Covered = 9 , Oversized = 10 , Powderized = 11 , NotPourable = 12 , Potable = 13 , NonPotable = 14 , Special = 15 } |
| Cargo classes. More... | |
Functions | |
| void | SetupCargoForClimate (LandscapeType l) |
| Set up the default cargo types for the given landscape type. | |
| bool | IsDefaultCargo (CargoType cargo_type) |
| Test if a cargo is a default cargo type. | |
| void | BuildCargoLabelMap () |
| Build cargo label map. | |
| std::optional< std::string > | BuildCargoAcceptanceString (const CargoArray &acceptance, StringID label) |
| Build comma-separated cargo acceptance string. | |
| CargoType | GetCargoTypeByLabel (CargoLabel label) |
| Get cargo assigned to a label. | |
| Dimension | GetLargestCargoIconSize () |
| Get dimensions of largest cargo icon. | |
| void | InitializeSortedCargoSpecs () |
| Initialize the list of sorted cargo specifications. | |
| bool | IsCargoInClass (CargoType cargo, CargoClasses cc) |
| Does a given cargo have any cargo class from cc. | |
Variables | |
| static const uint8_t | INVALID_CARGO_BITNUM = 0xFF |
| Constant representing invalid cargo bit number. | |
| static const uint | TOWN_PRODUCTION_DIVISOR = 256 |
| By what factor divide town production. | |
| CargoTypes | _cargo_mask |
| Bitmask of cargo types available. | |
| CargoTypes | _standard_cargo_mask |
| Bitmask of real cargo types available. | |
| std::array< uint8_t, NUM_CARGO > | _sorted_cargo_types |
| Sort order of cargoes by cargo type. | |
| std::vector< const CargoSpec * > | _sorted_cargo_specs |
| Cargo specifications sorted alphabetically by name. | |
| std::span< const CargoSpec * > | _sorted_standard_cargo_specs |
| Standard cargo specifications sorted alphabetically by name. | |
Types/functions related to cargoes.
Definition in file cargotype.h.
| using CargoClasses = EnumBitSet<CargoClass, uint16_t> |
Bitset of CargoClass elements.
Definition at line 69 of file cargotype.h.
|
strong |
Cargo classes.
Definition at line 49 of file cargotype.h.
|
strong |
Town growth effect when delivering cargo.
Definition at line 21 of file cargotype.h.
|
strong |
Town effect when producing cargo.
| Enumerator | |
|---|---|
| None | Town will not produce this cargo type. |
| Passengers | Cargo behaves passenger-like for production. |
Cargo behaves mail-like for production. | |
| End | End marker. |
| Invalid | Invalid town production effect. Used as a sentinel to indicate if a NewGRF has explicitly set an effect. This does not 'exist' after cargo types are finalised. |
Definition at line 35 of file cargotype.h.
| std::optional< std::string > BuildCargoAcceptanceString | ( | const CargoArray & | acceptance, |
| StringID | label ) |
Build comma-separated cargo acceptance string.
| acceptance | CargoArray filled with accepted cargo. |
| label | Label to prefix cargo acceptance list. |
Definition at line 271 of file cargotype.cpp.
References _sorted_cargo_specs, GetListSeparator(), and GetString().
Referenced by BuildHouseWindow::GetHouseInformation(), and LandInfoWindow::OnInit().
| void BuildCargoLabelMap | ( | ) |
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 249 of file cargotype.cpp.
References _sorted_cargo_specs, and _sorted_standard_cargo_specs.
Referenced by CargoReserveInfo(), and CargoSpec::SetupCargoForClimate.
|
inline |
Get cargo assigned to a label.
| label | The label to deduce cargo for. |
Definition at line 268 of file cargotype.h.
Referenced by AddAcceptedCargo_Object(), AddAcceptedCargoOfHouse(), AddProducedCargo_Object(), CalculateRefitMasks(), ChangeIndustryProduction(), CmdBuildAircraft(), CmdBuildVehicle(), Engine::DetermineCapacity(), DrawAircraftPurchaseInfo(), FinaliseHouseArray(), FinaliseIndustriesArray(), GetActiveCargoLabel(), RefitWindow::GetCapacityString(), GetCargoTranslation(), GetEngineLiveryScheme(), TownScopeResolver::GetVariable(), RefitVehicle(), TileLoop_Object(), TownHouseChangeInfo(), and TownProductionHistoryHelper().
| Dimension GetLargestCargoIconSize | ( | ) |
Get dimensions of largest cargo icon.
Definition at line 162 of file cargotype.cpp.
References _sorted_cargo_specs, GetSpriteSize(), and maxdim().
Referenced by BaseVehicleListWindow::BuildCargoDropDownList(), DrawAircraftImage(), IndustryCargoesWindow::OnClick(), IndustryCargoesWindow::OnInit(), IndustryViewWindow::OnInit(), StationViewWindow::OnInit(), and SubsidyListWindow::OnInit().
| void InitializeSortedCargoSpecs | ( | ) |
Initialize the list of sorted cargo specifications.
Definition at line 222 of file cargotype.cpp.
References _sorted_cargo_specs, _sorted_cargo_types, _standard_cargo_mask, CargoSpecClassSorter(), Invalid, CargoSpec::Iterate(), Special, and CargoSpec::town_production_cargoes.
Referenced by AfterLoadGRFs(), and ReadLanguagePack().
|
inline |
Does a given cargo have any cargo class from cc.
| cargo | The cargo type to test. |
| cc | The cargo classes to check for. |
true iff the cargo type fits in the classes. Definition at line 288 of file cargotype.h.
References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), CargoSpec::classes, and CargoSpec::Get().
Referenced by CargoFilterSingle(), Vehicle::Crash(), Engine::DetermineCapacity(), MultiCommodityFlow::Dijkstra(), DrawStationCoverageAreaText(), GetEngineLiveryScheme(), RoadVehicle::IsBus(), LoadUnloadVehicle(), and UpdateStationAcceptance().
| bool IsDefaultCargo | ( | CargoType | cargo_type | ) |
Test if a cargo is a default cargo type.
| cargo_type | Cargo type. |
Definition at line 149 of file cargotype.cpp.
References _default_cargo_labels, and CargoSpec::Get().
Referenced by CalculateRefitMasks().
| void SetupCargoForClimate | ( | LandscapeType | l | ) |
Set up the default cargo types for the given landscape type.
| l | Landscape to set up the default cargoes for. |
Definition at line 248 of file cargotype.cpp.
Referenced by ResetNewGRFData().
|
extern |
Bitmask of cargo types available.
This includes phony cargoes like regearing cargoes. Initialized during a call to SetupCargoForClimate.
Definition at line 30 of file cargotype.cpp.
Referenced by CalculateRefitMasks(), CargoReserveInfo(), CompanyStationsWindow::GetWidgetString(), CompanyStationsWindow::OnDropdownSelect(), CargoSpec::SetupCargoForClimate, and ShowRefitOptionsList().
|
extern |
Cargo specifications sorted alphabetically by name.
Definition at line 189 of file cargotype.cpp.
Referenced by BuildCargoAcceptanceString(), BaseVehicleListWindow::BuildCargoDropDownList(), BuildCargoLabelMap(), BuildLinkStatsLegend(), RefitWindow::BuildRefitList(), IndustryCargoesWindow::CountHouseCargoTypes(), DrawRoadVehDetails(), DrawTrainDetails(), BaseCargoGraphWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), FormatString(), BaseCargoGraphWindow::GetDatasetIndex(), GetLargestCargoIconSize(), GetMaximalSizeCargoString(), InitializeSortedCargoSpecs(), BaseCargoGraphWindow::OnClick(), LinkGraphLegendWindow::OnInvalidateData(), DepotWindow::OnRightClick(), LinkGraphLegendWindow::OnTooltip(), LinkGraphLegendWindow::SetOverlay(), LinkGraphLegendWindow::UpdateOverlayCargoes(), and LinkGraphLegendWindow::UpdateWidgetSize().
|
extern |
Sort order of cargoes by cargo type.
Definition at line 188 of file cargotype.cpp.
Referenced by InitializeSortedCargoSpecs(), and CargoTypeComparator::operator()().
|
extern |
Standard cargo specifications sorted alphabetically by name.
Definition at line 190 of file cargotype.cpp.
Referenced by BuildCargoLabelMap(), StationViewWindow::DrawCargoRatings(), CompanyStationsWindow::DrawWidget(), IndustryCargoesWindow::OnClick(), PaymentRatesGraphWindow::UpdatePaymentRates(), and CompanyStationsWindow::UpdateWidgetSize().
|
extern |
Bitmask of real cargo types available.
Phony cargoes like regearing cargoes are excluded.
Definition at line 35 of file cargotype.cpp.
Referenced by CalculateRefitMasks(), CargoAndEngineFilter(), PaymentRatesGraphWindow::GetCargoTypes(), InitializeSortedCargoSpecs(), and BuildVehicleWindow::SetCargoFilterArray().
|
static |
Constant representing invalid cargo bit number.
Definition at line 71 of file cargotype.h.
Referenced by CargoSpec::IsValid().
|
static |
By what factor divide town production.
Definition at line 73 of file cargotype.h.
Referenced by TownGenerateCargoBinomial(), and TownGenerateCargoOriginal().