OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
19 #include "table/strings.h"
60 if (std::holds_alternative<int>(cl)) {
75 if (insert->IsValid()) {
114 if (!cs->IsValid())
return false;
143 if (cs->bitnum == bitnum)
return cs->Index();
147 return INVALID_CARGO;
157 if (sprite == 0xFFFF) {
220 uint8_t nb_standard_cargo = 0;
222 assert(cargo->town_production_effect !=
INVALID_TPE);
233 uint64_t CargoSpec::WeightOfNUnitsInTrain(uint32_t n)
const
236 return this->WeightOfNUnits(n);
CargoTypes _standard_cargo_mask
Bitmask of real cargo types available.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
CargoLabel label
Unique label of the cargo type.
@ CC_PASSENGERS
Passengers.
Dimensions (a width and height) of a rectangle in 2D.
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.
void BuildCargoLabelMap()
Build cargo label map.
CargoID GetCargoIDByBitnum(uint8_t bitnum)
Find the CargoID of a 'bitnum' value.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
static std::map< CargoLabel, CargoID > label_map
Translation map from CargoLabel to Cargo ID.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
bool IsDefaultCargo(CargoID cid)
Test if a cargo is a default cargo type.
void SetupCargoForClimate(LandscapeID l)
Set up the default cargo types for the given landscape type.
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
Specification of a cargo type.
SpriteID GetCargoIcon() const
Get sprite for showing cargo of this type.
static bool CargoSpecNameSorter(const CargoSpec *const &a, const CargoSpec *const &b)
Sort cargo specifications by their name.
static CargoSpec array[NUM_CARGO]
Array holding all CargoSpecs.
@ CC_SPECIAL
Special bit used for livery refit tricks instead of normal cargoes.
std::span< const CargoSpec * > _sorted_standard_cargo_specs
Standard cargo specifications sorted alphabetically by name.
CargoClasses classes
Classes of this cargo type.
static const std::variant< CargoLabel, int > _default_climate_cargo[NUM_LANDSCAPE][NUM_ORIGINAL_CARGO]
Table of cargo types available in each climate, by default.
uint8_t freight_trains
value to multiply the weight of cargo by
static std::array< std::vector< const CargoSpec * >, NUM_TPE > town_production_cargoes
List of cargo specs for each Town Product Effect.
CargoTypes _cargo_mask
Bitmask of cargo types available.
static std::vector< CargoLabel > _default_cargo_labels
List of default cargo labels, used when setting up cargo types for default vehicles.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
SpriteID sprite
Icon to display this cargo type, may be 0xFFF (which means to resolve an action123 chain).
#define lengthof(array)
Return the length of an fixed size array.
@ INVALID_TPE
Invalid town production effect.
bool is_freight
Cargo type is considered to be freight (affects train freight multiplier).
uint8_t bitnum
Cargo bit number, is INVALID_CARGO_BITNUM for a non-used spec.
uint8_t LandscapeID
Landscape type.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
static bool CargoSpecClassSorter(const CargoSpec *const &a, const CargoSpec *const &b)
Sort cargo specifications by their cargo class.
static const uint8_t INVALID_CARGO_BITNUM
Constant representing invalid cargo.
static constexpr CargoLabel CT_INVALID
Invalid cargo type.
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
Get the custom sprite for the given cargo type.
void InitializeSortedCargoSpecs()
Initialize the list of sorted cargo specifications.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
StringID name
Name of this type of cargo.
VehicleSettings vehicle
options for vehicles
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
Dimension GetLargestCargoIconSize()
Get dimensions of largest cargo icon.
static const CargoSpec _default_cargo[]
Cargo types available by default.