OpenTTD Source: src/cargo_type.h File Reference

OpenTTD Source 15.3

Data Structures | Namespaces | Typedefs | Enumerations | Functions | Variables
cargo_type.h File Reference

Types related to cargoes... More...

`#include "core/strong_typedef_type.hpp"`

Go to the source code of this file.

## Data Structures
struct | CargoArray
| Class for storing amounts of cargo. More...

## Namespaces
namespace | CargoFilterCriteria
| Special cargo filter criteria.

## Typedefs
using | CargoLabel = StrongType::Typedef< uint32_t, struct CargoLabelTag, StrongType::Compare >
| Globally unique label of a cargo type.
using | CargoType = uint8_t
| Cargo slots to indicate a cargo type within a game.
typedef uint64_t | CargoTypes

## Enumerations
enum | MixedCargoType : uint8_t { MCT_LIVESTOCK_FRUIT , MCT_GRAIN_WHEAT_MAIZE , MCT_VALUABLES_GOLD_DIAMONDS }
| Mixed cargo types for definitions with cargo that can vary depending on climate. More...

## Functions
bool | IsValidCargoType (CargoType cargo)
| Test whether cargo type is not INVALID_CARGO.

## Variables
static constexpr CargoLabel | CT_PASSENGERS {'PASS'}
| Available types of cargo Labels may be re-used between different climates.
static constexpr CargoLabel | CT_COAL {'COAL'}
static constexpr CargoLabel | CT_MAIL {'MAIL'}
static constexpr CargoLabel | CT_OIL {'OIL_'}
static constexpr CargoLabel | CT_LIVESTOCK {'LVST'}
static constexpr CargoLabel | CT_GOODS {'GOOD'}
static constexpr CargoLabel | CT_GRAIN {'GRAI'}
static constexpr CargoLabel | CT_WOOD {'WOOD'}
static constexpr CargoLabel | CT_IRON_ORE {'IORE'}
static constexpr CargoLabel | CT_STEEL {'STEL'}
static constexpr CargoLabel | CT_VALUABLES {'VALU'}
static constexpr CargoLabel | CT_WHEAT {'WHEA'}
static constexpr CargoLabel | CT_PAPER {'PAPR'}
static constexpr CargoLabel | CT_GOLD {'GOLD'}
static constexpr CargoLabel | CT_FOOD {'FOOD'}
static constexpr CargoLabel | CT_RUBBER {'RUBR'}
static constexpr CargoLabel | CT_FRUIT {'FRUT'}
static constexpr CargoLabel | CT_MAIZE {'MAIZ'}
static constexpr CargoLabel | CT_COPPER_ORE {'CORE'}
static constexpr CargoLabel | CT_WATER {'WATR'}
static constexpr CargoLabel | CT_DIAMONDS {'DIAM'}
static constexpr CargoLabel | CT_SUGAR {'SUGR'}
static constexpr CargoLabel | CT_TOYS {'TOYS'}
static constexpr CargoLabel | CT_BATTERIES {'BATT'}
static constexpr CargoLabel | CT_CANDY {'SWET'}
static constexpr CargoLabel | CT_TOFFEE {'TOFF'}
static constexpr CargoLabel | CT_COLA {'COLA'}
static constexpr CargoLabel | CT_COTTON_CANDY {'CTCD'}
static constexpr CargoLabel | CT_BUBBLES {'BUBL'}
static constexpr CargoLabel | CT_PLASTIC {'PLST'}
static constexpr CargoLabel | CT_FIZZY_DRINKS {'FZDR'}
static constexpr CargoLabel | CT_NONE = CT_PASSENGERS
| Dummy label for engines that carry no cargo; they actually carry 0 passengers.
static constexpr CargoLabel | CT_INVALID {UINT32_MAX}
| Invalid cargo type.
static const CargoType | NUM_ORIGINAL_CARGO = 12
| Original number of cargo types.
static const CargoType | NUM_CARGO = 64
| Maximum number of cargo types in a game.
static const CargoType | CARGO_AUTO_REFIT = 0xFD
| Automatically choose cargo type when doing auto refitting.
static const CargoType | CARGO_NO_REFIT = 0xFE
| Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
static const CargoType | INVALID_CARGO = UINT8_MAX
static constexpr CargoType | CargoFilterCriteria::CF_ANY = NUM_CARGO
| Show all items independent of carried cargo (i.e. no filtering)
static constexpr CargoType | CargoFilterCriteria::CF_NONE = NUM_CARGO + 1
| Show only items which do not carry cargo (e.g. train engines)
static constexpr CargoType | CargoFilterCriteria::CF_ENGINES = NUM_CARGO + 2
| Show only engines (for rail vehicles only)
static constexpr CargoType | CargoFilterCriteria::CF_FREIGHT = NUM_CARGO + 3
| Show only vehicles which carry any freight (non-passenger) cargo.
static constexpr CargoType | CargoFilterCriteria::CF_NO_RATING = NUM_CARGO + 4
| Show items with no rating (station list)
static constexpr CargoType | CargoFilterCriteria::CF_SELECT_ALL = NUM_CARGO + 5
| Select all items (station list)
static constexpr CargoType | CargoFilterCriteria::CF_EXPAND_LIST = NUM_CARGO + 6
| Expand list to show all items (station list)
static const CargoTypes | ALL_CARGOTYPES = (CargoTypes)UINT64_MAX

