summaryrefslogtreecommitdiff
path: root/src/vehicle.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-03-13 21:28:40 +0000
committerfrosch <frosch@openttd.org>2009-03-13 21:28:40 +0000
commitd86e821f539a4838ebe3fb00f8a2bf4dbeb150d6 (patch)
tree8317c89e21d332e45318d53d44851fe0a13c0a4a /src/vehicle.cpp
parent0bbb7dfd38aeebe8c22934e5e904a72362344a99 (diff)
downloadopenttd-d86e821f539a4838ebe3fb00f8a2bf4dbeb150d6.tar.xz
(svn r15701) -Fix [FS#2595]: Blame NewGRFs returning inconsistent information in purchase-list/after building before users have a chance to blame OpenTTD for incorrectly autorenewing/-replacing.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r--src/vehicle.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 0f62292b7..bdc6d0c6b 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -3,7 +3,9 @@
/** @file vehicle.cpp Base implementations of all vehicles. */
#include "stdafx.h"
+#include "gui.h"
#include "openttd.h"
+#include "debug.h"
#include "roadveh.h"
#include "ship.h"
#include "spritecache.h"
@@ -36,6 +38,7 @@
#include "core/smallmap_type.hpp"
#include "depot_func.h"
#include "settings_type.h"
+#include "network/network.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -101,6 +104,40 @@ bool Vehicle::NeedsAutomaticServicing() const
return NeedsServicing();
}
+/**
+ * Displays a "NewGrf Bug" error message for a engine, and pauses the game if not networking.
+ * @param engine The engine that caused the problem
+ * @param part1 Part 1 of the error message, taking the grfname as parameter 1
+ * @param part2 Part 2 of the error message, taking the engine as parameter 2
+ * @param bug_type Flag to check and set in grfconfig
+ * @param critical Shall the "OpenTTD might crash"-message be shown when the player tries to unpause?
+ */
+void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRFBugs bug_type, bool critical)
+{
+ const Engine *e = GetEngine(engine);
+ uint32 grfid = e->grffile->grfid;
+ GRFConfig *grfconfig = GetGRFConfig(grfid);
+
+ if (!HasBit(grfconfig->grf_bugs, bug_type)) {
+ SetBit(grfconfig->grf_bugs, bug_type);
+ SetDParamStr(0, grfconfig->name);
+ SetDParam(1, engine);
+ ShowErrorMessage(part2, part1, 0, 0);
+ if (!_networking) _pause_game = (critical ? -1 : 1);
+ }
+
+ /* debug output */
+ char buffer[512];
+
+ SetDParamStr(0, grfconfig->name);
+ GetString(buffer, part1, lastof(buffer));
+ DEBUG(grf, 0, "%s", buffer + 3);
+
+ SetDParam(1, engine);
+ GetString(buffer, part2, lastof(buffer));
+ DEBUG(grf, 0, "%s", buffer + 3);
+}
+
StringID VehicleInTheWayErrMsg(const Vehicle *v)
{
switch (v->type) {