155 return n * this->weight / 16u;
246 static inline std::map<CargoLabel, CargoType>
label_map{};
Types related to cargoes...
Label< struct CargoLabelTag > CargoLabel
Globally unique label of a cargo type.
static constexpr CargoType INVALID_CARGO
Invalid marker for cargoes.
EnumBitSet< CargoType, uint64_t > CargoTypes
Bitset of CargoType elements.
static constexpr CargoType NUM_CARGO
Maximum number of cargo types in a game.
CargoType
Cargo slots to indicate a cargo type within a game.
std::array< uint8_t, NUM_CARGO > _sorted_cargo_types
Sort order of cargoes by cargo type.
std::span< const CargoSpec * > _sorted_standard_cargo_specs
Standard cargo specifications sorted alphabetically by name.
CargoTypes _standard_cargo_mask
Bitmask of real cargo types available.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
CargoTypes _cargo_mask
Bitmask of cargo types available.
CargoType GetCargoTypeByLabel(CargoLabel label)
Get cargo assigned to a label.
std::array< uint8_t, NUM_CARGO > _sorted_cargo_types
Sort order of cargoes by cargo type.
Dimension GetLargestCargoIconSize()
Get dimensions of largest cargo icon.
bool IsDefaultCargo(CargoType cargo_type)
Test if a cargo is a default cargo type.
static const uint8_t INVALID_CARGO_BITNUM
Constant representing invalid cargo bit number.
void BuildCargoLabelMap()
Build cargo label map.
std::optional< std::string > BuildCargoAcceptanceString(const CargoArray &acceptance, StringID label)
Build comma-separated cargo acceptance string.
void SetupCargoForClimate(LandscapeType l)
Set up the default cargo types for the given landscape type.
@ NotPourable
Not Pourable (open wagon, but not hopper wagon).
@ Powderized
Powderized, moist protected (powder/silo wagon).
@ Hazardous
Hazardous cargo (Nuclear Fuel, Explosives, etc.).
@ NonPotable
Non-potable / non-food / dirty.
@ Bulk
Bulk cargo (Coal, Grain etc., Ores, Fruit).
@ Liquid
Liquids (Oil, Water, Rubber).
@ Potable
Potable / food / clean.
@ Oversized
Oversized (stake/flatbed wagon).
@ Armoured
Armoured cargo (Valuables, Gold, Diamonds).
@ Refrigerated
Refrigerated cargo (Food, Fruit).
@ Express
Express cargo (Goods, Food, Candy, but also possible for passengers).
@ Special
Special bit used for livery refit tricks instead of normal cargoes.
@ PieceGoods
Piece goods (Livestock, Wood, Steel, Paper).
@ Covered
Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.).
static const uint TOWN_PRODUCTION_DIVISOR
By what factor divide town production.
TownProductionEffect
Town effect when producing cargo.
@ Invalid
Invalid town production effect.
EnumBitSet< CargoClass, uint16_t > CargoClasses
Bitset of CargoClass elements.
void InitializeSortedCargoSpecs()
Initialize the list of sorted cargo specifications.
TownAcceptanceEffect
Town growth effect when delivering cargo.
@ Food
Cargo behaves food/fizzy-drinks-like.
@ Begin
Used for iteration.
@ Water
Cargo behaves water-like.
@ Mail
Cargo behaves mail-like.
@ Passengers
Cargo behaves passenger-like.
@ None
Cargo has no effect.
@ End
End of town effects.
@ Goods
Cargo behaves goods/candy-like.
bool IsCargoInClass(CargoType cargo, CargoClasses cc)
Does a given cargo have any cargo class from cc.
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
Types related to the economy.
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
Types related to the graphics and/or input devices.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Types related to the landscape.
LandscapeType
Landscape types.
Callbacks that NewGRFs could implement.
EnumBitSet< CargoCallbackMask, uint8_t > CargoCallbackMasks
Bitset of CargoCallbackMask elements.
@ Invalid
broken savegame (used internally)
#define lengthof(array)
Return the length of an fixed size array.
Types related to strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
Class for storing amounts of cargo.
Iterable ensemble of all valid CargoSpec.
bool empty()
Check whether this range of valid CargoSpec is empty.
Iterator end()
Get the end iterator for all valid CargoSpec.
Iterator begin()
Get the begin iterator for this range of valid CargoSpec.
IterateWrapper(size_t from=0)
Constructs new iterator wrapper from an stating index.
size_t from
Index from which the iteration started.
Iterator to iterate all valid CargoSpec.
std::forward_iterator_tag iterator_category
The category of the iterator.
CargoSpec * operator*() const
Dereference operator.
Iterator(size_t index)
Constructs new iterator from an index.
void ValidateIndex()
Validate index so it points to a valid cargo spec.
Iterator & operator++()
Increment the iterator and set it to the next position.
size_t index
Index of the CargoSpec that this iterator points to.
bool operator==(const Iterator &other) const
Compare with other iterator.
CargoSpec * pointer
The pointer type to value_type.
CargoSpec value_type
The type pointed by iterator.
CargoSpec & reference
The reference type to value_type.
size_t difference_type
Type used to store difference between two iterators.
Specification of a cargo type.
int32_t initial_payment
Initial payment rate before inflation is applied.
friend CargoType GetCargoTypeByLabel(CargoLabel label)
Get cargo assigned to a label.
static EnumIndexArray< std::vector< const CargoSpec * >, TownProductionEffect, TownProductionEffect::End > town_production_cargoes
List of cargo specs for each Town Product Effect.
CargoClasses classes
Classes of this cargo type.
const struct SpriteGroup * group
Group of sprites used for drawing the cargo.
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.
static std::map< CargoLabel, CargoType > label_map
Translation map from CargoLabel to Cargo type.
StringID quantifier
Text for multiple units of cargo of this type.
SpriteID GetCargoIcon() const
Get sprite for showing cargo of this type.
CargoType Index() const
Determines index of this cargospec.
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).
PixelColour legend_colour
Colour in legends and graphs.
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.
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
Money current_payment
Payment rate scaled by inflation.
static CargoSpec array[NUM_CARGO]
Array holding all CargoSpecs.
uint64_t WeightOfNUnits(uint32_t n) const
Calculate the weight of n units of cargo.
PixelColour rating_colour
Colour used for box representing the amount of cargo waiting at the station in the station rating vie...
uint64_t WeightOfNUnitsInTrain(uint32_t n) const
Calculate the weight of n units of cargo inside a train wagon.
uint8_t transit_periods[2]
Values used to calculate timefactor for cargo payment alghoritm.
friend void BuildCargoLabelMap()
Build cargo label map.
StringID name
Name of this type of cargo.
friend void FinaliseCargoArray()
Check for invalid cargoes.
friend void SetupCargoForClimate(LandscapeType l)
Set up the default cargo types for the given landscape type.
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 size_t GetArraySize()
Total number of cargospecs, both valid and invalid.
Comparator to sort CargoType by according to desired order.
bool operator()(const CargoType &lhs, const CargoType &rhs) const
Call operator that performs the comparison.
Dimensions (a width and height) of a rectangle in 2D.
Dynamic data of a loaded NewGRF.
Colour for pixel/line drawing.
Common wrapper for all the different sprite group types.