## Detailed Description

Types related to cargoes...

Definition in file cargo_type.h.

## Typedef Documentation

## ◆ CargoLabel

using CargoLabel = StrongType::Typedef<uint32_t, struct CargoLabelTag, StrongType::Compare>

Globally unique label of a cargo type.

Definition at line 16 of file cargo_type.h.

## ◆ CargoType

using CargoType = uint8_t

Cargo slots to indicate a cargo type within a game.

Definition at line 21 of file cargo_type.h.

## ◆ CargoTypes

typedef uint64_t CargoTypes

Definition at line 106 of file cargo_type.h.

## Enumeration Type Documentation

## ◆ MixedCargoType

enum MixedCargoType : uint8_t

Mixed cargo types for definitions with cargo that can vary depending on climate.

Enumerator
MCT_LIVESTOCK_FRUIT | Cargo can be livestock or fruit.
MCT_GRAIN_WHEAT_MAIZE | Cargo can be grain, wheat or maize.
MCT_VALUABLES_GOLD_DIAMONDS | Cargo can be valuables, gold or diamonds.

Definition at line 82 of file cargo_type.h.

## Function Documentation

## ◆ IsValidCargoType()

bool IsValidCargoType | ( | CargoType | cargo | ) |
| inline

Test whether cargo type is not INVALID_CARGO.

Definition at line 104 of file cargo_type.h.

Referenced by AddAcceptedCargoSetMask(), AddArticulatedParts(), AfterLoadGame(), AircraftVehicleChangeInfo(), BuildReplacementVehicle(), CalculateRefitMasks(), CanCargoServiceIndustry(), Engine::CanCarryCargo(), ChangeIndustryProduction(), ChopLumberMillTrees(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdBuildVehicle(), CmdCloneVehicle(), CMSAMine(), CargoesField::ConnectCargo(), Engine::DetermineCapacity(), DoCreateNewIndustry(), CargoesField::Draw(), DrawCargoIconOverlay(), IndustryViewWindow::DrawInfo(), FinaliseHouseArray(), FinaliseIndustriesArray(), FindSubsidyIndustryCargoRoute(), FormatString(), GetAllCargoSuffixes(), GetCapacityOfArticulatedParts(), Industry::GetCargoAccepted(), Industry::GetCargoAccepted(), Industry::GetCargoProduced(), Industry::GetCargoProduced(), GetCargoSuffix(), GetCargoSummaryOfArticulatedVehicle(), IndustryDirectoryWindow::GetCargoTransportedPercentsIfValid(), GetCargoTypesOfArticulatedParts(), GetCargoTypesOfArticulatedVehicle(), GetEngineLiveryScheme(), IndustryDirectoryWindow::GetIndustryString(), GetNewCargoTypeForReplace(), GetProducedCargoOfHouse(), GetProductionAroundTiles(), VehicleScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), GetVehicleDefaultCapacity(), IndustryCargoesWindow::HasCommonValidCargo(), IndustryCargoesWindow::HousesCanAccept(), IndustryCargoesWindow::HousesCanSupply(), IndustryProductionCallback(), IndustryDirectoryWindow::IndustryProductionSorter(), Industry::IsCargoAccepted(), Industry::IsCargoProduced(), IsEngineRefittable(), INDYChunkHandler::Load(), CargoesField::MakeCargo(), BuildIndustryWindow::MakeCargoListString(), Vehicle::NeedsServicing(), IndustryViewWindow::OnClick(), IndustryCargoesWindow::OnClick(), IndustryCargoesWindow::OnInit(), IndustryCargoesWindow::OnTooltip(), ProduceIndustryGoodsHelper(), RailVehicleChangeInfo(), RefitVehicle(), RoadVehicleChangeInfo(), ShipVehicleChangeInfo(), TileLoop_Town(), TownHouseChangeInfo(), TrainDetailsCapacityTab(), TrainDetailsCargoTab(), TranslateRefitMask(), TransportIndustryGoods(), TriggerIndustryProduction(), TriggerRoadStopRandomisation(), TriggerStationRandomisation(), and UpdateIndustryStatistics().

