# 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 ()
void | StartupEngines ()
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 | SetCachedEngineCounts ()
| Sets cached values in Company::num_vehicles and Group::num_vehicles.
void | SetYearEngineAgingStops ()
void | StartupOneEngine (Engine *e, Date aging_date)
uint | GetTotalCapacityOfArticulatedParts (EngineID engine)
## 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

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

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), GetRailTypeInfo(), HasBit(), EngineInfo::string_id, Engine::type, and VEH_TRAIN.

Referenced by CheckAutoreplaceValidity(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRoadVeh(), CmdBuildShip(), GetNewEngineType(), AIEngine::IsBuildable(), and AIEngine::IsValidEngine().

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 828 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, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), and HasBit().

Referenced by IsArticulatedVehicleRefittable(), and IsVehicleRefitable().