OpenTTD Source
20241121-master-g67a0fccfad
|
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. More... | |
void | CheckEngines () |
Check for engines that have an appropriate availability. | |
bool | IsEngineBuildable (EngineID engine, VehicleType type, CompanyID company) |
Check if an engine is buildable. More... | |
bool | IsEngineRefittable (EngineID engine) |
Check if an engine is refittable. More... | |
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. More... | |
void | StartupOneEngine (Engine *e, const TimerGameCalendar::YearMonthDay &aging_ymd, uint32_t seed) |
Start/initialise one engine. More... | |
uint | GetTotalCapacityOfArticulatedParts (EngineID engine) |
Get the capacity of an engine with articulated parts. More... | |
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. | |
Functions related to engines.
Definition in file engine_func.h.
void CalcEngineReliability | ( | Engine * | e, |
bool | new_month | ||
) |
Update Engine::reliability and (if needed) update the engine GUIs.
e | Engine to update. |
Definition at line 611 of file engine.cpp.
References _settings_game, AddRemoveEngineFromAutoreplaceAndBuildWindows(), Engine::age, EngineInfo::base_life, ClearLastVariant(), Engine::company_avail, Engine::duration_phase_1, Engine::duration_phase_2, Engine::duration_phase_3, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), HasFlag(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_ENGINE, VehicleSettings::never_expire_vehicles, Engine::reliability, Engine::reliability_final, Engine::reliability_max, Engine::reliability_start, EngineInfo::retire_early, SyncReliability, Engine::type, EngineInfo::variant_id, and GameSettings::vehicle.
Referenced by CalendarEnginesMonthlyLoop().
uint GetTotalCapacityOfArticulatedParts | ( | EngineID | engine | ) |
Get the capacity of an engine with articulated parts.
engine | The engine to get the capacity of. |
Definition at line 165 of file engine_gui.cpp.
References GetCapacityOfArticulatedParts(), and CargoArray::GetSum().
Referenced by RoadVehEngineCapacitySorter().
bool IsEngineBuildable | ( | EngineID | engine, |
VehicleType | type, | ||
CompanyID | company | ||
) |
Check if an engine is buildable.
engine | index of the engine to check. |
type | the type the engine should be. |
company | index of the company. |
Definition at line 1218 of file engine.cpp.
References Company::avail_railtypes, Company::avail_roadtypes, 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(), GetRoadTypeInfo(), HasBit(), Engine::IsEnabled(), OWNER_DEITY, RoadTypeInfo::powered_roadtypes, RailVehicleInfo::railtype, RoadVehicleInfo::roadtype, ROADTYPES_NONE, Engine::type, VEH_ROAD, and VEH_TRAIN.
Referenced by CheckAutoreplaceValidity(), CmdBuildVehicle(), CmdSetVehicleVisibility(), and GetNewEngineType().
bool IsEngineRefittable | ( | EngineID | engine | ) |
Check if an engine is refittable.
Note: Likely you want to use IsArticulatedVehicleRefittable().
engine | index of the engine to check. |
Definition at line 1259 of file engine.cpp.
References EngineInfo::callback_mask, Engine::CanCarryCargo(), CBM_VEHICLE_CARGO_SUFFIX, Engine::GetDefaultCargoType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), HasBit(), IsValidCargoID(), and SetBit().
Referenced by IsArticulatedVehicleRefittable(), IsVehicleRefitable(), and OrdersWindow::UpdateAutoRefitState().
void StartupEngines | ( | ) |
Start/initialise all our engines.
Must be called whenever there are changes to the NewGRF config.
Definition at line 763 of file engine.cpp.
References _year_engine_aging_stops, TimerGameCalendar::ConvertDateToYMD(), TimerGameCalendar::ConvertYMDToDate(), and TimerGameCalendar::date.
Referenced by DEF_CONSOLE_CMD().
void StartupOneEngine | ( | Engine * | e, |
const TimerGameCalendar::YearMonthDay & | aging_ymd, | ||
uint32_t | seed | ||
) |
Start/initialise one engine.
e | The engine to initialise. |
aging_date | The date used for age calculations. |
seed | Random seed. |
Definition at line 682 of file engine.cpp.
References _settings_game, Engine::age, EngineInfo::base_intro, Engine::company_avail, Engine::company_hidden, Engine::flags, GameSettings::game_creation, GameCreationSettings::generation_seed, Engine::GetGRFID(), SaveRandomSeeds(), SetRandomSeed(), and Engine::type.