Engine Struct Reference

Inheritance diagram for Engine:
Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >

Public Member Functions

 Engine (VehicleType type, EngineID base)
bool IsEnabled () const
 Checks whether the engine spec is properly initialised.
CargoID GetDefaultCargoType () const
 Determines the default cargo type of an engine.
bool CanCarryCargo () const
 Determines whether an engine can carry something.
uint GetDisplayDefaultCapacity (uint16 *mail_capacity=NULL) const
 Determines the default cargo capacity of an engine for display purposes.
Money GetRunningCost () const
 Return how much the running costs of this engine are.
Money GetCost () const
 Return how much a new engine costs.
uint GetDisplayMaxSpeed () const
 Returns max speed of the engine for display purposes.
uint GetPower () const
 Returns the power of the engine for display and sorting purposes.
uint GetDisplayWeight () const
 Returns the weight of the engine for display purposes.
uint GetDisplayMaxTractiveEffort () const
 Returns the tractive effort of the engine for display purposes.
Date GetLifeLengthInDays () const
 Returns the vehicle's (not model's!) life length in days.
FORCEINLINE bool IsGroundVehicle () const
 Check if the engine is a ground vehicle.

Data Fields

char * name
 Custom name of engine.
Date intro_date
 Date of introduction of the engine.
Date age
uint16 reliability
 Current reliability of the engine.
uint16 reliability_spd_dec
 Speed of reliability decay between services (per day).
uint16 reliability_start
 Initial reliability of the engine.
uint16 reliability_max
 Maximal reliability of the engine.
uint16 reliability_final
 Final reliability of the engine.
uint16 duration_phase_1
 First reliability phase in months, increasing reliability from reliability_start to reliability_max.
uint16 duration_phase_2
 Second reliability phase in months, keeping reliability_max.
uint16 duration_phase_3
 Third reliability phase on months, decaying to reliability_final.
byte flags
 Flags of the engine.
uint8 preview_company_rank
 Rank of the company that is offered a preview. 0xFF means no company.
byte preview_wait
 Daily countdown timer for timeout of offering the engine to the preview_company_rank company.
CompanyMask company_avail
 Bit for each company whether the engine is available for that company.
uint8 original_image_index
 Original vehicle image index, thus the image index of the overridden vehicle.
VehicleType type
 Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
