OpenTTD Source: src/cargo_type.h File Reference

OpenTTD Source 15.0-beta1

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

Types related to cargoes... More...

`#include "core/enum_type.hpp"`
`#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 | CargoID = uint8_t
| Cargo slots to indicate a cargo type within a game.
typedef uint64_t | CargoTypes
typedef uint16_t | SourceID
| Contains either industry ID, town ID or company ID (or INVALID_SOURCE)

## Enumerations
enum | MixedCargoType { 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...
enum class | SourceType : uint8_t { Industry , Town , Headquarters }
| Types of cargo source and destination. More...

## Functions
bool | IsValidCargoType (CargoLabel t)
| Test whether cargo type is not CT_INVALID.
bool | IsValidCargoID (CargoID t)
| Test whether cargo type is not INVALID_CARGO.

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

## Detailed Description

Types related to cargoes...

Definition in file cargo_type.h.

## Typedef Documentation

## ◆ CargoID

using CargoID = uint8_t

Cargo slots to indicate a cargo type within a game.

Definition at line 22 of file cargo_type.h.

## ◆ CargoLabel

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

Globally unique label of a cargo type.

Definition at line 17 of file cargo_type.h.

## ◆ CargoTypes

typedef uint64_t CargoTypes

Definition at line 109 of file cargo_type.h.

## ◆ SourceID

typedef uint16_t SourceID

Contains either industry ID, town ID or company ID (or INVALID_SOURCE)

Definition at line 143 of file cargo_type.h.

## Enumeration Type Documentation

## ◆ MixedCargoType

enum MixedCargoType

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 83 of file cargo_type.h.

## ◆ SourceType

enum class SourceType : uint8_t
| strong

Types of cargo source and destination.

Enumerator
Industry | Source/destination is an industry.
Town | Source/destination is a town.
Headquarters | Source/destination are company headquarters.

Definition at line 137 of file cargo_type.h.

## Function Documentation

## ◆ IsValidCargoID()

bool IsValidCargoID | ( | CargoID | t | ) |
| inline

Test whether cargo type is not INVALID_CARGO.

Definition at line 107 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(), NewGRFInspectWindow::DrawMainPanelWidget(), IndustryProductionGraphWindow::DrawWidget(), FinaliseHouseArray(), FinaliseIndustriesArray(), FindSubsidyIndustryCargoRoute(), FormatString(), GetAllCargoSuffixes(), GetCapacityOfArticulatedParts(), Industry::GetCargoAccepted(), Industry::GetCargoAccepted(), Industry::GetCargoProduced(), Industry::GetCargoProduced(), GetCargoSuffix(), GetCargoSummaryOfArticulatedVehicle(), IndustryDirectoryWindow::GetCargoTransportedPercentsIfValid(), GetCargoTypesOfArticulatedParts(), GetCargoTypesOfArticulatedVehicle(), GetEngineLiveryScheme(), IndustryDirectoryWindow::GetIndustryString(), GetNewCargoTypeForReplace(), GetProductionAroundTiles(), VehicleScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), TownScopeResolver::GetVariable(), GetVehicleDefaultCapacity(), IndustryCargoesWindow::HasCommonValidCargo(), IndustryCargoesWindow::HousesCanAccept(), IndustryCargoesWindow::HousesCanSupply(), IndustryProductionCallback(), IndustryDirectoryWindow::IndustryProductionSorter(), Industry::IsCargoAccepted(), Industry::IsCargoProduced(), IsEngineRefittable(), CargoesField::MakeCargo(), BuildIndustryWindow::MakeCargoListString(), Vehicle::NeedsServicing(), IndustryProductionGraphWindow::OnClick(), IndustryViewWindow::OnClick(), IndustryCargoesWindow::OnClick(), IndustryCargoesWindow::OnInit(), IndustryCargoesWindow::OnTooltip(), ProduceIndustryGoodsHelper(), RailVehicleChangeInfo(), RefitVehicle(), RoadVehicleChangeInfo(), ShipVehicleChangeInfo(), TileLoop_Town(), TownHouseChangeInfo(), TrainDetailsCapacityTab(), TrainDetailsCargoTab(), TranslateRefitMask(), TransportIndustryGoods(), TriggerIndustryProduction(), TriggerRoadStopRandomisation(), TriggerStationRandomisation(), UpdateIndustryStatistics(), IndustryProductionGraphWindow::UpdateStatistics(), and IndustryProductionGraphWindow::UpdateWidgetSize().

## ◆ IsValidCargoType()

bool IsValidCargoType | ( | CargoLabel | t | ) |
| inline

Test whether cargo type is not CT_INVALID.

Definition at line 105 of file cargo_type.h.

References CT_INVALID.

## Variable Documentation

## ◆ ALL_CARGOTYPES

const CargoTypes ALL_CARGOTYPES = (CargoTypes)UINT64_MAX
| static

Definition at line 111 of file cargo_type.h.

## ◆ CARGO_AUTO_REFIT

const CargoID CARGO_AUTO_REFIT = 0xFD
| static

Automatically choose cargo type when doing auto refitting.

Definition at line 77 of file cargo_type.h.

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

## ◆ CARGO_NO_REFIT

const CargoID CARGO_NO_REFIT = 0xFE
| static

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

Definition at line 78 of file cargo_type.h.

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

## ◆ CT_BATTERIES

constexpr CargoLabel CT_BATTERIES = CargoLabel{'BATT'}
| staticconstexpr

Definition at line 59 of file cargo_type.h.

## ◆ CT_BUBBLES

constexpr CargoLabel CT_BUBBLES = CargoLabel{'BUBL'}
| staticconstexpr

Definition at line 64 of file cargo_type.h.

## ◆ CT_CANDY

constexpr CargoLabel CT_CANDY = CargoLabel{'SWET'}
| staticconstexpr

Definition at line 60 of file cargo_type.h.

## ◆ CT_COAL

constexpr CargoLabel CT_COAL = CargoLabel{'COAL'}
| staticconstexpr

Definition at line 31 of file cargo_type.h.

## ◆ CT_COLA

constexpr CargoLabel CT_COLA = CargoLabel{'COLA'}
| staticconstexpr

Definition at line 62 of file cargo_type.h.

## ◆ CT_COPPER_ORE

constexpr CargoLabel CT_COPPER_ORE = CargoLabel{'CORE'}
| staticconstexpr

Definition at line 52 of file cargo_type.h.

## ◆ CT_COTTON_CANDY

constexpr CargoLabel CT_COTTON_CANDY = CargoLabel{'CTCD'}
| staticconstexpr

Definition at line 63 of file cargo_type.h.

## ◆ CT_DIAMONDS

constexpr CargoLabel CT_DIAMONDS = CargoLabel{'DIAM'}
| staticconstexpr

Definition at line 54 of file cargo_type.h.

## ◆ CT_FIZZY_DRINKS

constexpr CargoLabel CT_FIZZY_DRINKS = CargoLabel{'FZDR'}
| staticconstexpr

Definition at line 66 of file cargo_type.h.

## ◆ CT_FOOD

constexpr CargoLabel CT_FOOD = CargoLabel{'FOOD'}
| staticconstexpr

Definition at line 46 of file cargo_type.h.

## ◆ CT_FRUIT

constexpr CargoLabel CT_FRUIT = CargoLabel{'FRUT'}
| staticconstexpr

Definition at line 50 of file cargo_type.h.

## ◆ CT_GOLD

constexpr CargoLabel CT_GOLD = CargoLabel{'GOLD'}
| staticconstexpr

Definition at line 45 of file cargo_type.h.

## ◆ CT_GOODS

constexpr CargoLabel CT_GOODS = CargoLabel{'GOOD'}
| staticconstexpr

Definition at line 35 of file cargo_type.h.

## ◆ CT_GRAIN

constexpr CargoLabel CT_GRAIN = CargoLabel{'GRAI'}
| staticconstexpr

Definition at line 36 of file cargo_type.h.

## ◆ CT_INVALID

constexpr CargoLabel CT_INVALID = CargoLabel{UINT32_MAX}
| staticconstexpr

Invalid cargo type.

Definition at line 71 of file cargo_type.h.

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

## ◆ CT_IRON_ORE

constexpr CargoLabel CT_IRON_ORE = CargoLabel{'IORE'}
| staticconstexpr

Definition at line 38 of file cargo_type.h.

## ◆ CT_LIVESTOCK

constexpr CargoLabel CT_LIVESTOCK = CargoLabel{'LVST'}
| staticconstexpr

Definition at line 34 of file cargo_type.h.

## ◆ CT_MAIL

constexpr CargoLabel CT_MAIL = CargoLabel{'MAIL'}
| staticconstexpr

Definition at line 32 of file cargo_type.h.

## ◆ CT_MAIZE

constexpr CargoLabel CT_MAIZE = CargoLabel{'MAIZ'}
| staticconstexpr

Definition at line 51 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 69 of file cargo_type.h.

## ◆ CT_OIL

constexpr CargoLabel CT_OIL = CargoLabel{'OIL_'}
| staticconstexpr

Definition at line 33 of file cargo_type.h.

## ◆ CT_PAPER

constexpr CargoLabel CT_PAPER = CargoLabel{'PAPR'}
| staticconstexpr

Definition at line 44 of file cargo_type.h.

## ◆ CT_PASSENGERS

constexpr CargoLabel CT_PASSENGERS = CargoLabel{'PASS'}
| staticconstexpr

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

Definition at line 30 of file cargo_type.h.

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

## ◆ CT_PLASTIC

constexpr CargoLabel CT_PLASTIC = CargoLabel{'PLST'}
| staticconstexpr

Definition at line 65 of file cargo_type.h.

## ◆ CT_RUBBER

constexpr CargoLabel CT_RUBBER = CargoLabel{'RUBR'}
| staticconstexpr

Definition at line 49 of file cargo_type.h.

## ◆ CT_STEEL

constexpr CargoLabel CT_STEEL = CargoLabel{'STEL'}
| staticconstexpr

Definition at line 39 of file cargo_type.h.

## ◆ CT_SUGAR

constexpr CargoLabel CT_SUGAR = CargoLabel{'SUGR'}
| staticconstexpr

Definition at line 57 of file cargo_type.h.

## ◆ CT_TOFFEE

constexpr CargoLabel CT_TOFFEE = CargoLabel{'TOFF'}
| staticconstexpr

Definition at line 61 of file cargo_type.h.

## ◆ CT_TOYS

constexpr CargoLabel CT_TOYS = CargoLabel{'TOYS'}
| staticconstexpr

Definition at line 58 of file cargo_type.h.

## ◆ CT_VALUABLES

constexpr CargoLabel CT_VALUABLES = CargoLabel{'VALU'}
| staticconstexpr

Definition at line 40 of file cargo_type.h.

## ◆ CT_WATER

constexpr CargoLabel CT_WATER = CargoLabel{'WATR'}
| staticconstexpr

Definition at line 53 of file cargo_type.h.

## ◆ CT_WHEAT

constexpr CargoLabel CT_WHEAT = CargoLabel{'WHEA'}
| staticconstexpr

Definition at line 43 of file cargo_type.h.

## ◆ CT_WOOD

constexpr CargoLabel CT_WOOD = CargoLabel{'WOOD'}
| staticconstexpr

Definition at line 37 of file cargo_type.h.

## ◆ INVALID_CARGO

const CargoID INVALID_CARGO = UINT8_MAX
| static

Definition at line 80 of file cargo_type.h.

## ◆ INVALID_SOURCE

const SourceID INVALID_SOURCE = 0xFFFF
| static

Invalid/unknown index of source.

Definition at line 144 of file cargo_type.h.

Referenced by AddCargoDelivery(), CargoPacket::CargoPacket(), CheckSubsidised(), and CargoPacket::InvalidateAllFrom().

## ◆ NUM_CARGO

const CargoID NUM_CARGO = 64
| static

Maximum number of cargo types in a game.

Definition at line 74 of file cargo_type.h.

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

## ◆ NUM_ORIGINAL_CARGO

const CargoID NUM_ORIGINAL_CARGO = 12
| static

Original number of cargo types.

Definition at line 73 of file cargo_type.h.