19#include "table/strings.h"
78 const CargoSpec &operator()(
const int &index)
94 *insert = std::visit(visitor{}, cl);
96 if (insert->IsValid()) {
155 if (!cs->IsValid())
return false;
181 if (sprite == 0xFFFF) {
244 uint8_t nb_standard_cargo = 0;
246 assert(cargo->town_production_effect !=
INVALID_TPE);
257uint64_t CargoSpec::WeightOfNUnitsInTrain(uint32_t n)
const
260 return this->WeightOfNUnits(n);
274 std::stringstream line;
280 if (acceptance[cid] > 0) {
282 if (found) line << list_separator;
286 if (acceptance[cid] < 8) {
289 line <<
GetString(STR_LAND_AREA_INFORMATION_CARGO_EIGHTS);
296 if (found)
return line.str();
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Table of all default cargo types.
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.
static constexpr CargoLabel CT_INVALID
Invalid cargo type.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
bool IsDefaultCargo(CargoID cid)
Test if a cargo is a default cargo type.
static std::array< CargoLabel, 32 > _climate_independent_cargo_labels
Default cargo translation for version 8+ NewGRFs.
static std::vector< CargoLabel > _default_cargo_labels
List of default cargo labels, used when setting up cargo types for default vehicles.
std::span< const CargoLabel > GetClimateDependentCargoTranslationTable()
Get default climate-dependent cargo translation table for a NewGRF, used if the NewGRF does not provi...
std::array< uint8_t, NUM_CARGO > _sorted_cargo_types
Sort order of cargoes by cargo ID.
static bool CargoSpecClassSorter(const CargoSpec *const &a, const CargoSpec *const &b)
Sort cargo specifications by their cargo class.
Dimension GetLargestCargoIconSize()
Get dimensions of largest cargo icon.
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::span< const CargoLabel > GetClimateIndependentCargoTranslationTable()
Get default climate-independent cargo translation table for a NewGRF, used if the NewGRF does not pro...
void BuildCargoLabelMap()
Build cargo label map.
std::optional< std::string > BuildCargoAcceptanceString(const CargoArray &acceptance, StringID label)
Build comma-separated cargo acceptance string.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
static bool CargoSpecNameSorter(const CargoSpec *const &a, const CargoSpec *const &b)
Sort cargo specifications by their name.
void InitializeSortedCargoSpecs()
Initialize the list of sorted cargo specifications.
void SetupCargoForClimate(LandscapeID l)
Set up the default cargo types for the given landscape type.
static std::array< CargoLabel, 12 > _climate_dependent_cargo_labels
Default cargo translation for upto version 7 NewGRFs.
CargoTypes _cargo_mask
Bitmask of cargo types available.
Types/functions related to cargoes.
@ CC_PASSENGERS
Passengers.
@ CC_SPECIAL
Special bit used for livery refit tricks instead of normal cargoes.
@ INVALID_TPE
Invalid town production effect.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
uint8_t LandscapeID
Landscape type.
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
Get the custom sprite for the given cargo type.
Cargo support for NewGRFs.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Types related to global configuration settings.
This file contains all sprite-related enums and defines.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
Functions related to low-level strings.
std::string_view GetListSeparator()
Get the list separator string for the current language.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Class for storing amounts of cargo.
Specification of a cargo type.
CargoClasses classes
Classes of this cargo type.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
uint8_t bitnum
Cargo bit number, is INVALID_CARGO_BITNUM for a non-used spec.
SpriteID GetCargoIcon() const
Get sprite for showing 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).
CargoLabel label
Unique label of the cargo type.
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
static CargoSpec array[NUM_CARGO]
Array holding all CargoSpecs.
StringID name
Name of this type of cargo.
static std::map< CargoLabel, CargoID > label_map
Translation map from CargoLabel to Cargo ID.
static std::array< std::vector< const CargoSpec * >, NUM_TPE > town_production_cargoes
List of cargo specs for each Town Product Effect.
Dimensions (a width and height) of a rectangle in 2D.
VehicleSettings vehicle
options for vehicles
uint8_t freight_trains
value to multiply the weight of cargo by