OpenTTD Source
20241108-master-g80f628063a
|
Types/functions related to cargoes. More...
#include "economy_type.h"
#include "cargo_type.h"
#include "gfx_type.h"
#include "strings_type.h"
#include "landscape_type.h"
#include "core/bitmath_func.hpp"
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 |
struct | CargoIDComparator |
Comparator to sort CargoID by according to desired order. More... | |
Typedefs | |
using | CargoClasses = uint16_t |
Bitmask of cargo classes. | |
using | SetCargoBitIterator = SetBitIterator< CargoID, CargoTypes > |
Enumerations | |
enum | TownAcceptanceEffect : uint8_t { TAE_BEGIN = 0 , TAE_NONE = TAE_BEGIN , TAE_PASSENGERS , TAE_MAIL , TAE_GOODS , TAE_WATER , TAE_FOOD , TAE_END , NUM_TAE = TAE_END } |
Town growth effect when delivering cargo. More... | |
enum | TownProductionEffect : uint8_t { TPE_NONE , TPE_PASSENGERS , TPE_MAIL , NUM_TPE , INVALID_TPE } |
Town effect when producing cargo. More... | |
enum | CargoClass : uint16_t { CC_NOAVAILABLE = 0 , CC_PASSENGERS = 1 << 0 , CC_MAIL = 1 << 1 , CC_EXPRESS = 1 << 2 , CC_ARMOURED = 1 << 3 , CC_BULK = 1 << 4 , CC_PIECE_GOODS = 1 << 5 , CC_LIQUID = 1 << 6 , CC_REFRIGERATED = 1 << 7 , CC_HAZARDOUS = 1 << 8 , CC_COVERED = 1 << 9 , CC_SPECIAL = 1 << 15 } |
Cargo classes. More... | |
Functions | |
void | SetupCargoForClimate (LandscapeID l) |
Set up the default cargo types for the given landscape type. More... | |
bool | IsDefaultCargo (CargoID cid) |
Test if a cargo is a default cargo type. More... | |
void | BuildCargoLabelMap () |
Build cargo label map. More... | |
CargoID | GetCargoIDByLabel (CargoLabel label) |
Dimension | GetLargestCargoIconSize () |
Get dimensions of largest cargo icon. More... | |
void | InitializeSortedCargoSpecs () |
Initialize the list of sorted cargo specifications. | |
bool | IsCargoInClass (CargoID c, CargoClass cc) |
Does cargo c have cargo class cc? More... | |
Variables | |
static const uint8_t | INVALID_CARGO_BITNUM = 0xFF |
Constant representing invalid cargo. | |
static const uint | TOWN_PRODUCTION_DIVISOR = 256 |
CargoTypes | _cargo_mask |
Bitmask of cargo types available. More... | |
CargoTypes | _standard_cargo_mask |
Bitmask of real cargo types available. More... | |
std::array< uint8_t, NUM_CARGO > | _sorted_cargo_types |
Sort order of cargoes by cargo ID. | |
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.
enum CargoClass : uint16_t |
Cargo classes.
Definition at line 48 of file cargotype.h.
enum TownAcceptanceEffect : uint8_t |
Town growth effect when delivering cargo.
Definition at line 21 of file cargotype.h.
enum TownProductionEffect : uint8_t |
Town effect when producing cargo.
Enumerator | |
---|---|
TPE_NONE | Town will not produce this cargo type. |
TPE_PASSENGERS | Cargo behaves passenger-like for production. |
TPE_MAIL | Cargo behaves mail-like for production. |
INVALID_TPE | 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 34 of file cargotype.h.
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 200 of file cargotype.cpp.
References CargoSpecNameSorter(), CC_SPECIAL, and CargoSpec::classes.
Dimension GetLargestCargoIconSize | ( | ) |
Get dimensions of largest cargo icon.
Definition at line 153 of file cargotype.cpp.
References _sorted_cargo_specs, GetSpriteSize(), and maxdim().
Referenced by IndustryViewWindow::OnInit(), and SubsidyListWindow::OnInit().
|
inline |
Does cargo c have cargo class cc?
c | Cargo type. |
cc | Cargo class. |
Definition at line 232 of file cargotype.h.
References CargoSpec::Get().
Referenced by CargoFilterSingle(), Vehicle::Crash(), RoadVehicle::IsBus(), and UpdateStationAcceptance().
bool IsDefaultCargo | ( | CargoID | cid | ) |
Test if a cargo is a default cargo type.
cid | Cargo ID. |
Definition at line 140 of file cargotype.cpp.
References _default_cargo_labels, and CargoSpec::Get().
Referenced by CalculateRefitMasks().
void SetupCargoForClimate | ( | LandscapeID | l | ) |
Set up the default cargo types for the given landscape type.
l | Landscape |
Definition at line 199 of file cargotype.cpp.
|
extern |
Bitmask of cargo types available.
This includes phony cargoes like regearing cargoes. Initialized during a call to SetupCargoForClimate.
Definition at line 31 of file cargotype.cpp.
|
extern |
Bitmask of real cargo types available.
Phony cargoes like regearing cargoes are excluded.
Definition at line 36 of file cargotype.cpp.
Referenced by CargoAndEngineFilter(), InitializeSortedCargoSpecs(), and BuildVehicleWindow::SetCargoFilterArray().