12#include "../newgrf_cargo.h"
17#include "../safeguards.h"
31 _cur_gps.
grffile->
cargo_list.assign(default_cargo_list.begin(), default_cargo_list.end());
55 GrfMsg(2,
"CargoChangeInfo: Cargo type {} out of range (max {})", last,
NUM_CARGO - 1);
59 for (uint
id = first;
id < last; ++id) {
111 cs->transit_periods[0] = buf.
ReadByte();
115 cs->transit_periods[1] = buf.
ReadByte();
145 uint8_t substitute_type = buf.
ReadByte();
147 switch (substitute_type) {
154 GrfMsg(1,
"CargoChangeInfo: Unknown town growth substitute value {}, setting to none.", substitute_type);
174 uint8_t substitute_type = buf.
ReadByte();
176 switch (substitute_type) {
180 GrfMsg(1,
"CargoChangeInfo: Unknown town production substitute value {}, setting to none.", substitute_type);
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
static constexpr CargoLabel CT_INVALID
Invalid cargo type.
static const CargoType NUM_CARGO
Maximum number of cargo types in a game.
void BuildCargoLabelMap()
Build cargo label map.
CargoTypes _cargo_mask
Bitmask of cargo types available.
@ TPE_NONE
Town will not produce this cargo type.
@ TPE_PASSENGERS
Cargo behaves passenger-like for production.
@ TPE_MAIL
Cargo behaves mail-like for production.
@ TAE_GOODS
Cargo behaves goods/candy-like.
@ TAE_NONE
Cargo has no effect.
@ TAE_PASSENGERS
Cargo behaves passenger-like.
@ TAE_MAIL
Cargo behaves mail-like.
@ TAE_FOOD
Cargo behaves food/fizzy-drinks-like.
@ TAE_WATER
Cargo behaves water-like.
Class to read from a NewGRF file.
uint32_t ReadDWord()
Read a single DWord (32 bits).
uint16_t ReadWord()
Read a single Word (16 bits).
uint8_t ReadByte()
Read a single byte (8 bits).
std::span< const CargoLabel > GetCargoTranslationTable(const GRFFile &grffile)
Get the cargo translation table to use for the given GRF file.
static ChangeInfoResult CargoReserveInfo(uint first, uint last, int prop, ByteReader &buf)
Define properties for cargoes.
static void MaybeInstallFallbackCargoLabel(uint id, uint last, CargoLabel label)
Install cargo label in a fallback cargo list, if a NewGRF-defined cargo list is not present.
NewGRF buffer reader definition.
NewGRF internal processing state.
ChangeInfoResult
Possible return values for the GrfChangeInfoHandler functions.
@ CIR_INVALID_ID
Attempt to modify an invalid ID.
@ CIR_UNKNOWN
Variable is unknown.
@ CIR_UNHANDLED
Variable was parsed but unread.
@ CIR_SUCCESS
Variable was parsed and read.
void AddStringForMapping(GRFStringID source, std::function< void(StringID)> &&func)
Record a static StringID for getting translated later.
NewGRF string mapping definition.
Specification of a cargo type.
int32_t initial_payment
Initial payment rate before inflation is applied.
CargoClasses classes
Classes of this cargo type.
uint16_t multiplier
Capacity multiplier for vehicles. (8 fractional bits)
StringID units_volume
Name of a single unit of cargo of this type.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo type.
StringID abbrev
Two letter abbreviation for this cargo type.
uint8_t bitnum
Cargo bit number, is INVALID_CARGO_BITNUM for a non-used spec.
StringID quantifier
Text for multiple units of 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).
uint8_t weight
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
CargoLabel label
Unique label of the cargo type.
const struct GRFFile * grffile
NewGRF where group belongs to.
StringID name
Name of this type of cargo.
TownProductionEffect town_production_effect
The effect on town cargo production.
TownAcceptanceEffect town_acceptance_effect
The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
CargoCallbackMasks callback_mask
Bitmask of cargo callbacks that have to be called.
uint16_t town_production_multiplier
Town production multiplier, if commanded by TownProductionEffect.
bool IsValid() const
Tests for validity of this cargospec.
StringID name_single
Name of a single entity of this type of cargo.
bool cargo_list_is_fallback
Set if cargo types have been created but a cargo list has not been installed.
std::vector< CargoLabel > cargo_list
Cargo translation table (local ID -> label)
GRFFile * grffile
Currently processed GRF file.
Colour for pixel/line drawing.