OpenTTD
Functions | Variables
engine_func.h File Reference

Functions related to engines. More...

#include "engine_type.h"
#include "vehicle_type.h"
#include "company_type.h"

Go to the source code of this file.

Functions

void SetupEngines ()
 Initialise the engine pool with the data from the original vehicles.
void StartupEngines ()
 Start/initialise all our engines.
void CheckEngines ()
 Check for engines that have an appropriate availability.
bool IsEngineBuildable (EngineID engine, VehicleType type, CompanyID company)
 Check if an engine is buildable.
bool IsEngineRefittable (EngineID engine)
 Check if an engine is refittable.
void GetArticulatedVehicleCargoesAndRefits (EngineID engine, CargoArray *cargoes, uint32 *refits)
 Get the default cargoes and refits of an articulated vehicle.
void SetYearEngineAgingStops ()
 Compute the value for _year_engine_aging_stops.
void StartupOneEngine (Engine *e, Date aging_date)
 Start/initialise one engine.
uint GetTotalCapacityOfArticulatedParts (EngineID engine)
 Get the capacity of an engine with articulated parts.

Variables

const uint8 _engine_counts [4]
 Number of engines of each vehicle type in original engine data.
const uint8 _engine_offsets [4]
 Offset of the first engine of each vehicle type in original engine data.

Detailed Description

Functions related to engines.

Definition in file engine_func.h.

Function Documentation

void GetArticulatedVehicleCargoesAndRefits ( EngineID  engine,
CargoArray cargoes,
uint32 *  refits 
)

Get the default cargoes and refits of an articulated vehicle.

The refits are linked to a cargo rather than an articulated part to prevent a long list of parts.

Parameters
engineModel to investigate.
[out]cargoesTotal amount of units that can be transported, summed by cargo.
[out]refitsWhether a (possibly partial) refit for each cargo is possible.

Definition at line 172 of file articulated_vehicles.cpp.

References EngineInfo::callback_mask, CBM_VEHICLE_ARTIC_ENGINE, CargoArray::Clear(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetNextArticulatedPart(), GetVehicleDefaultCapacity(), HasBit(), INVALID_ENGINE, IsEngineRefittable(), Engine::IsGroundVehicle(), MAX_ARTICULATED_PARTS, and SetBit().

uint GetTotalCapacityOfArticulatedParts ( EngineID  engine)

Get the capacity of an engine with articulated parts.

Parameters
engineThe engine to get the capacity of.
Returns
The capacity.

Definition at line 163 of file engine_gui.cpp.

References GetCapacityOfArticulatedParts(), and CargoArray::GetSum().

Referenced by RoadVehEngineCapacitySorter(), and TrainEngineCapacitySorter().

bool IsEngineBuildable ( EngineID  engine,
VehicleType  type,
CompanyID  company 
)

Check if an engine is buildable.

Parameters
engineindex of the engine to check.
typethe type the engine should be.
companyindex of the company.
Returns
True if an engine is valid, of the specified type, and buildable by the given company.

Definition at line 1084 of file engine.cpp.

References CompanyProperties::avail_railtypes, Engine::company_avail, ENGINE_AVAILABLE, Engine::flags, 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(), GetRailTypeInfo(), HasBit(), Engine::IsEnabled(), OWNER_DEITY, Engine::type, and VEH_TRAIN.

Referenced by CheckAutoreplaceValidity(), CmdBuildVehicle(), and GetNewEngineType().

bool IsEngineRefittable ( EngineID  engine)
void SetYearEngineAgingStops ( )
void StartupEngines ( )
void StartupOneEngine ( Engine e,
Date  aging_date 
)