OpenTTD Source 20261123-master-g1c55c72fd0
cargo_type.h File Reference

Types related to cargoes... More...

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 = Label<struct CargoLabelTag>
 Globally unique label of a cargo type.
using CargoTypes = EnumBitSet<CargoType, uint64_t>
 Bitset of CargoType elements.

Enumerations

enum  CargoType : uint8_t
 Cargo slots to indicate a cargo type within a game. More...
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_NONE = CT_PASSENGERS
 Dummy label for engines that carry no cargo; they actually carry 0 passengers.
static constexpr CargoLabel CT_INVALID {"\xFF\xFF\xFF\xFF"}
 Invalid cargo type.
static constexpr CargoType NUM_ORIGINAL_CARGO {12}
 Original number of cargo types.
static constexpr CargoType NUM_CARGO {64}
 Maximum number of cargo types in a game.
static constexpr CargoType CARGO_AUTO_REFIT {0xFD}
 Automatically choose cargo type when doing auto refitting.
static constexpr CargoType CARGO_NO_REFIT {0xFE}
 Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
static constexpr CargoType INVALID_CARGO {UINT8_MAX}
 Invalid marker for cargoes.
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 constexpr CargoTypes ALL_CARGOTYPES {UINT64_MAX}
Available types of cargo.

Labels may be re-used between different climates.

static constexpr CargoLabel CT_PASSENGERS {"PASS"}
 Cargo label for passengers.
static constexpr CargoLabel CT_COAL {"COAL"}
 Cargo label for coal.
static constexpr CargoLabel CT_MAIL {"MAIL"}
 Cargo label for mail.
static constexpr CargoLabel CT_OIL {"OIL_"}
 Cargo label for oil.
static constexpr CargoLabel CT_LIVESTOCK {"LVST"}
 Cargo label for livestock.
static constexpr CargoLabel CT_GOODS {"GOOD"}
 Cargo label for goods.
static constexpr CargoLabel CT_GRAIN {"GRAI"}
 Cargo label for grain.
static constexpr CargoLabel CT_WOOD {"WOOD"}
 Cargo label for wood.
static constexpr CargoLabel CT_IRON_ORE {"IORE"}
 Cargo label for iron ore.
static constexpr CargoLabel CT_STEEL {"STEL"}
 Cargo label for steel.
static constexpr CargoLabel CT_VALUABLES {"VALU"}
 Cargo label for valuables.
static constexpr CargoLabel CT_WHEAT {"WHEA"}
 Cargo label for wheat.
static constexpr CargoLabel CT_PAPER {"PAPR"}
 Cargo label for paper.
static constexpr CargoLabel CT_GOLD {"GOLD"}
 Cargo label for gold.
static constexpr CargoLabel CT_FOOD {"FOOD"}
 Cargo label for food.
static constexpr CargoLabel CT_RUBBER {"RUBR"}
 Cargo label for rubber.
static constexpr CargoLabel CT_FRUIT {"FRUT"}
 Cargo label for fruits.
static constexpr CargoLabel CT_MAIZE {"MAIZ"}
 Cargo label for maize.
static constexpr CargoLabel CT_COPPER_ORE {"CORE"}
 Cargo label for copper ore.
static constexpr CargoLabel CT_WATER {"WATR"}
 Cargo label for water.
static constexpr CargoLabel CT_DIAMONDS {"DIAM"}
 Cargo label for diamonds.
static constexpr CargoLabel CT_SUGAR {"SUGR"}
 Cargo label for sugar.
static constexpr CargoLabel CT_TOYS {"TOYS"}
 Cargo label for toys.
static constexpr CargoLabel CT_BATTERIES {"BATT"}
 Cargo label for batteries.
static constexpr CargoLabel CT_CANDY {"SWET"}
 Cargo label for candies/sweets.
static constexpr CargoLabel CT_TOFFEE {"TOFF"}
 Cargo label for toffee.
static constexpr CargoLabel CT_COLA {"COLA"}
 Cargo label for cola.
static constexpr CargoLabel CT_COTTON_CANDY {"CTCD"}
 Cargo label for cotton candies.
