Types/functions related to cargos. More...
#include "economy_type.h"
#include "cargo_type.h"
#include "gfx_type.h"
#include "strings_type.h"
#include "landscape_type.h"
Go to the source code of this file.
Data Structures | |
struct | CargoSpec |
Specification of a cargo type. More... | |
Defines | |
#define | FOR_ALL_CARGOSPECS_FROM(var, start) |
#define | FOR_ALL_CARGOSPECS(var) FOR_ALL_CARGOSPECS_FROM(var, 0) |
#define | FOR_EACH_SET_CARGO_ID(var, cargo_bits) FOR_EACH_SET_BIT_EX(CargoID, var, uint, cargo_bits) |
#define | FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; var = _sorted_cargo_specs[index], index < _sorted_cargo_specs_size; index++) |
#define | FOR_ALL_SORTED_STANDARD_CARGOSPECS(var) for (uint8 index = 0; var = _sorted_cargo_specs[index], index < _sorted_standard_cargo_specs_size; index++) |
Typedefs | |
typedef uint32 | CargoLabel |
Globally unique label of a cargo type. | |
Enumerations | |
enum | TownEffect { TE_NONE, TE_PASSENGERS, TE_MAIL, TE_GOODS, TE_WATER, TE_FOOD } |
Town growth effect when delivering cargo. More... | |
enum | CargoClass { CC_NOAVAILABLE = 0, CC_PASSENGERS = 1 << 0, CC_MAIL = 1 << 1, CC_EXPRESS = 1 << 2, CC_ARMOURED = 1 << 3, CC_BULK = 1 << 4, CC_PIECE_GOODS = 1 << 5, CC_LIQUID = 1 << 6, CC_REFRIGERATED = 1 << 7, CC_HAZARDOUS = 1 << 8, CC_COVERED = 1 << 9, CC_SPECIAL = 1 << 15 } |
Cargo classes. More... | |
Functions | |
void | SetupCargoForClimate (LandscapeID l) |
Set up the default cargo types for the given landscape type. | |
CargoID | GetCargoIDByLabel (CargoLabel cl) |
Get the cargo ID by cargo label. | |
CargoID | GetCargoIDByBitnum (uint8 bitnum) |
Find the CargoID of a 'bitnum' value. | |
void | InitializeSortedCargoSpecs () |
Initialize the list of sorted cargo specifications. | |
static bool | IsCargoInClass (CargoID c, CargoClass cc) |
Does cargo c have cargo class cc? | |
Variables | |
static const byte | INVALID_CARGO = 0xFF |
Constant representing invalid cargo. | |
uint32 | _cargo_mask |
Bitmask of cargo types available. | |
const CargoSpec * | _sorted_cargo_specs [NUM_CARGO] |
Cargo specifications sorted alphabetically by name. | |
uint8 | _sorted_cargo_specs_size |
Number of cargo specifications stored at the _sorted_cargo_specs array (including special cargos). | |
uint8 | _sorted_standard_cargo_specs_size |
Number of standard cargo specifications stored at the _sorted_cargo_specs array. |
Types/functions related to cargos.
Definition in file cargotype.h.
#define FOR_ALL_CARGOSPECS_FROM | ( | var, | |||
start | ) |
for (size_t cargospec_index = start; var = NULL, cargospec_index < CargoSpec::GetArraySize(); cargospec_index++) \ if ((var = CargoSpec::Get(cargospec_index))->IsValid())
Definition at line 150 of file cargotype.h.
typedef uint32 CargoLabel |
Globally unique label of a cargo type.
Definition at line 22 of file cargotype.h.
enum CargoClass |
Cargo classes.
Definition at line 35 of file cargotype.h.
enum TownEffect |
Town growth effect when delivering cargo.
Definition at line 25 of file cargotype.h.
CargoID GetCargoIDByBitnum | ( | uint8 | bitnum | ) |
Find the CargoID of a 'bitnum' value.
bitnum | 'bitnum' to find. |
Definition at line 94 of file cargotype.cpp.
References CargoSpec::bitnum, CT_INVALID, CargoSpec::Index(), and INVALID_CARGO.
CargoID GetCargoIDByLabel | ( | CargoLabel | cl | ) |
Get the cargo ID by cargo label.
cl | Cargo type to get. |
Definition at line 77 of file cargotype.cpp.
References CT_INVALID, CargoSpec::Index(), and CargoSpec::label.
Referenced by CalculateRefitMasks().
void InitializeSortedCargoSpecs | ( | ) |
Initialize the list of sorted cargo specifications.
Definition at line 162 of file cargotype.cpp.
References _sorted_cargo_specs_size, _sorted_standard_cargo_specs_size, CargoSpecClassSorter(), CC_SPECIAL, CargoSpec::classes, and QSortT().
Referenced by ReadLanguagePack().
static bool IsCargoInClass | ( | CargoID | c, | |
CargoClass | cc | |||
) | [inline, static] |
Does cargo c have cargo class cc?
c | Cargo type. | |
cc | Cargo class. |
Definition at line 145 of file cargotype.h.
References CargoSpec::Get().
Referenced by Vehicle::Crash(), DrawStationCoverageAreaText(), Engine::GetDisplayDefaultCapacity(), GetEngineLiveryScheme(), GetVehicleCapacity(), AICargo::HasCargoClass(), RoadVehicle::IsBus(), LoadUnloadVehicle(), and UpdateStationAcceptance().
void SetupCargoForClimate | ( | LandscapeID | l | ) |
Set up the default cargo types for the given landscape type.
l | Landscape |
Definition at line 36 of file cargotype.cpp.
References _cargo_mask, _default_cargo, _default_climate_cargo, CargoSpec::bitnum, CargoSpec::Get(), INVALID_CARGO, lengthof, and SetBit().
Referenced by ResetNewGRFData().
uint32 _cargo_mask |
Bitmask of cargo types available.
Initialized during a call to SetupCargoForClimate.
Definition at line 30 of file cargotype.cpp.
Referenced by CalculateRefitMasks(), CompanyStationsWindow::OnClick(), SetupCargoForClimate(), ShipVehicleChangeInfo(), and ShowRefitOptionsList().