summaryrefslogtreecommitdiff
path: root/src/newgrf_industries.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-07-11 16:32:19 +0000
committermichi_cc <michi_cc@openttd.org>2011-07-11 16:32:19 +0000
commit206ff68e65b1a679e96f5064e3595a183327ef6b (patch)
treeb8e692a54a0d9cf28150a6e2efb1a3c78ceff8b3 /src/newgrf_industries.cpp
parent1e855be4924d113d1e1eefd6345f174a86a9ef0b (diff)
downloadopenttd-206ff68e65b1a679e96f5064e3595a183327ef6b.tar.xz
(svn r22656) -Codechange: Deduplicate the custom error message of the industry shape and location callbacks.
Diffstat (limited to 'src/newgrf_industries.cpp')
-rw-r--r--src/newgrf_industries.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index fa4fdf197..71118b126 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -544,20 +544,9 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin
* the building of the industry, as that's how it's done in TTDP. */
if (group == NULL) return CommandCost();
uint16 result = group->GetCallbackResult();
- if (result == 0x400 || result == CALLBACK_FAILED) return CommandCost();
-
- CommandCost res;
- switch (result) {
- case 0x401: res = CommandCost(STR_ERROR_SITE_UNSUITABLE); 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;
- default: res = CommandCost(GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + result)); break;
- }
-
- /* Copy some parameters from the registers to the error message text ref. stack */
- res.UseTextRefStack(4);
+ if (result == CALLBACK_FAILED) return CommandCost();
- return res;
+ return GetErrorMessageFromLocationCallbackResult(result, indspec->grf_prop.grffile->grfid, STR_ERROR_SITE_UNSUITABLE);
}
/**