summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-07-02 18:57:26 +0000
committerrubidium <rubidium@openttd.org>2013-07-02 18:57:26 +0000
commit1efc64fa7d4cbf4cfbc6d1ed3c7d6bd87e309a16 (patch)
tree8883bdeaaf80f410869733a6eb3b482e3d28ee11
parent79ddda1b104515871dfa87db9b8ab0bd51064e73 (diff)
downloadopenttd-1efc64fa7d4cbf4cfbc6d1ed3c7d6bd87e309a16.tar.xz
(svn r25553) -Fix [FS#5530]: provide a warning when no vehicles are available, and tell what to do in that case
-rw-r--r--src/engine.cpp23
-rw-r--r--src/engine_func.h1
-rw-r--r--src/lang/english.txt3
-rw-r--r--src/openttd.cpp1
4 files changed, 28 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);
+}
diff --git a/src/engine_func.h b/src/engine_func.h
index bb7e2fcac..faa8e8e02 100644
--- a/src/engine_func.h
+++ b/src/engine_func.h
@@ -18,6 +18,7 @@
void SetupEngines();
void StartupEngines();
+void CheckEngines();
/* Original engine data counts and offsets */
extern const uint8 _engine_counts[4];
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 686e705c9..85011e4e6 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -4316,6 +4316,9 @@ STR_ERROR_CAN_T_CHANGE_SERVICING :{WHITE}Can't ch
STR_ERROR_VEHICLE_IS_DESTROYED :{WHITE}... vehicle is destroyed
+STR_ERROR_NO_VEHICLES_AVAILABLE :{WHITE}No vehicles are available yet
+STR_ERROR_NO_VEHICLES_AVAILABLE_EXPLANATION :{WHITE}Start a new game after {DATE_SHORT} or use a NewGRF that provides early vehicles
+
# Specific vehicle errors
STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL :{WHITE}Can't make train pass signal at danger...
STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN :{WHITE}Can't reverse direction of train...
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 0c236a9d6..07124b84f 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -926,6 +926,7 @@ static void MakeNewGameDone()
if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
+ CheckEngines();
MarkWholeScreenDirty();
}