OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
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++;
CargoType
Available types of cargo.
const T GetSum() const
Get the sum of all cargo amounts.
uint amount[NUM_CARGO]
Amount of each type of cargo.
Class for storing amounts of cargo.
byte GetCount() const
Get the amount of cargos that have an amount.
@ ST_TOWN
Source/destination is a town.
void Clear()
Reset all entries.
CargoArray()
Default constructor.
uint16 SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
bool IsCargoIDValid(CargoID t)
Test whether cargo type is not CT_INVALID.
@ ST_INDUSTRY
Source/destination is an industry.
@ ST_HEADQUARTERS
Source/destination are company headquarters.
SourceType
Types of cargo source and destination.
@ CT_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
@ NUM_CARGO
Maximal number of cargo types in a game.
static const SourceID INVALID_SOURCE
Invalid/unknown index of source.
#define lengthof(x)
Return the length of an fixed size array.
byte CargoID
Cargo slots to indicate a cargo type within a game.
const uint & operator[](CargoID cargo) const
Read-only access to an amount of a specific cargo type.
uint & operator[](CargoID cargo)
Read/write access to an amount of a specific cargo type.
@ CT_INVALID
Invalid cargo type.
@ CT_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
bool IsCargoTypeValid(CargoType t)
Test whether cargo type is not CT_INVALID.