summaryrefslogtreecommitdiff
path: root/src/newgrf_commons.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-08 17:24:15 +0000
committerfrosch <frosch@openttd.org>2011-11-08 17:24:15 +0000
commit56e5144f716fb98ef8facde8b18631452188df6e (patch)
tree651bd5139bea2342485b09777cd6d27edb7cf252 /src/newgrf_commons.cpp
parentae11548b4ec2650348d818ae9f6bc19dd62caac2 (diff)
downloadopenttd-56e5144f716fb98ef8facde8b18631452188df6e.tar.xz
(svn r23140) -Add: ErrorUnknownCallbackResult()
Diffstat (limited to 'src/newgrf_commons.cpp')
-rw-r--r--src/newgrf_commons.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp
index 443a61e47..6d81676de 100644
--- a/src/newgrf_commons.cpp
+++ b/src/newgrf_commons.cpp
@@ -13,10 +13,12 @@
*/
#include "stdafx.h"
+#include "debug.h"
#include "landscape.h"
#include "house.h"
#include "industrytype.h"
#include "newgrf.h"
+#include "newgrf_config.h"
#include "clear_map.h"
#include "station_map.h"
#include "tree_map.h"
@@ -27,6 +29,8 @@
#include "newgrf_text.h"
#include "livery.h"
#include "company_base.h"
+#include "gui.h"
+#include "strings_func.h"
#include "table/strings.h"
@@ -495,6 +499,38 @@ CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, uint32 grfi
return res;
}
+/**
+ * Record that a NewGRF returned an unknown/invalid callback result.
+ * Also show an error to the user.
+ * @param grfid ID of the NewGRF causing the problem.
+ * @param cbid Callback causing the problem.
+ * @param cb_res Invalid result returned by the callback.
+ */
+void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
+{
+ GRFConfig *grfconfig = GetGRFConfig(grfid);
+
+ if (!HasBit(grfconfig->grf_bugs, GBUG_UNKNOWN_CB_RESULT)) {
+ SetBit(grfconfig->grf_bugs, GBUG_UNKNOWN_CB_RESULT);
+ SetDParamStr(0, grfconfig->GetName());
+ SetDParam(1, cbid);
+ SetDParam(2, cb_res);
+ ShowErrorMessage(STR_NEWGRF_BUGGY, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, WL_CRITICAL);
+ }
+
+ /* debug output */
+ char buffer[512];
+
+ SetDParamStr(0, grfconfig->GetName());
+ GetString(buffer, STR_NEWGRF_BUGGY, lastof(buffer));
+ DEBUG(grf, 0, "%s", buffer + 3);
+
+ SetDParam(1, cbid);
+ SetDParam(2, cb_res);
+ GetString(buffer, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, lastof(buffer));
+ DEBUG(grf, 0, "%s", buffer + 3);
+}
+
/* static */ SmallVector<DrawTileSeqStruct, 8> NewGRFSpriteLayout::result_seq;
/**