OpenTTD Source  20240919-master-gdf0233f4c2
cargo_const.h File Reference

Go to the source code of this file.

Macros

#define MK_STR_CARGO_PLURAL(label_plural)   STR_CARGO_PLURAL_ ## label_plural
 Construction macros for the CargoSpec StringID entries.
 
#define MK_STR_CARGO_SINGULAR(label_singular)   STR_CARGO_SINGULAR_ ## label_singular
 
#define MK_STR_QUANTITY(label_plural)   STR_QUANTITY_ ## label_plural
 
#define MK_STR_ABBREV(label_plural)   STR_ABBREV_ ## label_plural
 
#define MK_SPRITE(label_plural)   SPR_CARGO_ ## label_plural
 Construction macros for the CargoSpec SpriteID entry.
 
#define MK(bt, label, colour, weight, mult, ip, td1, td2, freight, tae, str_plural, str_singular, str_volume, classes)
 Construction macro for a CargoSpec structure. More...
 

Variables

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. More...
 

Detailed Description

Table of all default cargo types

Definition in file cargo_const.h.

Macro Definition Documentation

◆ MK

#define MK (   bt,
  label,
  colour,
  weight,
  mult,
  ip,
  td1,
  td2,
  freight,
  tae,
  str_plural,
  str_singular,
  str_volume,
  classes 
)
Value:
{label, bt, colour, colour, weight, mult, classes, ip, {td1, td2}, freight, tae, INVALID_TPE, TOWN_PRODUCTION_DIVISOR, 0, \
MK_STR_CARGO_PLURAL(str_plural), MK_STR_CARGO_SINGULAR(str_singular), str_volume, MK_STR_QUANTITY(str_plural), MK_STR_ABBREV(str_plural), \
MK_SPRITE(str_plural), nullptr, nullptr, 0}

Construction macro for a CargoSpec structure.

The order of arguments matches the order in which they are defined in CargoSpec. Some macros are used to automatically expand to the correct StringID consts, this means that adding/changing a cargo spec requires updating of the following strings:

  • STR_CARGO_PLURAL_<str_plural>
  • STR_CARGO_SINGULAR_<str_singular>
  • STR_QUANTITY_<str_plural>
  • STR_ABBREV_<str_plural> And the following sprite:
  • SPR_CARGO_<str_plural>
Parameters
btCargo bit number, is INVALID_CARGO_BITNUM for a non-used spec.
labelUnique label of the cargo type.
colourCargoSpec->legend_colour and CargoSpec->rating_colour.
weightWeight of a single unit of this cargo type in 1/16 ton (62.5 kg).
multCapacity multiplier for vehicles. (8 fractional bits).
ipCargoSpec->initial_payment.
td1CargoSpec->transit_periods[0].
td2CargoSpec->transit_periods[1].
freightCargo type is considered to be freight (affects train freight multiplier).
taeThe effect that delivering this cargo type has on towns.
str_pluralThe name suffix used to populate CargoSpec->name, CargoSpec->quantifier, CargoSpec->abbrev and CargoSpec->sprite. See above for more detailed information.
str_singularThe name suffix used to populate CargoSpec->name_single. See above for more information.
str_volumeName of a single unit of cargo of this type.
classesClasses of this cargo type.
See also
CargoClass

Definition at line 46 of file cargo_const.h.

Variable Documentation

◆ _default_climate_cargo

const std::variant<CargoLabel, int> _default_climate_cargo[NUM_LANDSCAPE][NUM_ORIGINAL_CARGO]
static
Initial value:
= {
{ CT_PASSENGERS, CT_COAL, CT_MAIL, CT_OIL, CT_LIVESTOCK, CT_GOODS, CT_GRAIN, CT_WOOD, CT_IRON_ORE, CT_STEEL, CT_VALUABLES, 33, },
{ CT_PASSENGERS, CT_COAL, CT_MAIL, CT_OIL, CT_LIVESTOCK, CT_GOODS, CT_WHEAT, CT_WOOD, 34, CT_PAPER, CT_GOLD, CT_FOOD, },
{ CT_PASSENGERS, CT_RUBBER, CT_MAIL, 4, CT_FRUIT, CT_GOODS, CT_MAIZE, 11, CT_COPPER_ORE, CT_WATER, CT_DIAMONDS, CT_FOOD, },
{ CT_PASSENGERS, CT_SUGAR, CT_MAIL, CT_TOYS, CT_BATTERIES, CT_CANDY, CT_TOFFEE, CT_COLA, CT_COTTON_CANDY, CT_BUBBLES, CT_PLASTIC, CT_FIZZY_DRINKS, },
}

Table of cargo types available in each climate, by default.

Definition at line 99 of file cargo_const.h.

Referenced by SetupCargoForClimate().

INVALID_TPE
@ INVALID_TPE
Invalid town production effect.
Definition: cargotype.h:44
CT_PASSENGERS
static constexpr CargoLabel CT_PASSENGERS
Available types of cargo Labels may be re-used between different climates.
Definition: cargo_type.h:30