## Variable Documentation

## ◆ ALL_CARGOTYPES

const CargoTypes ALL_CARGOTYPES = (CargoTypes)UINT64_MAX
| static

Definition at line 108 of file cargo_type.h.

## ◆ CARGO_AUTO_REFIT

const CargoType CARGO_AUTO_REFIT = 0xFD
| static

Automatically choose cargo type when doing auto refitting.

Definition at line 76 of file cargo_type.h.

Referenced by CmdOrderRefit(), HandleStationRefit(), Order::IsAutoRefit(), Order::IsRefit(), LoadUnloadVehicle(), and OrdersWindow::OrderClick_Refit().

## ◆ CARGO_NO_REFIT

const CargoType CARGO_NO_REFIT = 0xFE
| static

Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).

Definition at line 77 of file cargo_type.h.

Referenced by AfterLoadGame(), BuildReplacementVehicle(), CmdInsertOrder(), CmdModifyOrder(), CmdOrderRefit(), GetNewCargoTypeForReplace(), and OrdersWindow::OrderClick_Refit().

## ◆ CT_BATTERIES

constexpr CargoLabel CT_BATTERIES {'BATT'}
| staticconstexpr

Definition at line 58 of file cargo_type.h.

## ◆ CT_BUBBLES

constexpr CargoLabel CT_BUBBLES {'BUBL'}
| staticconstexpr

Definition at line 63 of file cargo_type.h.

## ◆ CT_CANDY

constexpr CargoLabel CT_CANDY {'SWET'}
| staticconstexpr

Definition at line 59 of file cargo_type.h.

## ◆ CT_COAL

constexpr CargoLabel CT_COAL {'COAL'}
| staticconstexpr

Definition at line 30 of file cargo_type.h.

## ◆ CT_COLA

constexpr CargoLabel CT_COLA {'COLA'}
| staticconstexpr

Definition at line 61 of file cargo_type.h.

## ◆ CT_COPPER_ORE

constexpr CargoLabel CT_COPPER_ORE {'CORE'}
| staticconstexpr

Definition at line 51 of file cargo_type.h.

## ◆ CT_COTTON_CANDY

constexpr CargoLabel CT_COTTON_CANDY {'CTCD'}
| staticconstexpr

Definition at line 62 of file cargo_type.h.

## ◆ CT_DIAMONDS

constexpr CargoLabel CT_DIAMONDS {'DIAM'}
| staticconstexpr

Definition at line 53 of file cargo_type.h.

## ◆ CT_FIZZY_DRINKS

constexpr CargoLabel CT_FIZZY_DRINKS {'FZDR'}
| staticconstexpr

Definition at line 65 of file cargo_type.h.

## ◆ CT_FOOD

constexpr CargoLabel CT_FOOD {'FOOD'}
| staticconstexpr

Definition at line 45 of file cargo_type.h.

## ◆ CT_FRUIT

constexpr CargoLabel CT_FRUIT {'FRUT'}
| staticconstexpr

Definition at line 49 of file cargo_type.h.

## ◆ CT_GOLD

constexpr CargoLabel CT_GOLD {'GOLD'}
| staticconstexpr

Definition at line 44 of file cargo_type.h.

## ◆ CT_GOODS

constexpr CargoLabel CT_GOODS {'GOOD'}
| staticconstexpr

Definition at line 34 of file cargo_type.h.

## ◆ CT_GRAIN

constexpr CargoLabel CT_GRAIN {'GRAI'}
| staticconstexpr

Definition at line 35 of file cargo_type.h.

## ◆ CT_INVALID

constexpr CargoLabel CT_INVALID {UINT32_MAX}
| staticconstexpr

Invalid cargo type.

Definition at line 70 of file cargo_type.h.

Referenced by CalculateRefitMasks(), GetActiveCargoLabel(), IndustriesChangeInfo(), IndustrytilesChangeInfo(), MaybeInstallFallbackCargoLabel(), RailVehicleChangeInfo(), RoadVehicleChangeInfo(), ShipVehicleChangeInfo(), and TownHouseChangeInfo().

## ◆ CT_IRON_ORE

constexpr CargoLabel CT_IRON_ORE {'IORE'}
| staticconstexpr

Definition at line 37 of file cargo_type.h.

## ◆ CT_LIVESTOCK

constexpr CargoLabel CT_LIVESTOCK {'LVST'}
| staticconstexpr

Definition at line 33 of file cargo_type.h.

