OpenTTD Source 20241224-master-gee860a5c8e
|
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. | |
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 647 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(), FixTTOEngines(), and StartupEngines().
void CheckEngines | ( | ) |
Check for engines that have an appropriate availability.
Definition at line 1321 of file engine.cpp.
References ENGINE_AVAILABLE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Iterate(), RAILVEH_WAGON, SetDParam(), ShowErrorMessage(), VEH_TRAIN, and WL_WARNING.
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(), and TrainEngineCapacitySorter().
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 1254 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 1295 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 SetupEngines | ( | ) |
Initialise the engine pool with the data from the original vehicles.
Definition at line 601 of file engine.cpp.
References _engine_counts, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::CleanPool(), CloseWindowByClass(), VEH_COMPANY_END, and WC_ENGINE_PREVIEW.
Referenced by ResetNewGRFData().
void SetYearEngineAgingStops | ( | ) |
Compute the value for _year_engine_aging_stops.
Definition at line 693 of file engine.cpp.
References _settings_game, _year_engine_aging_stops, EngineInfo::base_intro, EngineInfo::climates, TimerGameCalendar::ConvertDateToYMD(), TimerGameConst< struct Calendar >::DAYS_IN_LEAP_YEAR, GameSettings::game_creation, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Iterate(), GameCreationSettings::landscape, EngineInfo::lifelength, RAILVEH_WAGON, and VEH_TRAIN.
Referenced by AfterLoadGRFs().
void StartupEngines | ( | ) |
Start/initialise all our engines.
Must be called whenever there are changes to the NewGRF config.
Definition at line 799 of file engine.cpp.
References _year_engine_aging_stops, CalcEngineReliability(), TimerGameCalendar::ConvertDateToYMD(), TimerGameCalendar::ConvertYMDToDate(), TimerGameCalendar::date, GetCompanyRailTypes(), GetCompanyRoadTypes(), InvalidateWindowClassesData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Iterate(), SetWindowClassesDirty(), StartupOneEngine(), WC_BUILD_VEHICLE, and WC_REPLACE_VEHICLE.
Referenced by _GenerateWorld(), AfterLoadGame(), DEF_CONSOLE_CMD(), SaveLoadWindow::OnTimeout(), and ReloadNewGRFData().
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 718 of file engine.cpp.
References _settings_game, Engine::age, EngineInfo::base_intro, EngineInfo::base_life, EngineInfo::climates, Engine::company_avail, Engine::company_hidden, TimerGameCalendar::ConvertDateToYMD(), TimerGameCalendar::ConvertYMDToDate(), TimerGameCalendar::date, Engine::duration_phase_1, Engine::duration_phase_2, Engine::duration_phase_3, ENGINE_AVAILABLE, Engine::flags, GameSettings::game_creation, GB(), GameCreationSettings::generation_seed, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::GetGRFID(), HasBit(), HasFlag(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Engine::intro_date, INVALID_ENGINE, GameCreationSettings::landscape, EngineInfo::lifelength, MAX_UVALUE, Engine::reliability_final, Engine::reliability_max, Engine::reliability_spd_dec, Engine::reliability_start, RestoreRandomSeeds(), EngineInfo::retire_early, SaveRandomSeeds(), SetRandomSeed(), GameCreationSettings::starting_year, SyncReliability, Engine::type, and EngineInfo::variant_id.
Referenced by FixTTOEngines(), and StartupEngines().
|
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().
|
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().