OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
68 static const uint TOWN_PRODUCTION_DIVISOR = 256;
74 uint8_t legend_colour;
75 uint8_t rating_colour;
80 uint8_t transit_periods[2];
99 Money current_payment;
142 inline uint64_t WeightOfNUnits(uint32_t n)
const
144 return n * this->weight / 16u;
147 uint64_t WeightOfNUnitsInTrain(uint32_t n)
const;
156 typedef size_t difference_type;
157 typedef std::forward_iterator_tag iterator_category;
159 explicit Iterator(
size_t index) : index(index)
161 this->ValidateIndex();
164 bool operator==(
const Iterator &other)
const {
return this->index == other.index; }
165 bool operator!=(
const Iterator &other)
const {
return !(*
this == other); }
167 Iterator & operator++() { this->index++; this->ValidateIndex();
return *
this; }
182 bool empty() {
return this->begin() == this->end(); }
197 static inline std::map<CargoLabel, CargoID>
label_map{};
217 return INVALID_CARGO;
CargoLabel label
Unique label of the cargo type.
@ CC_LIQUID
Liquids (Oil, Water, Rubber)
@ CC_PASSENGERS
Passengers.
Dimensions (a width and height) of a rectangle in 2D.
Iterator to iterate all valid CargoSpec.
@ CC_PIECE_GOODS
Piece goods (Livestock, Wood, Steel, Paper)
CargoTypes _cargo_mask
Bitmask of cargo types available.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Tindex index
Index of this pool item.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
void InitializeSortedCargoSpecs()
Initialize the list of sorted cargo specifications.
static std::map< CargoLabel, CargoID > label_map
Translation map from CargoLabel to Cargo ID.
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
Specification of a cargo type.
SpriteID GetCargoIcon() const
Get sprite for showing cargo of this type.
static size_t GetArraySize()
Total number of cargospecs, both valid and invalid.
@ TPE_MAIL
Cargo behaves mail-like for production.
int32_t initial_payment
Initial payment rate before inflation is applied.
@ TAE_MAIL
Cargo behaves mail-like.
static CargoSpec array[NUM_CARGO]
Array holding all CargoSpecs.
@ CC_EXPRESS
Express cargo (Goods, Food, Candy, but also possible for passengers)
@ CC_SPECIAL
Special bit used for livery refit tricks instead of normal cargoes.
CargoID Index() const
Determines index of this cargospec.
CargoClasses classes
Classes of this cargo type.
Iterable ensemble of each set bit in a value.
uint8_t weight
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
StringID units_volume
Name of a single unit of cargo of this type.
bool IsValid() const
Tests for validity of this cargospec.
friend void SetupCargoForClimate(LandscapeID l)
Set up the default cargo types for the given landscape type.
static std::array< std::vector< const CargoSpec * >, NUM_TPE > town_production_cargoes
List of cargo specs for each Town Product Effect.
@ TPE_PASSENGERS
Cargo behaves passenger-like for production.
@ CC_REFRIGERATED
Refrigerated cargo (Food, Fruit)
@ CC_NOAVAILABLE
No cargo class has been specified.
const struct GRFFile * grffile
NewGRF where #group belongs to.
Dimension GetLargestCargoIconSize()
Get dimensions of largest cargo icon.
friend void FinaliseCargoArray()
Check for invalid cargoes.
SpriteID sprite
Icon to display this cargo type, may be 0xFFF (which means to resolve an action123 chain).
#define lengthof(array)
Return the length of an fixed size array.
@ TPE_NONE
Town will not produce this cargo type.
uint8_t callback_mask
Bitmask of cargo callbacks that have to be called.
@ TAE_END
End of town effects.
friend void BuildCargoLabelMap()
Build cargo label map.
@ INVALID_TPE
Invalid town production effect.
bool is_freight
Cargo type is considered to be freight (affects train freight multiplier).
@ TAE_PASSENGERS
Cargo behaves passenger-like.
uint8_t bitnum
Cargo bit number, is INVALID_CARGO_BITNUM for a non-used spec.
uint8_t LandscapeID
Landscape type.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ NUM_TAE
Amount of town effects.
static const uint8_t INVALID_CARGO_BITNUM
Constant representing invalid cargo.
void BuildCargoLabelMap()
Build cargo label map.
TownAcceptanceEffect
Town growth effect when delivering cargo.
@ TAE_NONE
Cargo has no effect.
TownProductionEffect town_production_effect
The effect on town cargo production.
uint16_t CargoClasses
Bitmask of cargo classes.
StringID quantifier
Text for multiple units of cargo of this type.
std::span< const CargoSpec * > _sorted_standard_cargo_specs
Standard cargo specifications sorted alphabetically by name.
TownProductionEffect
Town effect when producing cargo.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
StringID name
Name of this type of cargo.
StringID name_single
Name of a single entity of this type of cargo.
@ CC_BULK
Bulk cargo (Coal, Grain etc., Ores, Fruit)
StringID abbrev
Two letter abbreviation for this cargo type.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
CargoID GetCargoIDByBitnum(uint8_t bitnum)
Find the CargoID of a 'bitnum' value.
bool IsDefaultCargo(CargoID cid)
Test if a cargo is a default cargo type.
void SetupCargoForClimate(LandscapeID l)
Set up the default cargo types for the given landscape type.
Comparator to sort CargoID by according to desired order.
@ TAE_WATER
Cargo behaves water-like.
std::array< uint8_t, NUM_CARGO > _sorted_cargo_types
Sort order of cargoes by cargo ID.
@ CC_HAZARDOUS
Hazardous cargo (Nuclear Fuel, Explosives, etc.)
uint16_t town_production_multiplier
Town production multipler, if commanded by TownProductionEffect.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
@ CC_COVERED
Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.)
@ TAE_GOODS
Cargo behaves goods/candy-like.
@ CC_ARMOURED
Armoured cargo (Valuables, Gold, Diamonds)
uint16_t multiplier
Capacity multiplier for vehicles. (8 fractional bits)
Dynamic data of a loaded NewGRF.
@ TAE_FOOD
Cargo behaves food/fizzy-drinks-like.
CargoTypes _standard_cargo_mask
Bitmask of real cargo types available.
TownAcceptanceEffect town_acceptance_effect
The effect that delivering this cargo type has on towns. Also affects destination of subsidies.