Class that handles all cargo related functions. More...
#include <script_cargo.hpp>
Public Types | |
enum | CargoClass { 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 } |
The classes of cargo (from newgrf_cargo.h). More... | |
enum | TownEffect { TE_NONE = 0, TE_PASSENGERS = 1, TE_MAIL = 2, TE_GOODS = 3, TE_WATER = 4, TE_FOOD = 5 } |
The effects a cargo can have on a town. More... | |
enum | SpecialCargoID { CT_AUTO_REFIT = 0xFD, CT_NO_REFIT = 0xFE } |
Special cargo types. More... | |
Static Public Member Functions | |
static bool | IsValidCargo (CargoID cargo_type) |
Checks whether the given cargo type is valid. | |
static bool | IsValidTownEffect (TownEffect towneffect_type) |
Checks whether the given town effect type is valid. | |
static char * | GetCargoLabel (CargoID cargo_type) |
Gets the string representation of the cargo label. | |
static bool | IsFreight (CargoID cargo_type) |
Checks whether the give cargo is a freight or not. | |
static bool | HasCargoClass (CargoID cargo_type, CargoClass cargo_class) |
Check if this cargo is in the requested cargo class. | |
static TownEffect | GetTownEffect (CargoID cargo_type) |
Get the effect this cargo has on a town. | |
static Money | GetCargoIncome (CargoID cargo_type, uint32 distance, uint32 days_in_transit) |
Get the income for transporting a piece of cargo over the given distance within the specified time. |
Class that handles all cargo related functions.
ai
Definition at line 21 of file script_cargo.hpp.
The classes of cargo (from newgrf_cargo.h).
Definition at line 26 of file script_cargo.hpp.
Special cargo types.
CT_AUTO_REFIT |
Automatically choose cargo type when doing auto-refitting. |
CT_NO_REFIT |
Do not refit cargo of a vehicle. |
Definition at line 54 of file script_cargo.hpp.
The effects a cargo can have on a town.
Definition at line 42 of file script_cargo.hpp.
Money ScriptCargo::GetCargoIncome | ( | CargoID | cargo_type, | |
uint32 | distance, | |||
uint32 | days_in_transit | |||
) | [static] |
Get the income for transporting a piece of cargo over the given distance within the specified time.
cargo_type | The cargo to transport. |
distance | The distance the cargo travels from begin to end. | |
days_in_transit | Amount of (game) days the cargo is in transit. The max value of this variable is 637. Any value higher returns the same as 637 would. |
Definition at line 63 of file script_cargo.cpp.
References Clamp(), and IsValidCargo().
char * ScriptCargo::GetCargoLabel | ( | CargoID | cargo_type | ) | [static] |
Gets the string representation of the cargo label.
cargo_type | The cargo to get the string representation of. |
Definition at line 28 of file script_cargo.cpp.
References GB(), CargoSpec::Get(), IsValidCargo(), and CargoSpec::label.
ScriptCargo::TownEffect ScriptCargo::GetTownEffect | ( | CargoID | cargo_type | ) | [static] |
Get the effect this cargo has on a town.
cargo_type | The cargo to check on. |
Definition at line 56 of file script_cargo.cpp.
References CargoSpec::Get(), and IsValidCargo().
bool ScriptCargo::HasCargoClass | ( | CargoID | cargo_type, | |
CargoClass | cargo_class | |||
) | [static] |
Check if this cargo is in the requested cargo class.
cargo_type | The cargo to check on. |
cargo_class | The class to check for. |
Definition at line 50 of file script_cargo.cpp.
References IsCargoInClass(), and IsValidCargo().
Referenced by ScriptEngine::CanPullCargo(), and ScriptRoad::GetRoadVehicleTypeForCargo().
bool ScriptCargo::IsFreight | ( | CargoID | cargo_type | ) | [static] |
Checks whether the give cargo is a freight or not.
This defines whether the "freight train weight multiplier" will apply to trains transporting this cargo.
cargo_type | The cargo to check on. |
Definition at line 43 of file script_cargo.cpp.
References CargoSpec::Get(), CargoSpec::is_freight, and IsValidCargo().
bool ScriptCargo::IsValidCargo | ( | CargoID | cargo_type | ) | [static] |
Checks whether the given cargo type is valid.
cargo_type | The cargo to check. |
Definition at line 18 of file script_cargo.cpp.
References CargoSpec::Get(), and NUM_CARGO.
Referenced by ScriptRail::BuildNewGRFRailStation(), ScriptEngine::CanPullCargo(), ScriptEngine::CanRefitCargo(), ScriptVehicle::GetCapacity(), ScriptTile::GetCargoAcceptance(), GetCargoIncome(), GetCargoLabel(), ScriptVehicle::GetCargoLoad(), ScriptTile::GetCargoProduction(), ScriptStation::GetCargoRating(), ScriptStation::GetCargoWaiting(), ScriptTown::GetLastMonthProduction(), ScriptIndustry::GetLastMonthProduction(), ScriptTown::GetLastMonthSupplied(), ScriptIndustry::GetLastMonthTransported(), ScriptTown::GetLastMonthTransportedPercentage(), ScriptIndustry::GetLastMonthTransportedPercentage(), ScriptVehicle::GetRefitCapacity(), ScriptIndustry::GetStockpiledCargo(), GetTownEffect(), HasCargoClass(), ScriptIndustry::IsCargoAccepted(), IsFreight(), ScriptVehicle::RefitVehicle(), and ScriptOrder::SetOrderRefit().
bool ScriptCargo::IsValidTownEffect | ( | TownEffect | towneffect_type | ) | [static] |
Checks whether the given town effect type is valid.
towneffect_type | The town effect to check. |
Definition at line 23 of file script_cargo.cpp.
References TE_END.
Referenced by ScriptTown::GetCargoGoal(), and ScriptTown::GetLastMonthReceived().