|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
19 #include "table/strings.h"
118 if (cs->label == cl)
return cs->Index();
122 return INVALID_CARGO;
136 if (cs->bitnum == bitnum)
return cs->Index();
140 return INVALID_CARGO;
150 if (sprite == 0xFFFF) {
213 uint8_t nb_standard_cargo = 0;
215 assert(cargo->town_production_effect !=
INVALID_TPE);
226 uint64_t CargoSpec::WeightOfNUnitsInTrain(uint32_t n)
const
229 return this->WeightOfNUnits(n);
CargoType
Available types of cargo.
CargoTypes _standard_cargo_mask
Bitmask of real cargo types available.
bool IsValidCargoType(CargoType t)
Test whether cargo type is not CT_INVALID.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
CargoLabel label
Unique label of the cargo type.
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.
static const CargoLabel _default_climate_cargo[NUM_LANDSCAPE][NUM_ORIGINAL_CARGO]
Table of cargo types available in each climate, by default.
CargoID GetCargoIDByBitnum(uint8_t bitnum)
Find the CargoID of a 'bitnum' value.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
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.
@ CC_PASSENGERS
Passengers.
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.
std::span< const CargoSpec * > _sorted_standard_cargo_specs
Standard cargo specifications sorted alphabetically by name.
uint8_t freight_trains
value to multiply the weight of cargo by
@ CC_SPECIAL
Special bit used for livery refit tricks instead of normal cargoes.
static const byte INVALID_CARGO_BITNUM
Constant representing invalid cargo.
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.
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).
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.
uint32_t CargoLabel
Globally unique label of a cargo 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.
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
Get the custom sprite for the given cargo type.
@ INVALID_TPE
Invalid town production effect.
CargoID GetDefaultCargoID(LandscapeID l, CargoType ct)
Get the cargo ID of a default cargo, if present.
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.
StringID name
Name of this type of cargo.
#define lengthof(x)
Return the length of an fixed size array.
byte CargoID
Cargo slots to indicate a cargo type within a game.
VehicleSettings vehicle
options for vehicles
byte LandscapeID
Landscape type.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
CargoID GetCargoIDByLabel(CargoLabel cl)
Get the cargo ID by cargo label.
Dimension GetLargestCargoIconSize()
Get dimensions of largest cargo icon.
static const CargoSpec _default_cargo[]
Cargo types available by default.
uint16_t classes
Classes of this cargo type.