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

OpenTTD Source 15.0-RC2

cargo_const.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "../table/sprites.h"
11#ifndef CHECK_UNUSED_STRINGS
12#include "table/strings.h"
13#endif
14
16#define MK_STR_CARGO_PLURAL(label_plural) STR_CARGO_PLURAL_ ## label_plural
17#define MK_STR_CARGO_SINGULAR(label_singular) STR_CARGO_SINGULAR_ ## label_singular
18#define MK_STR_QUANTITY(label_plural) STR_QUANTITY_ ## label_plural
19#define MK_STR_ABBREV(label_plural) STR_ABBREV_ ## label_plural
21#define MK_SPRITE(label_plural) SPR_CARGO_ ## label_plural
22
51#define MK(bt, label, colour, weight, mult, ip, td1, td2, freight, tae, str_plural, str_singular, str_volume, classes) \
52 {label, bt, PixelColour{colour}, PixelColour{colour}, weight, mult, classes, ip, {td1, td2}, freight, tae, INVALID_TPE, TOWN_PRODUCTION_DIVISOR, CargoCallbackMasks{}, \
53 MK_STR_CARGO_PLURAL(str_plural), MK_STR_CARGO_SINGULAR(str_singular), str_volume, MK_STR_QUANTITY(str_plural), MK_STR_ABBREV(str_plural), \
54 MK_SPRITE(str_plural), nullptr, nullptr, 0}
55
57 static const CargoSpec _default_cargo[] = {
58 MK( 0, CT_PASSENGERS, 152, 1, 0x400, 3185, 0, 24, false, TAE_PASSENGERS, PASSENGERS, PASSENGER, STR_PASSENGERS, CargoClasses({CargoClass::Passengers})),
59 MK( 1, CT_COAL, 6, 16, 0x100, 5916, 7, 255, true, TAE_NONE, COAL, COAL, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::NonPotable})),
60 MK( 2, CT_MAIL, 15, 4, 0x200, 4550, 20, 90, false, TAE_MAIL, MAIL, MAIL, STR_BAGS, CargoClasses({CargoClass::Mail})),
61 /* Oil in temperate and arctic */
62 MK( 3, CT_OIL, 174, 16, 0x100, 4437, 25, 255, true, TAE_NONE, OIL, OIL, STR_LITERS, CargoClasses({CargoClass::Liquid, CargoClass::NonPotable})),
63 /* Oil in subtropic */
64 MK( 3, CT_OIL, 174, 16, 0x100, 4892, 25, 255, true, TAE_NONE, OIL, OIL, STR_LITERS, CargoClasses({CargoClass::Liquid, CargoClass::NonPotable})),
65 MK( 4, CT_LIVESTOCK, 208, 3, 0x100, 4322, 4, 18, true, TAE_NONE, LIVESTOCK, LIVESTOCK, STR_ITEMS, CargoClasses({CargoClass::PieceGoods, CargoClass::NonPotable})),
66 MK( 5, CT_GOODS, 194, 8, 0x200, 6144, 5, 28, true, TAE_GOODS, GOODS, GOODS, STR_CRATES, CargoClasses({CargoClass::Express})),
67 MK( 6, CT_GRAIN, 191, 16, 0x100, 4778, 4, 40, true, TAE_NONE, GRAIN, GRAIN, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Potable})),
68 MK( 6, CT_WHEAT, 191, 16, 0x100, 4778, 4, 40, true, TAE_NONE, WHEAT, WHEAT, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Potable})),
69 MK( 6, CT_MAIZE, 191, 16, 0x100, 4322, 4, 40, true, TAE_NONE, MAIZE, MAIZE, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Potable})),
70 /* Wood in temperate and arctic */
71 MK( 7, CT_WOOD, 84, 16, 0x100, 5005, 15, 255, true, TAE_NONE, WOOD, WOOD, STR_TONS, CargoClasses({CargoClass::PieceGoods})),
72 /* Wood in subtropic */
73 MK( 7, CT_WOOD, 84, 16, 0x100, 7964, 15, 255, true, TAE_NONE, WOOD, WOOD, STR_TONS, CargoClasses({CargoClass::PieceGoods})),
74 MK( 8, CT_IRON_ORE, 184, 16, 0x100, 5120, 9, 255, true, TAE_NONE, IRON_ORE, IRON_ORE, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::NonPotable})),
75 MK( 9, CT_STEEL, 10, 16, 0x100, 5688, 7, 255, true, TAE_NONE, STEEL, STEEL, STR_TONS, CargoClasses({CargoClass::PieceGoods})),
76 MK( 10, CT_VALUABLES, 202, 2, 0x100, 7509, 1, 32, true, TAE_NONE, VALUABLES, VALUABLES, STR_BAGS, CargoClasses({CargoClass::Armoured})),
77 MK( 10, CT_GOLD, 202, 8, 0x100, 5802, 10, 40, true, TAE_NONE, GOLD, GOLD, STR_BAGS, CargoClasses({CargoClass::Armoured})),
78 MK( 10, CT_DIAMONDS, 202, 2, 0x100, 5802, 10, 255, true, TAE_NONE, DIAMONDS, DIAMOND, STR_BAGS, CargoClasses({CargoClass::Armoured})),
79 MK( 11, CT_PAPER, 10, 16, 0x100, 5461, 7, 60, true, TAE_NONE, PAPER, PAPER, STR_TONS, CargoClasses({CargoClass::PieceGoods})),
80 MK( 12, CT_FOOD, 48, 16, 0x100, 5688, 0, 30, true, TAE_FOOD, FOOD, FOOD, STR_TONS, CargoClasses({CargoClass::Express, CargoClass::Refrigerated, CargoClass::Potable})),
81 MK( 13, CT_FRUIT, 208, 16, 0x100, 4209, 0, 15, true, TAE_NONE, FRUIT, FRUIT, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Refrigerated, CargoClass::Potable})),
82 MK( 14, CT_COPPER_ORE, 184, 16, 0x100, 4892, 12, 255, true, TAE_NONE, COPPER_ORE, COPPER_ORE, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::NonPotable})),
83 MK( 15, CT_WATER, 10, 16, 0x100, 4664, 20, 80, true, TAE_WATER, WATER, WATER, STR_LITERS, CargoClasses({CargoClass::Liquid, CargoClass::Potable})),
84 MK( 16, CT_RUBBER, 6, 16, 0x100, 4437, 2, 20, true, TAE_NONE, RUBBER, RUBBER, STR_LITERS, CargoClasses({CargoClass::Liquid, CargoClass::NonPotable})),
85 MK( 17, CT_SUGAR, 6, 16, 0x100, 4437, 20, 255, true, TAE_NONE, SUGAR, SUGAR, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Potable})),
86 MK( 18, CT_TOYS, 174, 2, 0x100, 5574, 25, 255, true, TAE_NONE, TOYS, TOY, STR_ITEMS, CargoClasses({CargoClass::PieceGoods})),
87 MK( 19, CT_BATTERIES, 208, 4, 0x100, 4322, 2, 30, true, TAE_NONE, BATTERIES, BATTERY, STR_ITEMS, CargoClasses({CargoClass::PieceGoods})),
88 MK( 20, CT_CANDY, 194, 5, 0x200, 6144, 8, 40, true, TAE_GOODS, SWEETS, SWEETS, STR_BAGS, CargoClasses({CargoClass::Express})),
89 MK( 21, CT_TOFFEE, 191, 16, 0x100, 4778, 14, 60, true, TAE_NONE, TOFFEE, TOFFEE, STR_TONS, CargoClasses({CargoClass::Bulk})),
90 MK( 22, CT_COLA, 84, 16, 0x100, 4892, 5, 75, true, TAE_NONE, COLA, COLA, STR_LITERS, CargoClasses({CargoClass::Liquid})),
91 MK( 23, CT_COTTON_CANDY, 184, 16, 0x100, 5005, 10, 25, true, TAE_NONE, CANDYFLOSS, CANDYFLOSS, STR_TONS, CargoClasses({CargoClass::Bulk})),
92 MK( 24, CT_BUBBLES, 10, 1, 0x100, 5077, 20, 80, true, TAE_NONE, BUBBLES, BUBBLE, STR_ITEMS, CargoClasses({CargoClass::PieceGoods})),
93 MK( 25, CT_PLASTIC, 202, 16, 0x100, 4664, 30, 255, true, TAE_NONE, PLASTIC, PLASTIC, STR_LITERS, CargoClasses({CargoClass::Liquid})),
94 MK( 26, CT_FIZZY_DRINKS, 48, 2, 0x100, 6250, 30, 50, true, TAE_FOOD, FIZZY_DRINKS, FIZZY_DRINK, STR_ITEMS, CargoClasses({CargoClass::PieceGoods})),
95
96 /* Void slot in temperate */
97 MK(0xFF, CT_INVALID, 1, 0, 0x100, 5688, 0, 30, true, TAE_NONE, NOTHING, NOTHING, STR_TONS, CargoClasses({})),
98 /* Void slot in arctic */
99 MK(0xFF, CT_INVALID, 184, 0, 0x100, 5120, 9, 255, true, TAE_NONE, NOTHING, NOTHING, STR_TONS, CargoClasses({})),
100};
101
102
104 static const std::variant<CargoLabel, int> _default_climate_cargo[NUM_LANDSCAPE][NUM_ORIGINAL_CARGO] = {
105 { CT_PASSENGERS, CT_COAL, CT_MAIL, CT_OIL, CT_LIVESTOCK, CT_GOODS, CT_GRAIN, CT_WOOD, CT_IRON_ORE, CT_STEEL, CT_VALUABLES, 33, },
106 { CT_PASSENGERS, CT_COAL, CT_MAIL, CT_OIL, CT_LIVESTOCK, CT_GOODS, CT_WHEAT, CT_WOOD, 34, CT_PAPER, CT_GOLD, CT_FOOD, },
107 { CT_PASSENGERS, CT_RUBBER, CT_MAIL, 4, CT_FRUIT, CT_GOODS, CT_MAIZE, 11, CT_COPPER_ORE, CT_WATER, CT_DIAMONDS, CT_FOOD, },
108 { 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, },
109};
110
MK
#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.
Definition cargo_const.h:51
_default_cargo
static const CargoSpec _default_cargo[]
Cargo types available by default.
Definition cargo_const.h:57
_default_climate_cargo
static const std::variant< CargoLabel, int > _default_climate_cargo[NUM_LANDSCAPE][NUM_ORIGINAL_CARGO]
Table of cargo types available in each climate, by default.
Definition cargo_const.h:104
CT_INVALID
static constexpr CargoLabel CT_INVALID
Invalid cargo type.
Definition cargo_type.h:70
NUM_ORIGINAL_CARGO
static const CargoType NUM_ORIGINAL_CARGO
Original number of cargo types.
Definition cargo_type.h:72
CT_PASSENGERS
static constexpr CargoLabel CT_PASSENGERS
Available types of cargo Labels may be re-used between different climates.
Definition cargo_type.h:29
CargoClass::NonPotable
@ NonPotable
Non-potable / non-food / dirty.
CargoClass::Bulk
@ Bulk
Bulk cargo (Coal, Grain etc., Ores, Fruit)
CargoClass::Mail
@ Mail
Mail.
CargoClass::Liquid
@ Liquid
Liquids (Oil, Water, Rubber)
CargoClass::Passengers
@ Passengers
Passengers.
CargoClass::Potable
@ Potable
Potable / food / clean.
CargoClass::Armoured
@ Armoured
Armoured cargo (Valuables, Gold, Diamonds)
CargoClass::Refrigerated
@ Refrigerated
Refrigerated cargo (Food, Fruit)
CargoClass::Express
@ Express
Express cargo (Goods, Food, Candy, but also possible for passengers)
CargoClass::PieceGoods
@ PieceGoods
Piece goods (Livestock, Wood, Steel, Paper)
TAE_GOODS
@ TAE_GOODS
Cargo behaves goods/candy-like.
Definition cargotype.h:27
TAE_NONE
@ TAE_NONE
Cargo has no effect.
Definition cargotype.h:24
TAE_PASSENGERS
@ TAE_PASSENGERS
Cargo behaves passenger-like.
Definition cargotype.h:25
TAE_MAIL
@ TAE_MAIL
Cargo behaves mail-like.
Definition cargotype.h:26
TAE_FOOD
@ TAE_FOOD
Cargo behaves food/fizzy-drinks-like.
Definition cargotype.h:29
TAE_WATER
@ TAE_WATER
Cargo behaves water-like.
Definition cargotype.h:28
EnumBitSet< CargoClass, uint16_t >
CargoSpec
Specification of a cargo type.
Definition cargotype.h:74