78 typedef uint64 CargoTypes;
80 static const CargoTypes ALL_CARGOTYPES = (CargoTypes)UINT64_MAX;
97 memset(this->amount, 0,
sizeof(this->amount));
106 return this->amount[cargo];
115 return this->amount[cargo];
122 template <
typename T>
126 for (
size_t i = 0; i <
lengthof(this->amount); i++) {
127 ret += this->amount[i];
139 for (
size_t i = 0; i <
lengthof(this->amount); i++) {
140 if (this->amount[i] != 0) count++;
uint amount[NUM_CARGO]
Amount of each type of cargo.
Source/destination is a town.
byte GetCount() const
Get the amount of cargos that have an amount.
Maximal number of cargo types in a game.
bool IsCargoTypeValid(CargoType t)
Test whether cargo type is not CT_INVALID.
Automatically choose cargo type when doing auto refitting.
bool IsCargoIDValid(CargoID t)
Test whether cargo type is not CT_INVALID.
Type (helpers) for enums.
static const SourceID INVALID_SOURCE
Invalid/unknown index of source.
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
void Clear()
Reset all entries.
CargoType
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.
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.