static constexpr CargoLabel CT_BUBBLES {"BUBL"}
 Cargo label for bubbles.
static constexpr CargoLabel CT_PLASTIC {"PLST"}
 Cargo label for plastic.
static constexpr CargoLabel CT_FIZZY_DRINKS {"FZDR"}
 Cargo label for fizzy drinks.

Detailed Description

Types related to cargoes...

Definition in file cargo_type.h.

Typedef Documentation

◆ CargoLabel

using CargoLabel = Label<struct CargoLabelTag>

Globally unique label of a cargo type.

Definition at line 17 of file cargo_type.h.

◆ CargoTypes

using CargoTypes = EnumBitSet<CargoType, uint64_t>

Bitset of CargoType elements.

Definition at line 115 of file cargo_type.h.

Enumeration Type Documentation

◆ CargoType

enum CargoType : uint8_t

Cargo slots to indicate a cargo type within a game.

Definition at line 22 of file cargo_type.h.

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

Function Documentation

◆ IsValidCargoType()

bool IsValidCargoType ( CargoType cargo)
inline

Test whether cargo type is not INVALID_CARGO.

Parameters
cargoThe cargo to check.
Returns
false iff the cargo is INVALID_CARGO.

Definition at line 112 of file cargo_type.h.

References INVALID_CARGO.

Referenced by AddAcceptedCargo_Industry(), AddAcceptedCargo_Object(), AddAcceptedCargoSetMask(), AddArticulatedParts(), AddProducedCargo_Object(), AddProducedCargo_Town(), AfterLoadGame(), AircraftVehicleChangeInfo(), BuildReplacementVehicle(), CalculateRefitMasks(), CanCargoServiceIndustry(), Engine::CanCarryCargo(), ChangeIndustryProduction(), ChopLumberMillTrees(), AcceptsProducesChainField::ClickedAt(), CargoChainField::ClickedAt(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdBuildVehicle(), CmdCloneVehicle(), CMSAMine(), IndustryCargoesWindow::ComputeCargoDisplay(), ConnectionChainField::ConnectCargo(), IndustryCargoesWindow::CountIndustryCargoTypes(), Engine::DetermineCapacity(), DoCreateNewIndustry(), AcceptsProducesChainField::Draw(), CargoChainField::Draw(), DrawCargoIconOverlay(), IndustryViewWindow::DrawInfo(), FinaliseHouseArray(), FinaliseIndustriesArray(), FindSubsidyIndustryCargoRoute(), FormatString(), GetAllCargoSuffixes(), GetCapacityOfArticulatedParts(), Industry::GetCargoAccepted(), Industry::GetCargoAccepted(), Town::GetCargoAccepted(), Industry::GetCargoProduced(), Industry::GetCargoProduced(), GetCargoSuffix(), GetCargoSummaryOfArticulatedVehicle(), IndustryDirectoryWindow::GetCargoTransportedPercentsIfValid(), IndustryProductionGraphWindow::GetCargoTypes(), TownCargoGraphWindow::GetCargoTypes(), GetCargoTypesOfArticulatedParts(), GetCargoTypesOfArticulatedVehicle(), GetEngineLiveryScheme(), IndustryDirectoryWindow::GetIndustryString(), GetNewCargoTypeForReplace(), Town::GetOrCreateCargoAccepted(), GetProducedCargoOfHouse(), GetProductionAroundTiles(), HouseScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), VehicleScopeResolver::GetVariable(), GetVehicleDefaultCapacity(), IndustryProductionCallback(), IndustryDirectoryWindow::IndustryProductionSorter(), Industry::IsCargoAccepted(), Industry::IsCargoProduced(), IsEngineRefittable(), INDYChunkHandler::Load(), BuildIndustryWindow::MakeCargoListString(), CargoTypeMapSpriteGroupHandler< T, Tclass >::MapSpecific(), Vehicle::NeedsServicing(), IndustryViewWindow::OnClick(), IndustryCargoesWindow::OnTooltip(), ProduceIndustryGoodsHelper(), RailVehicleChangeInfo(), ReadIndustryProductionSpriteGroup(), RefitVehicle(), RoadVehicleChangeInfo(), SlIndustryAcceptedHistory::Save(), SlIndustryProducedHistory::Save(), ShipVehicleChangeInfo(), TileLoop_Object(), TileLoop_Town(), TownAcceptanceHistoryHelperCargoID(), TownHouseChangeInfo(), TownProductionHistoryHelperCargoID(), TrainDetailsCargoTab(), TranslateRefitMask(), TransportIndustryGoods(), TriggerIndustryProduction(), TriggerRoadStopRandomisation(), TriggerStationRandomisation(), UpdateIndustryStatistics(), IndustryProductionGraphWindow::UpdateStatistics(), and TownCargoGraphWindow::UpdateStatistics().

