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.
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 | 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

uint GetTotalCapacityOfArticulatedParts | ( | EngineID | engine | ) |

Get the capacity of an engine with articulated parts.

Parameters:

  | engine | The engine to get the capacity of.

Returns:
  The capacity.

Definition at line 141 of file engine_gui.cpp.

References GetCapacityOfArticulatedParts().

Referenced by RoadVehEngineCapacitySorter(), and TrainEngineCapacitySorter().

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

Check if an engine is buildable.

Parameters:

  | engine | index of the engine to check.
  | type | the type the engine should be.
  | company | index of the company.

Returns:
  True if an engine is valid, of the specified type, and buildable by the given company.

Definition at line 1045 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 | ) |

Check if an engine is refittable.

Note: Likely you want to use IsArticulatedVehicleRefittable().

Parameters:

  | engine | index of the engine to check.

Returns:
  true if the engine is refittable.

Definition at line 1081 of file engine.cpp.

References EngineInfo::callback_mask, Engine::CanCarryCargo(), CBM_VEHICLE_CARGO_SUFFIX, CT_INVALID, Engine::GetDefaultCargoType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), and HasBit().

Referenced by IsArticulatedVehicleRefittable(), and IsVehicleRefitable().

void SetYearEngineAgingStops | ( |  | ) |

Compute the value for _year_engine_aging_stops.

Definition at line 622 of file engine.cpp.

References _settings_game, _year_engine_aging_stops, EngineInfo::base_intro, EngineInfo::climates, ConvertDateToYMD(), DAYS_IN_LEAP_YEAR, GameSettings::game_creation, HasBit(), GameCreationSettings::landscape, EngineInfo::lifelength, max(), RAILVEH_WAGON, Engine::type, VEH_TRAIN, and YearMonthDay::year.

Referenced by AfterLoadGRFs().

void StartupEngines | ( |  | ) |

Start/initialise all our engines.

Must be called whenever there are changes to the NewGRF config.

Definition at line 692 of file engine.cpp.

References _date, _introduced_railtypes, _year_engine_aging_stops, CompanyProperties::avail_railtypes, Company::avail_roadtypes, CheckRailIntroduction(), ConvertYMDToDate(), GetCompanyRailtypes(), GetCompanyRoadtypes(), GetRailTypeInfo(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, RailtypeInfo::introduction_date, InvalidateWindowClassesData(), IsInsideMM(), RailtypeInfo::label, MAX_DAY, min(), RAILTYPE_BEGIN, SetBit(), StartupOneEngine(), and WC_BUILD_VEHICLE.

Referenced by _GenerateWorld(), AfterLoadGame(), DEF_CONSOLE_CMD(), SaveLoadWindow::OnTimeout(), and ReloadNewGRFData().

void StartupOneEngine | ( | Engine * | e,
|  | Date | aging_date |
| ) |  |  |

Start/initialise one engine.

Parameters:

  | e | The engine to initialise.
  | aging_date | The date used for age calculations.

Definition at line 648 of file engine.cpp.

References _date, _settings_game, EngineInfo::base_intro, EngineInfo::base_life, CalcEngineReliability(), EngineInfo::climates, Engine::company_avail, ConvertYMDToDate(), Engine::duration_phase_1, Engine::duration_phase_2, Engine::duration_phase_3, Engine::flags, GameSettings::game_creation, GB(), HasBit(), Engine::intro_date, GameCreationSettings::landscape, Engine::reliability_final, Engine::reliability_max, Engine::reliability_spd_dec, Engine::reliability_start, and GameCreationSettings::starting_year.

Referenced by FixTTOEngines(), and StartupEngines().