88 memset(this->amount, 0,
sizeof(this->amount));
97 return this->amount[cargo];
106 return this->amount[cargo];
113 template <
typename T>
117 for (
size_t i = 0; i <
lengthof(this->amount); i++) {
118 ret += this->amount[i];
130 for (
size_t i = 0; i <
lengthof(this->amount); i++) {
131 if (this->amount[i] != 0) count++;
uint amount[NUM_CARGO]
Amount of each type of cargo.
Source/destination is a town.
Automatically choose cargo type when doing auto refitting.
byte GetCount() const
Get the amount of cargos that have an amount.
Type (helpers) for enums.
static const SourceID INVALID_SOURCE
Invalid/unknown index of source.
void Clear()
Reset all entries.
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
CargoTypes
Available types of cargo.
CargoArray()
Default constructor.
Source/destination are company headquarters.
#define lengthof(x)
Return the length of an fixed size array.
SourceType
Types of cargo source and destination.
Maximal number of cargo types in a game.
Class for storing amounts of cargo.
SimpleTinyEnumT< SourceType, byte > SourceTypeByte
The SourceType packed into a byte for savegame purposes.
Source/destination is an industry.
uint16 SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
const uint & operator[](CargoID cargo) const
Read-only access to an amount of a specific cargo type.
byte CargoID
Cargo slots to indicate a cargo type within a game.
uint & operator[](CargoID cargo)
Read/write access to an amount of a specific cargo type.
const T GetSum() const
Get the sum of all cargo amounts.