76 typedef uint64 CargoTypes;
78 static const CargoTypes ALL_CARGOTYPES = (CargoTypes)UINT64_MAX;
95 memset(this->amount, 0,
sizeof(this->amount));
104 return this->amount[cargo];
113 return this->amount[cargo];
120 template <
typename T>
124 for (
size_t i = 0; i <
lengthof(this->amount); i++) {
125 ret += this->amount[i];
137 for (
size_t i = 0; i <
lengthof(this->amount); i++) {
138 if (this->amount[i] != 0) count++;
SourceType
Types of cargo source and destination.
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.
Source/destination are company headquarters.
CargoType
Available types of cargo.
CargoArray()
Default constructor.
#define lengthof(x)
Return the length of an fixed size array.
Class for storing amounts of cargo.
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.
Source/destination is an industry.