20 #include "table/strings.h" 47 memset(CargoSpec::array, 0,
sizeof(CargoSpec::array));
91 FOR_ALL_CARGOSPECS(cs) {
110 FOR_ALL_CARGOSPECS(cs) {
125 if (sprite == 0xFFFF) {
130 if (sprite == 0) sprite = SPR_CARGO_GOODS;
143 static char a_name[64];
144 static char b_name[64];
146 GetString(a_name, (*a)->name,
lastof(a_name));
147 GetString(b_name, (*b)->name,
lastof(b_name));
152 return (res != 0) ? res : ((*a)->bitnum - (*b)->bitnum);
178 FOR_ALL_CARGOSPECS(cargo) {
Functions related to OTTD's strings.
Special bit used for livery refit tricks instead of normal cargoes.
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
Get the custom sprite for the given cargo type.
CargoID GetCargoIDByLabel(CargoLabel cl)
Get the cargo ID by cargo label.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
#define FOR_ALL_SORTED_CARGOSPECS(var)
Loop header for iterating over cargoes, sorted by name.
Specification of a cargo type.
uint8 _sorted_cargo_specs_size
Number of cargo specifications stored at the _sorted_cargo_specs array (including special cargoes)...
#define lastof(x)
Get the last element of an fixed size array.
uint16 classes
Classes of this cargo type.
uint16 multiplier
Capacity multiplier for vehicles. (8 fractional bits)
Functions related to low-level strings.
static int CDECL CargoSpecNameSorter(const CargoSpec *const *a, const CargoSpec *const *b)
Sort cargo specifications by their name.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
Table of all default cargo types.
static const CargoLabel _default_climate_cargo[NUM_LANDSCAPE][12]
Table of cargo types available in each climate, by default.
CargoLabel label
Unique label of the cargo type.
static const CargoSpec _default_cargo[]
Cargo types available by default.
#define lengthof(x)
Return the length of an fixed size array.
static int CDECL CargoSpecClassSorter(const CargoSpec *const *a, const CargoSpec *const *b)
Sort cargo specifications by their cargo class.
Maximal number of cargo types in a game.
uint8 _sorted_standard_cargo_specs_size
Number of standard cargo specifications stored at the _sorted_cargo_specs array.
CargoID GetCargoIDByBitnum(uint8 bitnum)
Find the CargoID of a 'bitnum' value.
SpriteID GetCargoIcon() const
Get sprite for showing cargo of this type.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
byte LandscapeID
Landscape type.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Cargo support for NewGRFs.
void InitializeSortedCargoSpecs()
Initialize the list of sorted cargo specifications.
Functions related to sorting operations.
static const byte INVALID_CARGO
Constant representing invalid cargo.
uint32 CargoLabel
Globally unique label of a cargo type.
uint32 _cargo_mask
Bitmask of cargo types available.
Types/functions related to cargoes.
CargoID Index() const
Determines index of this cargospec.
uint32 _standard_cargo_mask
Bitmask of real cargo types available.
static CargoSpec array[NUM_CARGO]
Array holding all CargoSpecs.
uint8 bitnum
Cargo bit number, is INVALID_CARGO for a non-used spec.
byte CargoID
Cargo slots to indicate a cargo type within a game.
const CargoSpec * _sorted_cargo_specs[NUM_CARGO]
Cargo specifications sorted alphabetically by name.
SpriteID sprite
Icon to display this cargo type, may be 0xFFF (which means to resolve an action123 chain)...
static void QSortT(T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
Type safe qsort()
This file contains all sprite-related enums and defines.
void SetupCargoForClimate(LandscapeID l)
Set up the default cargo types for the given landscape type.