OpenTTD Source 20260512-master-g20b387b91f
engine_func.h File Reference

Functions related to engines. More...

#include "engine_type.h"
#include "vehicle_type.h"
#include "company_type.h"
#include "timer/timer_game_calendar.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.
uint8_t GetOriginalEngineCount (VehicleType type)
 Get the number of original engines for a VehicleType.
uint8_t GetOriginalEngineOffset (VehicleType type)
 Get the index offset for original engines of a VehicleType.
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 SetYearEngineAgingStops ()
 Compute the value for _year_engine_aging_stops.
void CalcEngineReliability (Engine *e, bool new_month)
 Update Engine::reliability and (if needed) update the engine GUIs.
void StartupOneEngine (Engine *e, const TimerGameCalendar::YearMonthDay &aging_ymd, uint32_t seed)
 Start/initialise one engine.
uint GetTotalCapacityOfArticulatedParts (EngineID engine)
 Get the capacity of an engine with articulated parts.

Detailed Description

Functions related to engines.

Definition in file engine_func.h.

Function Documentation

◆ CalcEngineReliability()

◆ CheckEngines()

void CheckEngines ( )

Check for engines that have an appropriate availability.

Definition at line 1339 of file engine.cpp.

References Available, GetEncodedString(), RailVehicleInfo::railveh_type, ShowErrorMessage(), Train, Wagon, and WL_WARNING.

◆ GetOriginalEngineCount()

uint8_t GetOriginalEngineCount ( VehicleType type)

Get the number of original engines for a VehicleType.

Parameters
typethe vehicle type
Returns
the number of original engines of the given type

Number of engines of each vehicle type in original engine data

Definition at line 58 of file engine.cpp.

References IsCompanyBuildableVehicleType(), and lengthof.

Referenced by GetNewEngine(), ParamSet(), EngineOverrideManager::ResetToDefaultMapping(), and SetupEngines().

◆ GetOriginalEngineOffset()

uint8_t GetOriginalEngineOffset ( VehicleType type)

Get the index offset for original engines of a VehicleType.

Parameters
typethe vehicle type
Returns
the index offset for original engines of the given type

Offset of the first engine of each vehicle type in original engine data

Definition at line 77 of file engine.cpp.

References IsCompanyBuildableVehicleType(), and lengthof.

Referenced by ParamSet().

◆ GetTotalCapacityOfArticulatedParts()

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 300 of file engine_gui.cpp.

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

Referenced by DrawEngineList(), RoadVehEngineCapacitySorter(), and TrainEngineCapacitySorter().

◆ IsEngineBuildable()

◆ IsEngineRefittable()

bool IsEngineRefittable ( EngineID engine)

Check if an engine is refittable.

Note: Likely you want to use IsArticulatedVehicleRefittable().

Parameters
engineindex of the engine to check.
Returns
true if the engine is refittable.

Definition at line 1315 of file engine.cpp.

References EngineInfo::callback_mask, Engine::CanCarryCargo(), CargoSuffix, Engine::GetDefaultCargoType(), IsValidCargoType(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::None(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by IsArticulatedVehicleRefittable(), IsVehicleRefittable(), and OrdersWindow::UpdateAutoRefitState().

◆ SetupEngines()

void SetupEngines ( )

Initialise the engine pool with the data from the original vehicles.

Definition at line 627 of file engine.cpp.

References Begin, CloseWindowByClass(), CompanyEnd, GetOriginalEngineCount(), and WC_ENGINE_PREVIEW.

Referenced by ResetNewGRFData().

◆ SetYearEngineAgingStops()

◆ StartupEngines()

◆ StartupOneEngine()