diff options
author | frosch <frosch@openttd.org> | 2011-07-03 14:32:15 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-07-03 14:32:15 +0000 |
commit | 2a55273291191a25ff827321f9d5203e05f12c76 (patch) | |
tree | 9d3d49ae781ccb0f19f33f86d370da15e286e586 /src/newgrf_industries.cpp | |
parent | 2158f4f1bf9e8bafd8602b07652f24019ecde8c9 (diff) | |
download | openttd-2a55273291191a25ff827321f9d5203e05f12c76.tar.xz |
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
Diffstat (limited to 'src/newgrf_industries.cpp')
-rw-r--r-- | src/newgrf_industries.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 5cf9eb6ae..291d1a20f 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -549,18 +549,18 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin uint16 result = group->GetCallbackResult(); if (result == 0x400 || result == CALLBACK_FAILED) return CommandCost(); - /* Copy some parameters from the registers to the error message text ref. stack */ - SwitchToErrorRefStack(); - StartTextRefStackUsage(4); - SwitchToNormalRefStack(); - + CommandCost res; switch (result) { - case 0x401: return_cmd_error(STR_ERROR_SITE_UNSUITABLE); - case 0x402: return_cmd_error(STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST); - case 0x403: return_cmd_error(STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT); - default: return_cmd_error(GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + result)); + case 0x401: res = CommandCost(STR_ERROR_SITE_UNSUITABLE); + case 0x402: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST); + case 0x403: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT); + default: res = CommandCost(GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + result)); } - NOT_REACHED(); + + /* Copy some parameters from the registers to the error message text ref. stack */ + res.UseTextRefStack(4); + + return res; } /** |