28 if (_cur_gps.grffile->cargo_list.empty()) {
31 _cur_gps.grffile->cargo_list.assign(default_cargo_list.begin(), default_cargo_list.end());
32 _cur_gps.grffile->cargo_list_is_fallback =
true;
35 if (_cur_gps.grffile->cargo_list_is_fallback) {
37 if (_cur_gps.grffile->cargo_list.size() < last) _cur_gps.grffile->cargo_list.resize(last,
CT_INVALID);
38 _cur_gps.grffile->cargo_list[id] = label;
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 enable_if_t< is_integral_v< T >, T > byteswap(T x) noexcept
Custom implementation of std::byteswap; remove once we build with C++23.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
static constexpr CargoLabel CT_INVALID
Invalid cargo type.
StrongType::Typedef< uint32_t, struct CargoLabelTag, StrongType::Compare > CargoLabel
Globally unique label of a 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.
@ Mail
Cargo behaves mail-like for production.
@ Passengers
Cargo behaves passenger-like for production.
@ None
Town will not produce this cargo type.
@ Food
Cargo behaves food/fizzy-drinks-like.
@ Water
Cargo behaves water-like.
@ Mail
Cargo behaves mail-like.
@ Passengers
Cargo behaves passenger-like.
@ None
Cargo has no effect.
@ Goods
Cargo behaves goods/candy-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).
Functions related to debugging.
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.
Cargo support for NewGRFs.
NewGRF internal processing state.
ChangeInfoResult
Possible return values for the GrfChangeInfoHandler functions.
@ Success
Variable was parsed and read.
@ Unhandled
Variable was parsed but unread.
@ Unknown
Variable is unknown.
@ InvalidId
Attempt to modify an invalid ID.
void AddStringForMapping(GRFStringID source, std::function< void(StringID)> &&func)
Record a static StringID for getting translated later.
NewGRF string mapping definition.
StrongType::Typedef< uint32_t, struct GRFStringIDTag, StrongType::Compare, StrongType::Integer > GRFStringID
Type for GRF-internal string IDs.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
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.
static ChangeInfoResult Reserve(uint first, uint last, int prop, ByteReader &buf)
Implementation of the GrfLoadingStage::Reserve stage of this feature.
static ChangeInfoResult Activation(uint first, uint last, int prop, ByteReader &buf)
Implementation of the GrfLoadingStage::Activation stage of this feature.
Colour for pixel/line drawing.