OpenTTD Source 20260208-master-g43af8e94d0
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.
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.

Variables

const uint8_t _engine_counts [4]
 Number of engines of each vehicle type in original engine data.
const uint8_t _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

◆ CalcEngineReliability()

◆ CheckEngines()

void CheckEngines ( )

Check for engines that have an appropriate availability.

Definition at line 1318 of file engine.cpp.

References Available, GetEncodedString(), RAILVEH_WAGON, ShowErrorMessage(), VEH_TRAIN, and WL_WARNING.

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

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

Referenced by RoadVehEngineCapacitySorter(), and TrainEngineCapacitySorter().

◆ IsEngineBuildable()

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

◆ 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 1292 of file engine.cpp.

References EngineInfo::callback_mask, Engine::CanCarryCargo(), CargoSuffix, Engine::GetDefaultCargoType(), IsValidCargoType(), SetBit(), 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 604 of file engine.cpp.

References _engine_counts, CloseWindowByClass(), VEH_COMPANY_END, and WC_ENGINE_PREVIEW.

Referenced by ResetNewGRFData().

◆ SetYearEngineAgingStops()

◆ StartupEngines()

◆ StartupOneEngine()

Variable Documentation

◆ _engine_counts

const uint8_t _engine_counts[4]
extern

Number of engines of each vehicle type in original engine data.

Definition at line 54 of file engine.cpp.

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

◆ _engine_offsets

const uint8_t _engine_offsets[4]
extern

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

Definition at line 62 of file engine.cpp.

Referenced by ParamSet().