## ◆ CT_MAIL

constexpr CargoLabel CT_MAIL {'MAIL'}
| staticconstexpr

Definition at line 31 of file cargo_type.h.

## ◆ CT_MAIZE

constexpr CargoLabel CT_MAIZE {'MAIZ'}
| staticconstexpr

Definition at line 50 of file cargo_type.h.

## ◆ CT_NONE

constexpr CargoLabel CT_NONE = CT_PASSENGERS
| staticconstexpr

Dummy label for engines that carry no cargo; they actually carry 0 passengers.

Definition at line 68 of file cargo_type.h.

## ◆ CT_OIL

constexpr CargoLabel CT_OIL {'OIL_'}
| staticconstexpr

Definition at line 32 of file cargo_type.h.

## ◆ CT_PAPER

constexpr CargoLabel CT_PAPER {'PAPR'}
| staticconstexpr

Definition at line 43 of file cargo_type.h.

## ◆ CT_PASSENGERS

constexpr CargoLabel CT_PASSENGERS {'PASS'}
| staticconstexpr

Available types of cargo Labels may be re-used between different climates.

Definition at line 29 of file cargo_type.h.

Referenced by CalculateRefitMasks(), ChangeIndustryProduction(), Engine::DetermineCapacity(), and TownScopeResolver::GetVariable().

## ◆ CT_PLASTIC

constexpr CargoLabel CT_PLASTIC {'PLST'}
| staticconstexpr

Definition at line 64 of file cargo_type.h.

## ◆ CT_RUBBER

constexpr CargoLabel CT_RUBBER {'RUBR'}
| staticconstexpr

Definition at line 48 of file cargo_type.h.

## ◆ CT_STEEL

constexpr CargoLabel CT_STEEL {'STEL'}
| staticconstexpr

Definition at line 38 of file cargo_type.h.

## ◆ CT_SUGAR

constexpr CargoLabel CT_SUGAR {'SUGR'}
| staticconstexpr

Definition at line 56 of file cargo_type.h.

## ◆ CT_TOFFEE

constexpr CargoLabel CT_TOFFEE {'TOFF'}
| staticconstexpr

Definition at line 60 of file cargo_type.h.

## ◆ CT_TOYS

constexpr CargoLabel CT_TOYS {'TOYS'}
| staticconstexpr

Definition at line 57 of file cargo_type.h.

## ◆ CT_VALUABLES

constexpr CargoLabel CT_VALUABLES {'VALU'}
| staticconstexpr

Definition at line 39 of file cargo_type.h.

## ◆ CT_WATER

constexpr CargoLabel CT_WATER {'WATR'}
| staticconstexpr

Definition at line 52 of file cargo_type.h.

## ◆ CT_WHEAT

constexpr CargoLabel CT_WHEAT {'WHEA'}
| staticconstexpr

Definition at line 42 of file cargo_type.h.

## ◆ CT_WOOD

constexpr CargoLabel CT_WOOD {'WOOD'}
| staticconstexpr

Definition at line 36 of file cargo_type.h.

## ◆ INVALID_CARGO

const CargoType INVALID_CARGO = UINT8_MAX
| static

Definition at line 79 of file cargo_type.h.

## ◆ NUM_CARGO

const CargoType NUM_CARGO = 64
| static

Maximum number of cargo types in a game.

Definition at line 73 of file cargo_type.h.

Referenced by StationViewWindow::BuildCargoList(), CompanyStationsWindow::BuildStationsList(), CalculateRefitMasks(), CargoReserveInfo(), CheckConsistencyOfArticulatedVehicle(), CmdBuildVehicle(), CmdCreateSubsidy(), CmdOrderRefit(), CmdRefitVehicle(), DeleteStaleLinks(), BaseGraphWindow::DrawGraph(), DrawStationCoverageAreaText(), FindSubsidyTownCargoRoute(), SlStationGoods::GetNumCargo(), SlTownOldSupplied::GetNumCargo(), Order::IsRefit(), LinkRefresher::LinkRefresher(), CAPRChunkHandler::Load(), CompanyStationsWindow::OnDropdownSelect(), StationViewWindow::OnInvalidateData(), DepotWindow::OnRightClick(), ProcessNewGRFStringControlCode(), LinkRefresher::RefreshLinks(), LinkRefresher::RefreshStats(), TransferCargo(), TriggerWatchedCargoCallbacks(), UpdateStationAcceptance(), and Station::~Station().

## ◆ NUM_ORIGINAL_CARGO

const CargoType NUM_ORIGINAL_CARGO = 12
| static

Original number of cargo types.

Definition at line 72 of file cargo_type.h.