19 #include "table/strings.h"
76 const CargoSpec &operator()(
const int &index)
92 *insert = std::visit(visitor{}, cl);
94 if (insert->IsValid()) {
146 if (!cs->IsValid())
return false;
172 if (sprite == 0xFFFF) {
235 uint8_t nb_standard_cargo = 0;
237 assert(cargo->town_production_effect !=
INVALID_TPE);
248 uint64_t CargoSpec::WeightOfNUnitsInTrain(uint32_t n)
const
251 return this->WeightOfNUnits(n);
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Table of all default cargo types.
static const CargoSpec _default_cargo[]
Cargo types available by default.
static const std::variant< CargoLabel, int > _default_climate_cargo[NUM_LANDSCAPE][NUM_ORIGINAL_CARGO]
Table of cargo types available in each climate, by default.
static constexpr CargoLabel CT_INVALID
Invalid cargo type.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
bool IsDefaultCargo(CargoID cid)
Test if a cargo is a default cargo type.
static std::vector< CargoLabel > _default_cargo_labels
List of default cargo labels, used when setting up cargo types for default vehicles.
std::array< uint8_t, NUM_CARGO > _sorted_cargo_types
Sort order of cargoes by cargo ID.
static bool CargoSpecClassSorter(const CargoSpec *const &a, const CargoSpec *const &b)
Sort cargo specifications by their cargo class.
Dimension GetLargestCargoIconSize()
Get dimensions of largest cargo icon.
std::span< const CargoLabel > GetDefaultCargoTranslationTable(uint8_t grf_version)
Get default cargo translation table for a NewGRF, used if the NewGRF does not provide its own.
std::span< const CargoSpec * > _sorted_standard_cargo_specs
Standard cargo specifications sorted alphabetically by name.
CargoTypes _standard_cargo_mask
Bitmask of real cargo types available.
void BuildCargoLabelMap()
Build cargo label map.
static std::array< CargoLabel, 32 > _v8_cargo_labels
Default cargo translation for version 8+ NewGRFs.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
static bool CargoSpecNameSorter(const CargoSpec *const &a, const CargoSpec *const &b)
Sort cargo specifications by their name.
void InitializeSortedCargoSpecs()
Initialize the list of sorted cargo specifications.
void SetupCargoForClimate(LandscapeID l)
Set up the default cargo types for the given landscape type.
static std::array< CargoLabel, 12 > _v7_cargo_labels
Default cargo translation for upto version 7 NewGRFs.
CargoTypes _cargo_mask
Bitmask of cargo types available.
Types/functions related to cargoes.
@ CC_PASSENGERS
Passengers.
@ CC_SPECIAL
Special bit used for livery refit tricks instead of normal cargoes.
@ INVALID_TPE
Invalid town production effect.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
uint8_t LandscapeID
Landscape type.
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
Get the custom sprite for the given cargo type.
Cargo support for NewGRFs.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Types related to global configuration settings.
This file contains all sprite-related enums and defines.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
Functions related to low-level strings.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Functions related to OTTD's strings.
Specification of a cargo type.
CargoClasses classes
Classes of this cargo type.
uint8_t bitnum
Cargo bit number, is INVALID_CARGO_BITNUM for a non-used spec.
SpriteID GetCargoIcon() const
Get sprite for showing cargo of this type.
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).
CargoLabel label
Unique label of the cargo type.
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
static CargoSpec array[NUM_CARGO]
Array holding all CargoSpecs.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
StringID name
Name of this type of cargo.
static std::map< CargoLabel, CargoID > label_map
Translation map from CargoLabel to Cargo ID.
static std::array< std::vector< const CargoSpec * >, NUM_TPE > town_production_cargoes
List of cargo specs for each Town Product Effect.
Dimensions (a width and height) of a rectangle in 2D.
VehicleSettings vehicle
options for vehicles
uint8_t freight_trains
value to multiply the weight of cargo by