Variable Documentation

◆ ALL_CARGOTYPES

CargoTypes ALL_CARGOTYPES {UINT64_MAX}
staticconstexpr

Definition at line 117 of file cargo_type.h.

◆ CARGO_AUTO_REFIT

CargoType CARGO_AUTO_REFIT {0xFD}
staticconstexpr

Automatically choose cargo type when doing auto refitting.

Definition at line 80 of file cargo_type.h.

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

◆ CARGO_NO_REFIT

CargoType CARGO_NO_REFIT {0xFE}
staticconstexpr

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

Definition at line 81 of file cargo_type.h.

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

◆ CT_BATTERIES

CargoLabel CT_BATTERIES {"BATT"}
staticconstexpr

Cargo label for batteries.

Definition at line 61 of file cargo_type.h.

◆ CT_BUBBLES

CargoLabel CT_BUBBLES {"BUBL"}
staticconstexpr

Cargo label for bubbles.

Definition at line 66 of file cargo_type.h.

◆ CT_CANDY

CargoLabel CT_CANDY {"SWET"}
staticconstexpr

Cargo label for candies/sweets.

Definition at line 62 of file cargo_type.h.

Referenced by CalculateRefitMasks(), and TownHouseChangeInfo().

◆ CT_COAL

CargoLabel CT_COAL {"COAL"}
staticconstexpr

Cargo label for coal.

Definition at line 33 of file cargo_type.h.

Referenced by CalculateRefitMasks().

◆ CT_COLA

CargoLabel CT_COLA {"COLA"}
staticconstexpr

Cargo label for cola.

Definition at line 64 of file cargo_type.h.

Referenced by CalculateRefitMasks().

◆ CT_COPPER_ORE

CargoLabel CT_COPPER_ORE {"CORE"}
staticconstexpr

Cargo label for copper ore.

Definition at line 54 of file cargo_type.h.

Referenced by CalculateRefitMasks().

◆ CT_COTTON_CANDY

CargoLabel CT_COTTON_CANDY {"CTCD"}
staticconstexpr

Cargo label for cotton candies.

Definition at line 65 of file cargo_type.h.

◆ CT_DIAMONDS

CargoLabel CT_DIAMONDS {"DIAM"}
staticconstexpr

Cargo label for diamonds.

Definition at line 56 of file cargo_type.h.

Referenced by GetActiveCargoLabel().

◆ CT_FIZZY_DRINKS

CargoLabel CT_FIZZY_DRINKS {"FZDR"}
staticconstexpr

Cargo label for fizzy drinks.

Definition at line 68 of file cargo_type.h.

Referenced by TownHouseChangeInfo().

◆ CT_FOOD

CargoLabel CT_FOOD {"FOOD"}
staticconstexpr

Cargo label for food.

Definition at line 48 of file cargo_type.h.

Referenced by AddAcceptedCargoOfHouse(), CalculateRefitMasks(), and TownHouseChangeInfo().

◆ CT_FRUIT

CargoLabel CT_FRUIT {"FRUT"}
staticconstexpr

Cargo label for fruits.

Definition at line 52 of file cargo_type.h.

Referenced by GetActiveCargoLabel().

◆ CT_GOLD

CargoLabel CT_GOLD {"GOLD"}
staticconstexpr

Cargo label for gold.

Definition at line 47 of file cargo_type.h.

