* Check for engines that have an appropriate availability. */
| 1311 | * Check for engines that have an appropriate availability. |
| 1312 | */ |
| 1313 | void 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 | } |
no test coverage detected