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

Function CheckEngines

src/engine.cpp:1313–1337  ·  view source on GitHub ↗

* Check for engines that have an appropriate availability. */

Source from the content-addressed store, hash-verified

1311 * Check for engines that have an appropriate availability.
1312 */
1313void CheckEngines()
1314{
1315 TimerGameCalendar::Date min_date{INT32_MAX};
1316
1317 for (const Engine *e : Engine::Iterate()) {
1318 if (!e->IsEnabled()) continue;
1319
1320 /* Don't consider train wagons, we need a powered engine available. */
1321 if (e->type == VEH_TRAIN && e->VehInfo<RailVehicleInfo>().railveh_type == RAILVEH_WAGON) continue;
1322
1323 /* We have an available engine... yay! */
1324 if (e->flags.Test(EngineFlag::Available) && e->company_avail.Any()) return;
1325
1326 /* Okay, try to find the earliest date. */
1327 min_date = std::min(min_date, e->info.base_intro);
1328 }
1329
1330 if (min_date < INT32_MAX) {
1331 ShowErrorMessage(GetEncodedString(STR_ERROR_NO_VEHICLES_AVAILABLE_YET),
1332 GetEncodedString(STR_ERROR_NO_VEHICLES_AVAILABLE_YET_EXPLANATION, min_date), WL_WARNING);
1333 } else {
1334 ShowErrorMessage(GetEncodedString(STR_ERROR_NO_VEHICLES_AVAILABLE_AT_ALL),
1335 GetEncodedString(STR_ERROR_NO_VEHICLES_AVAILABLE_AT_ALL_EXPLANATION), WL_WARNING);
1336 }
1337}

Callers 1

MakeNewGameDoneFunction · 0.85

Calls 5

ShowErrorMessageFunction · 0.85
TestMethod · 0.80
AnyMethod · 0.80
GetEncodedStringFunction · 0.70
IsEnabledMethod · 0.45

Tested by

no test coverage detected