OpenTTD Source: src/table/cargo_const.h File Reference

OpenTTD Source 15.3

Macros | Variables
cargo_const.h File Reference

Table of all default cargo types. More...

`#include "../table/sprites.h"`
`#include "table/strings.h"`

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.

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

## 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, PixelColour{colour}, PixelColour{colour}, weight, mult, classes, ip, {td1, td2}, freight, tae, INVALID_TPE, TOWN_PRODUCTION_DIVISOR, CargoCallbackMasks{}, \
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}
INVALID_TPE
@ INVALID_TPE
Invalid town production effect.
Definition cargotype.h:45
EnumBitSet< CargoCallbackMask, uint8_t >
PixelColour
Colour for pixel/line drawing.
Definition gfx_type.h:405

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

  bt | Cargo bit number, is INVALID_CARGO_BITNUM for a non-used spec.
  label | Unique label of the cargo type.
  colour | CargoSpec->legend_colour and CargoSpec->rating_colour.
  weight | Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
  mult | Capacity multiplier for vehicles. (8 fractional bits).
  ip | CargoSpec->initial_payment.
  td1 | CargoSpec->transit_periods[0].
  td2 | CargoSpec->transit_periods[1].
  freight | Cargo type is considered to be freight (affects train freight multiplier).
  tae | The effect that delivering this cargo type has on towns.
  str_plural | The name suffix used to populate CargoSpec->name, CargoSpec->quantifier, CargoSpec->abbrev and CargoSpec->sprite. See above for more detailed information.
  str_singular | The name suffix used to populate CargoSpec->name_single. See above for more information.
  str_volume | Name of a single unit of cargo of this type.
  classes | Classes of this cargo type.

See also
  CargoClass

Definition at line 51 of file cargo_const.h.

## ◆ MK_SPRITE

#define MK_SPRITE | ( |  | label_plural | ) | SPR_CARGO_ ## label_plural

Construction macros for the CargoSpec SpriteID entry.

Definition at line 21 of file cargo_const.h.

## ◆ MK_STR_ABBREV

#define MK_STR_ABBREV | ( |  | label_plural | ) | STR_ABBREV_ ## label_plural

Definition at line 19 of file cargo_const.h.

## ◆ MK_STR_CARGO_PLURAL

#define MK_STR_CARGO_PLURAL | ( |  | label_plural | ) | STR_CARGO_PLURAL_ ## label_plural

Construction macros for the CargoSpec StringID entries.

Definition at line 16 of file cargo_const.h.

## ◆ MK_STR_CARGO_SINGULAR

#define MK_STR_CARGO_SINGULAR | ( |  | label_singular | ) | STR_CARGO_SINGULAR_ ## label_singular

Definition at line 17 of file cargo_const.h.

## ◆ MK_STR_QUANTITY

#define MK_STR_QUANTITY | ( |  | label_plural | ) | STR_QUANTITY_ ## label_plural

Definition at line 18 of file cargo_const.h.

## Variable Documentation

## ◆ _default_cargo

const CargoSpec _default_cargo[]
| static

Cargo types available by default.

Definition at line 57 of file cargo_const.h.

## ◆ _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, },
}
CT_PASSENGERS
static constexpr CargoLabel CT_PASSENGERS
Available types of cargo Labels may be re-used between different climates.
Definition cargo_type.h:29

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

Definition at line 104 of file cargo_const.h.