EngineInfo info
union {
   RailVehicleInfo   rail
   RoadVehicleInfo   road
   ShipVehicleInfo   ship
   AircraftVehicleInfo   air
u
GRFFilePropsBase< NUM_CARGO+2 > grf_prop
 Properties related the the grf file.
uint16 overrides_count
struct WagonOverrideoverrides
uint16 list_position

Detailed Description

Definition at line 25 of file engine_base.h.


Member Function Documentation

bool Engine::CanCarryCargo (  )  const

Determines whether an engine can carry something.

A vehicle cannot carry anything if its capacity is zero, or none of the possible cargos is available in the climate.

Returns:
true if the vehicle can carry something.

Definition at line 159 of file engine.cpp.

References CT_INVALID, GetDefaultCargoType(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by AddArticulatedParts(), RefitWindow::BuildRefitList(), CmdCloneVehicle(), GetBestFittingSubType(), GetDisplayDefaultCapacity(), GetVehicleCapacity(), GetVehicleDefaultCapacity(), IsEngineRefittable(), and RefitVehicle().

Money Engine::GetCost (  )  const
CargoID Engine::GetDefaultCargoType (  )  const [inline]

Determines the default cargo type of an engine.

Usually a valid cargo is returned, even though the vehicle has zero capacity, and can therefore not carry anything. But the cargotype is still used for livery selection etc..

Vehicles with CT_INVALID as default cargo are usally not available, but it can appear as default cargo of articulated parts.

Returns:
The default cargo type.
See also:
CanCarryCargo

Definition at line 81 of file engine_base.h.

Referenced by AddArticulatedParts(), CanCarryCargo(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdBuildVehicle(), CmdCloneVehicle(), GetDisplayDefaultCapacity(), GetVehicleCapacity(), GetVehicleDefaultCapacity(), and IsEngineRefittable().

uint Engine::GetDisplayDefaultCapacity ( uint16 *  mail_capacity = NULL  )  const

Determines the default cargo capacity of an engine for display purposes.

For planes carrying both passenger and mail this is the passenger capacity. For multiheaded engines this is the capacity of both heads. For articulated engines use GetCapacityOfArticulatedParts

Note:
Keep this function consistent with GetVehicleCapacity().
Parameters:
mail_capacity returns secondary cargo (mail) capacity of aircraft
Returns:
The default capacity
See also:
GetDefaultCargoType

Definition at line 196 of file engine.cpp.

References CanCarryCargo(), CC_PASSENGERS, GetDefaultCargoType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::index, IsCargoInClass(), PROP_AIRCRAFT_MAIL_CAPACITY, PROP_AIRCRAFT_PASSENGER_CAPACITY, PROP_ROADVEH_CARGO_CAPACITY, PROP_SHIP_CARGO_CAPACITY, PROP_TRAIN_CARGO_CAPACITY, RAILVEH_MULTIHEAD, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by AircraftEngineCargoSorter(), AIEventEnginePreview::GetCapacity(), AIEngine::GetCapacity(), GetVehicleDefaultCapacity(), and ShipEngineCapacitySorter().

uint Engine::GetDisplayMaxSpeed (  )  const
uint Engine::GetDisplayMaxTractiveEffort (  )  const

Returns the tractive effort of the engine for display purposes.

For dual-headed train-engines this is the tractive effort of both heads

Returns:
tractive effort in display units kN

Definition at line 379 of file engine.cpp.

References GetDisplayWeight(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::index, PROP_ROADVEH_TRACTIVE_EFFORT, PROP_TRAIN_TRACTIVE_EFFORT, VEH_ROAD, and VEH_TRAIN.

uint Engine::GetDisplayWeight (  )  const

Returns the weight of the engine for display purposes.

For dual-headed train-engines this is the weight of both heads

Returns:
weight in display units metric tons

Definition at line 361 of file engine.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::index, PROP_ROADVEH_WEIGHT, PROP_TRAIN_WEIGHT, RAILVEH_MULTIHEAD, VEH_ROAD, and VEH_TRAIN.

Referenced by GetDisplayMaxTractiveEffort().

Date Engine::GetLifeLengthInDays (  )  const

Returns the vehicle's (not model's!) life length in days.

Returns:
the life length

Definition at line 396 of file engine.cpp.

References _settings_game, DAYS_IN_LEAP_YEAR, VehicleSettings::extend_vehicle_life, EngineInfo::lifelength, and GameSettings::vehicle.

Referenced by CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRoadVehicle(), CmdBuildShip(), and DrawVehiclePurchaseInfo().

uint Engine::GetPower (  )  const

Returns the power of the engine for display and sorting purposes.

Only trains and road vehicles have power

Returns:
power in display units hp

Definition at line 343 of file engine.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::index, PROP_ROADVEH_POWER, PROP_TRAIN_POWER, VEH_ROAD, and VEH_TRAIN.

Referenced by EnginePowerVsRunningCostSorter().

Money Engine::GetRunningCost (  )  const
bool Engine::IsEnabled (  )  const

Checks whether the engine spec is properly initialised.

Returns:
true if enabled

Definition at line 149 of file engine.cpp.

References EngineInfo::string_id.

Referenced by FormatString(), IsEngineBuildable(), and AIEventEnginePreview::IsEngineValid().

FORCEINLINE bool Engine::IsGroundVehicle (  )  const [inline]

Check if the engine is a ground vehicle.

Returns:
True iff the engine is a train or a road vehicle.

Definition at line 100 of file engine_base.h.

References type, VEH_ROAD, and VEH_TRAIN.

Referenced by GetArticulatedRefitMasks(), GetCapacityOfArticulatedParts(), and IsArticulatedVehicleRefittable().


Field Documentation

Properties related the the grf file.

NUM_CARGO real cargo plus two pseudo cargo sprite groups. Used for obtaining the sprite offset of custom sprites, and for evaluating callbacks.

Definition at line 60 of file engine_base.h.

Referenced by CalculateRefitMasks(), FinaliseEngineArray(), GetCost(), Train::GetDisplayImageWidth(), GetNewEngine(), GetRefitCost(), Train::GetRunningCost(), Ship::GetRunningCost(), RoadVehicle::GetRunningCost(), GetRunningCost(), Aircraft::GetRunningCost(), GetVehicleSpriteGroup(), ListPositionOfEngine(), RailVehicleLengthChanged(), SetEngineGRF(), and ShowNewGrfVehicleError().


The documentation for this struct was generated from the following files:

Generated on Fri Jun 3 05:19:54 2011 for OpenTTD by  doxygen 1.6.1