summaryrefslogtreecommitdiff
path: root/src/newgrf_commons.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-08 17:24:43 +0000
committerfrosch <frosch@openttd.org>2011-11-08 17:24:43 +0000
commitd8f8909f859eb900ceaf8897537b2f46d970b308 (patch)
tree6a7c1eec6508195356926d1859b78305f959aafb /src/newgrf_commons.cpp
parentcd029465e1d6413453cb16224d5000fa9689fa79 (diff)
downloadopenttd-d8f8909f859eb900ceaf8897537b2f46d970b308.tar.xz
(svn r23142) -Change: [NewGRF v8] Unify the return values of callbacks returning D0xx texts.
Diffstat (limited to 'src/newgrf_commons.cpp')
-rw-r--r--src/newgrf_commons.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp
index 6d81676de..2f49c51c7 100644
--- a/src/newgrf_commons.cpp
+++ b/src/newgrf_commons.cpp
@@ -480,17 +480,24 @@ uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, uint32 grfid, StringID default_error)
{
CommandCost res;
- switch (cb_res) {
- case 0x400: return res; // No error.
- case 0x401: res = CommandCost(default_error); break;
- case 0x402: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST); break;
- case 0x403: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT); break;
- case 0x404: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_ABOVE_SNOW_LINE); break;
- case 0x405: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_BELOW_SNOW_LINE); break;
- case 0x406: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_SEA); break;
- case 0x407: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_CANAL); break;
- case 0x408: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_RIVER); break;
- default: res = CommandCost(GetGRFStringID(grfid, 0xD000 + cb_res)); break;
+
+ if (cb_res < 0x400) {
+ res = CommandCost(GetGRFStringID(grfid, 0xD000 + cb_res));
+ } else {
+ switch (cb_res) {
+ case 0x400: return res; // No error.
+
+ default: // unknown reason -> default error
+ case 0x401: res = CommandCost(default_error); break;
+
+ case 0x402: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST); break;
+ case 0x403: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT); break;
+ case 0x404: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_ABOVE_SNOW_LINE); break;
+ case 0x405: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_BELOW_SNOW_LINE); break;
+ case 0x406: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_SEA); break;
+ case 0x407: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_CANAL); break;
+ case 0x408: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_RIVER); break;
+ }
}
/* Copy some parameters from the registers to the error message text ref. stack */