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/command.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/command.cpp')
-rw-r--r-- | src/command.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/command.cpp b/src/command.cpp index 61e570da9..b291ce797 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -530,7 +530,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac /* Only show the error when it's for us. */ StringID error_part1 = GB(cmd, 16, 16); if (estimate_only || (IsLocalCompany() && error_part1 != 0 && my_cmd)) { - ShowErrorMessage(error_part1, res.GetErrorMessage(), WL_INFO, x, y); + ShowErrorMessage(error_part1, res.GetErrorMessage(), WL_INFO, x, y, res.GetTextRefStackSize(), res.GetTextRefStack()); } } else if (estimate_only) { ShowEstimatedCostOrIncome(res.GetCost(), x, y); @@ -735,3 +735,25 @@ void CommandCost::AddCost(const CommandCost &ret) this->success = false; } } + +/** + * Values to put on the #TextRefStack for the error message. + * There is only one static instance of the array, just like there is only one + * instance of normal DParams. + */ +uint32 CommandCost::textref_stack[16]; + +/** + * Activate usage of the NewGRF #TextRefStack for the error message. + * @param number of entries to copy from the temporary NewGRF registers + */ +void CommandCost::UseTextRefStack(uint num_registers) +{ + extern TemporaryStorageArray<int32, 0x110> _temp_store; + + assert(num_registers < lengthof(textref_stack)); + this->textref_stack_size = num_registers; + for (uint i = 0; i < num_registers; i++) { + textref_stack[i] = _temp_store.GetValue(0x100 + i); + } +} |