MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / StartupEngines

Function StartupEngines

src/engine.cpp:798–823  ·  view source on GitHub ↗

* Start/initialise all our engines. Must be called whenever there are changes * to the NewGRF config. */

Source from the content-addressed store, hash-verified

796 * to the NewGRF config.
797 */
798void StartupEngines()
799{
800 /* Aging of vehicles stops, so account for that when starting late */
801 const TimerGameCalendar::Date aging_date = std::min(TimerGameCalendar::date, TimerGameCalendar::ConvertYMDToDate(_year_engine_aging_stops, 0, 1));
802 TimerGameCalendar::YearMonthDay aging_ymd = TimerGameCalendar::ConvertDateToYMD(aging_date);
803 uint32_t seed = Random();
804
805 for (Engine *e : Engine::Iterate()) {
806 StartupOneEngine(e, aging_ymd, seed);
807 }
808 for (Engine *e : Engine::Iterate()) {
809 CalcEngineReliability(e, false);
810 }
811
812 /* Update the bitmasks for the vehicle lists */
813 for (Company *c : Company::Iterate()) {
814 c->avail_railtypes = GetCompanyRailTypes(c->index);
815 c->avail_roadtypes = GetCompanyRoadTypes(c->index);
816 }
817
818 /* Invalidate any open purchase lists */
819 InvalidateWindowClassesData(WC_BUILD_VEHICLE);
820
821 SetWindowClassesDirty(WC_BUILD_VEHICLE);
822 SetWindowClassesDirty(WC_REPLACE_VEHICLE);
823}
824
825/**
826 * Allows engine \a eid to be used by a company \a company.

Callers 5

OnTimeoutMethod · 0.85
ConResetEnginesFunction · 0.85
_GenerateWorldFunction · 0.85
AfterLoadGameFunction · 0.85
ReloadNewGRFDataFunction · 0.85

Calls 7

StartupOneEngineFunction · 0.85
CalcEngineReliabilityFunction · 0.85
GetCompanyRailTypesFunction · 0.85
GetCompanyRoadTypesFunction · 0.85
SetWindowClassesDirtyFunction · 0.85
RandomFunction · 0.50

Tested by

no test coverage detected