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_type.h | |
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_type.h')
-rw-r--r-- | src/command_type.h | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/command_type.h b/src/command_type.h index 179f3be2b..606bfc287 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -25,30 +25,33 @@ class CommandCost { Money cost; ///< The cost of this action StringID message; ///< Warning message for when success is unset bool success; ///< Whether the comment went fine up to this moment + uint textref_stack_size; ///< Number of uint32 values to put on the #TextRefStack for the error message. + + static uint32 textref_stack[16]; public: /** * Creates a command cost return with no cost and no error */ - CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true) {} + CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true), textref_stack_size(0) {} /** * Creates a command return value the is failed with the given message */ - explicit CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false) {} + explicit CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false), textref_stack_size(0) {} /** * Creates a command cost with given expense type and start cost of 0 * @param ex_t the expense type */ - explicit CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true) {} + explicit CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true), textref_stack_size(0) {} /** * Creates a command return value with the given start cost and expense type * @param ex_t the expense type * @param cst the initial cost of this command */ - CommandCost(ExpensesType ex_t, const Money &cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {} + CommandCost(ExpensesType ex_t, const Money &cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true), textref_stack_size(0) {} /** @@ -100,6 +103,26 @@ public: this->message = message; } + void UseTextRefStack(uint num_registers); + + /** + * Returns the number of uint32 values for the #TextRefStack of the error message. + * @return number of uint32 values. + */ + uint GetTextRefStackSize() const + { + return this->textref_stack_size; + } + + /** + * Returns a pointer to the values for the #TextRefStack of the error message. + * @return uint32 values for the #TextRefStack + */ + const uint32 *GetTextRefStack() const + { + return textref_stack; + } + /** * Returns the error message of a command * @return the error message, if succeeded #INVALID_STRING_ID |