Class that handles all engine related functions. More...
#include <ai_engine.hpp>
Static Public Member Functions | |
static const char * | GetClassName () |
Get the name of this class to identify it towards squirrel. | |
static bool | IsValidEngine (EngineID engine_id) |
Checks whether the given engine type is valid. | |
static bool | IsBuildable (EngineID engine_id) |
Checks whether the given engine type is buildable by you. | |
static char * | GetName (EngineID engine_id) |
Get the name of an engine. | |
static CargoID | GetCargoType (EngineID engine_id) |
Get the cargo-type of an engine. | |
static bool | CanRefitCargo (EngineID engine_id, CargoID cargo_id) |
Check if the cargo of an engine can be refitted to your requested. | |
static bool | CanPullCargo (EngineID engine_id, CargoID cargo_id) |
Check if the engine can pull a wagon with the given cargo. | |
static int32 | GetCapacity (EngineID engine_id) |
Get the capacity of an engine. | |
static int32 | GetReliability (EngineID engine_id) |
Get the reliability of an engine. | |
static int32 | GetMaxSpeed (EngineID engine_id) |
Get the maximum speed of an engine. | |
static Money | GetPrice (EngineID engine_id) |
Get the new cost of an engine. | |
static int32 | GetMaxAge (EngineID engine_id) |
Get the maximum age of a brand new engine. | |
static Money | GetRunningCost (EngineID engine_id) |
Get the running cost of an engine. | |
static int32 | GetPower (EngineID engine_id) |
Get the power of an engine. | |
static int32 | GetWeight (EngineID engine_id) |
Get the weight of an engine. | |
static int32 | GetMaxTractiveEffort (EngineID engine_id) |
Get the maximum tractive effort of an engine. | |
static int32 | GetDesignDate (EngineID engine_id) |
Get the date this engine was designed. | |
static AIVehicle::VehicleType | GetVehicleType (EngineID engine_id) |
Get the type of an engine. | |
static bool | IsWagon (EngineID engine_id) |
Check if an engine is a wagon. | |
static bool | CanRunOnRail (EngineID engine_id, AIRail::RailType track_rail_type) |
Check if a train vehicle can run on a RailType. | |
static bool | HasPowerOnRail (EngineID engine_id, AIRail::RailType track_rail_type) |
Check if a train engine has power on a RailType. | |
static AIRoad::RoadType | GetRoadType (EngineID engine_id) |
Get the RoadType of the engine. | |
static AIRail::RailType | GetRailType (EngineID engine_id) |
Get the RailType of the engine. | |
static bool | IsArticulated (EngineID engine_id) |
Check if the engine is articulated. | |
static AIAirport::PlaneType | GetPlaneType (EngineID engine_id) |
Get the PlaneType of the engine. |
Class that handles all engine related functions.
Definition at line 22 of file ai_engine.hpp.
Check if the engine can pull a wagon with the given cargo.
engine_id | The engine to check. | |
cargo_id | The cargo to check. |
Definition at line 75 of file ai_engine.cpp.
References AICargo::CC_PASSENGERS, GetVehicleType(), AICargo::HasCargoClass(), AICargo::IsValidCargo(), IsValidEngine(), and AIVehicle::VT_RAIL.
Check if the cargo of an engine can be refitted to your requested.
If the engine already allows this cargo, the function also returns true. In case of articulated vehicles the function decides whether at least one part can carry the cargo.
engine_id | The engine to check for refitting. | |
cargo_id | The cargo to check for refitting. |
Definition at line 67 of file ai_engine.cpp.
References GetUnionOfArticulatedRefitMasks(), HasBit(), AICargo::IsValidCargo(), and IsValidEngine().
bool AIEngine::CanRunOnRail | ( | EngineID | engine_id, | |
AIRail::RailType | track_rail_type | |||
) | [static] |
Check if a train vehicle can run on a RailType.
engine_id | The engine to check. | |
track_rail_type | The type you want to check. |
Definition at line 203 of file ai_engine.cpp.
References GetVehicleType(), IsCompatibleRail(), AIRail::IsRailTypeAvailable(), IsValidEngine(), and AIVehicle::VT_RAIL.
int32 AIEngine::GetCapacity | ( | EngineID | engine_id | ) | [static] |
Get the capacity of an engine.
In case it can transport multiple cargos, it returns the first/main.
engine_id | The engine to get the capacity of. |
Definition at line 85 of file ai_engine.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetCapacityOfArticulatedParts(), Engine::GetDisplayDefaultCapacity(), IsValidEngine(), NUM_CARGO, Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Get the cargo-type of an engine.
In case it can transport multiple cargos, it returns the first/main.
engine_id | The engine to get the cargo-type of. |
Definition at line 49 of file ai_engine.cpp.
References CT_INVALID, GetCapacityOfArticulatedParts(), IsValidEngine(), and NUM_CARGO.
static const char* AIEngine::GetClassName | ( | ) | [inline, static] |
Get the name of this class to identify it towards squirrel.
Definition at line 25 of file ai_engine.hpp.
int32 AIEngine::GetDesignDate | ( | EngineID | engine_id | ) | [static] |
Get the date this engine was designed.
engine_id | The engine to get the design date of. |
Definition at line 175 of file ai_engine.cpp.
References IsValidEngine().
int32 AIEngine::GetMaxAge | ( | EngineID | engine_id | ) | [static] |
Get the maximum age of a brand new engine.
engine_id | The engine to get the maximum age of. |
Definition at line 134 of file ai_engine.cpp.
References GetVehicleType(), IsValidEngine(), IsWagon(), and AIVehicle::VT_RAIL.
int32 AIEngine::GetMaxSpeed | ( | EngineID | engine_id | ) | [static] |
Get the maximum speed of an engine.
engine_id | The engine to get the maximum speed of. |
Definition at line 117 of file ai_engine.cpp.
References _settings_game, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::GetDisplayMaxSpeed(), IsValidEngine(), VehicleSettings::plane_speed, Engine::type, VEH_AIRCRAFT, and GameSettings::vehicle.
int32 AIEngine::GetMaxTractiveEffort | ( | EngineID | engine_id | ) | [static] |
Get the maximum tractive effort of an engine.
engine_id | The engine to get the maximum tractive effort of. |
Definition at line 166 of file ai_engine.cpp.
References GetVehicleType(), IsValidEngine(), IsWagon(), AIVehicle::VT_RAIL, and AIVehicle::VT_ROAD.
char * AIEngine::GetName | ( | EngineID | engine_id | ) | [static] |
Get the name of an engine.
engine_id | The engine to get the name of. |
Definition at line 37 of file ai_engine.cpp.
References IsValidEngine(), and SetDParam().
AIAirport::PlaneType AIEngine::GetPlaneType | ( | EngineID | engine_id | ) | [static] |
Get the PlaneType of the engine.
engine_id | The engine to get the PlaneType of. |
Definition at line 245 of file ai_engine.cpp.
References GetVehicleType(), IsValidEngine(), AIAirport::PT_INVALID, and AIVehicle::VT_AIR.
int32 AIEngine::GetPower | ( | EngineID | engine_id | ) | [static] |
Get the power of an engine.
engine_id | The engine to get the power of. |
Definition at line 149 of file ai_engine.cpp.
References GetVehicleType(), IsValidEngine(), IsWagon(), AIVehicle::VT_RAIL, and AIVehicle::VT_ROAD.
Get the new cost of an engine.
engine_id | The engine to get the new cost of. |
Definition at line 127 of file ai_engine.cpp.
References IsValidEngine().
AIRail::RailType AIEngine::GetRailType | ( | EngineID | engine_id | ) | [static] |
Get the RailType of the engine.
engine_id | The engine to get the RailType of. |
Definition at line 229 of file ai_engine.cpp.
References GetVehicleType(), IsValidEngine(), AIRail::RAILTYPE_INVALID, and AIVehicle::VT_RAIL.
int32 AIEngine::GetReliability | ( | EngineID | engine_id | ) | [static] |
Get the reliability of an engine.
The value is between 0 and 100, where 100 means 100% reliability (never breaks down) and 0 means 0% reliability (you most likely don't want to buy it).
engine_id | The engine to get the reliability of. |
Definition at line 109 of file ai_engine.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetVehicleType(), IsValidEngine(), IsWagon(), ToPercent16(), and AIVehicle::VT_RAIL.
AIRoad::RoadType AIEngine::GetRoadType | ( | EngineID | engine_id | ) | [static] |
Get the RoadType of the engine.
engine_id | The engine to get the RoadType of. |
Definition at line 221 of file ai_engine.cpp.
References EF_ROAD_TRAM, GetVehicleType(), HasBit(), IsValidEngine(), AIRoad::ROADTYPE_INVALID, AIRoad::ROADTYPE_ROAD, AIRoad::ROADTYPE_TRAM, and AIVehicle::VT_ROAD.
Get the running cost of an engine.
engine_id | The engine to get the running cost of. |
Definition at line 142 of file ai_engine.cpp.
References IsValidEngine().
AIVehicle::VehicleType AIEngine::GetVehicleType | ( | EngineID | engine_id | ) | [static] |
Get the type of an engine.
engine_id | The engine to get the type of. |
Definition at line 182 of file ai_engine.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), IsValidEngine(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, AIVehicle::VT_AIR, AIVehicle::VT_INVALID, AIVehicle::VT_RAIL, AIVehicle::VT_ROAD, and AIVehicle::VT_WATER.
Referenced by CanPullCargo(), CanRunOnRail(), GetMaxAge(), GetMaxTractiveEffort(), GetPlaneType(), GetPower(), GetRailType(), GetReliability(), GetRoadType(), GetWeight(), HasPowerOnRail(), IsArticulated(), and IsWagon().
int32 AIEngine::GetWeight | ( | EngineID | engine_id | ) | [static] |
Get the weight of an engine.
engine_id | The engine to get the weight of. |
Definition at line 158 of file ai_engine.cpp.
References GetVehicleType(), IsValidEngine(), AIVehicle::VT_RAIL, and AIVehicle::VT_ROAD.
bool AIEngine::HasPowerOnRail | ( | EngineID | engine_id, | |
AIRail::RailType | track_rail_type | |||
) | [static] |
Check if a train engine has power on a RailType.
engine_id | The engine to check. | |
track_rail_type | Another RailType. |
Definition at line 212 of file ai_engine.cpp.
References GetVehicleType(), AIRail::IsRailTypeAvailable(), IsValidEngine(), and AIVehicle::VT_RAIL.
bool AIEngine::IsArticulated | ( | EngineID | engine_id | ) | [static] |
Check if the engine is articulated.
engine_id | The engine to check. |
Definition at line 237 of file ai_engine.cpp.
References CountArticulatedParts(), GetVehicleType(), IsValidEngine(), AIVehicle::VT_RAIL, and AIVehicle::VT_ROAD.
bool AIEngine::IsBuildable | ( | EngineID | engine_id | ) | [static] |
Checks whether the given engine type is buildable by you.
engine_id | The engine to check. |
Definition at line 31 of file ai_engine.cpp.
References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), IsEngineBuildable(), and Engine::type.
Referenced by AIVehicle::BuildVehicle(), and AIGroup::SetAutoReplace().
bool AIEngine::IsValidEngine | ( | EngineID | engine_id | ) | [static] |
Checks whether the given engine type is valid.
An engine is valid if you have at least one vehicle of this engine or it's currently buildable.
engine_id | The engine to check. |
Definition at line 24 of file ai_engine.cpp.
References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), IsEngineBuildable(), and Engine::type.
Referenced by CanPullCargo(), CanRefitCargo(), CanRunOnRail(), GetCapacity(), GetCargoType(), GetDesignDate(), GetMaxAge(), GetMaxSpeed(), GetMaxTractiveEffort(), GetName(), GetPlaneType(), GetPower(), GetPrice(), GetRailType(), GetReliability(), GetRoadType(), GetRunningCost(), GetVehicleType(), GetWeight(), HasPowerOnRail(), IsArticulated(), and IsWagon().
bool AIEngine::IsWagon | ( | EngineID | engine_id | ) | [static] |
Check if an engine is a wagon.
engine_id | The engine to check. |
Definition at line 195 of file ai_engine.cpp.
References GetVehicleType(), IsValidEngine(), and AIVehicle::VT_RAIL.
Referenced by GetMaxAge(), GetMaxTractiveEffort(), GetPower(), and GetReliability().