summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index fa9b1dcff..b09332c0f 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -30,6 +30,7 @@
#include "company_base.h"
#include "vehicle_func.h"
#include "articulated_vehicles.h"
+#include "error.h"
#include "table/strings.h"
#include "table/engines.h"
@@ -1098,3 +1099,25 @@ bool IsEngineRefittable(EngineID engine)
CargoID default_cargo = e->GetDefaultCargoType();
return default_cargo != CT_INVALID && ei->refit_mask != 1U << default_cargo;
}
+
+/**
+ * Check for engines that have an appropriate availability.
+ */
+void CheckEngines()
+{
+ const Engine *e;
+ Date min_date = INT32_MAX;
+
+ FOR_ALL_ENGINES(e) {
+ if (!e->IsEnabled()) continue;
+
+ /* We have an available engine... yay! */
+ if (e->flags & ENGINE_AVAILABLE && e->company_avail != 0) return;
+
+ /* Okay, try to find the earliest date. */
+ min_date = min(min_date, e->info.base_intro);
+ }
+
+ SetDParam(0, min_date);
+ ShowErrorMessage(STR_ERROR_NO_VEHICLES_AVAILABLE, STR_ERROR_NO_VEHICLES_AVAILABLE_EXPLANATION, WL_WARNING);
+}