Referenced by GetActiveCargoLabel().

◆ CT_GOODS

CargoLabel CT_GOODS {"GOOD"}
staticconstexpr

Cargo label for goods.

Definition at line 37 of file cargo_type.h.

Referenced by CalculateRefitMasks(), GetEngineLiveryScheme(), and TownHouseChangeInfo().

◆ CT_GRAIN

CargoLabel CT_GRAIN {"GRAI"}
staticconstexpr

Cargo label for grain.

Definition at line 38 of file cargo_type.h.

Referenced by GetActiveCargoLabel().

◆ CT_INVALID

◆ CT_IRON_ORE

CargoLabel CT_IRON_ORE {"IORE"}
staticconstexpr

Cargo label for iron ore.

Definition at line 40 of file cargo_type.h.

◆ CT_LIVESTOCK

CargoLabel CT_LIVESTOCK {"LVST"}
staticconstexpr

Cargo label for livestock.

Definition at line 36 of file cargo_type.h.

Referenced by GetActiveCargoLabel().

◆ CT_MAIL

◆ CT_MAIZE

CargoLabel CT_MAIZE {"MAIZ"}
staticconstexpr

Cargo label for maize.

Definition at line 53 of file cargo_type.h.

Referenced by GetActiveCargoLabel().

◆ CT_NONE

CargoLabel CT_NONE = CT_PASSENGERS
staticconstexpr

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

Definition at line 72 of file cargo_type.h.

◆ CT_OIL

CargoLabel CT_OIL {"OIL_"}
staticconstexpr

Cargo label for oil.

Definition at line 35 of file cargo_type.h.

Referenced by CalculateRefitMasks().

◆ CT_PAPER

CargoLabel CT_PAPER {"PAPR"}
staticconstexpr

Cargo label for paper.

Definition at line 46 of file cargo_type.h.

◆ CT_PASSENGERS

◆ CT_PLASTIC

CargoLabel CT_PLASTIC {"PLST"}
staticconstexpr

Cargo label for plastic.

Definition at line 67 of file cargo_type.h.

◆ CT_RUBBER

CargoLabel CT_RUBBER {"RUBR"}
staticconstexpr

Cargo label for rubber.

Definition at line 51 of file cargo_type.h.

◆ CT_STEEL

CargoLabel CT_STEEL {"STEL"}
staticconstexpr

Cargo label for steel.

Definition at line 41 of file cargo_type.h.

◆ CT_SUGAR

CargoLabel CT_SUGAR {"SUGR"}
staticconstexpr

Cargo label for sugar.

Definition at line 59 of file cargo_type.h.

Referenced by CalculateRefitMasks().

◆ CT_TOFFEE

CargoLabel CT_TOFFEE {"TOFF"}
staticconstexpr

Cargo label for toffee.

Definition at line 63 of file cargo_type.h.

◆ CT_TOYS

CargoLabel CT_TOYS {"TOYS"}
staticconstexpr

Cargo label for toys.

Definition at line 60 of file cargo_type.h.

◆ CT_VALUABLES

CargoLabel CT_VALUABLES {"VALU"}
staticconstexpr

Cargo label for valuables.

Definition at line 42 of file cargo_type.h.

Referenced by CalculateRefitMasks(), and GetActiveCargoLabel().

◆ CT_WATER

CargoLabel CT_WATER {"WATR"}
staticconstexpr

Cargo label for water.

Definition at line 55 of file cargo_type.h.

◆ CT_WHEAT

CargoLabel CT_WHEAT {"WHEA"}
staticconstexpr

Cargo label for wheat.

Definition at line 45 of file cargo_type.h.

Referenced by GetActiveCargoLabel().

◆ CT_WOOD

CargoLabel CT_WOOD {"WOOD"}
staticconstexpr

Cargo label for wood.

Definition at line 39 of file cargo_type.h.

◆ INVALID_CARGO

◆ NUM_CARGO

◆ NUM_ORIGINAL_CARGO

CargoType NUM_ORIGINAL_CARGO {12}
staticconstexpr

Original number of cargo types.

Definition at line 76 of file cargo_type.h.