From 65530a76f6502d9f9bfb9f7e650e9e869cb33908 Mon Sep 17 00:00:00 2001 From: Nicolas Chappe <74881848+nchappe@users.noreply.github.com> Date: Wed, 22 Dec 2021 13:21:19 +0100 Subject: [PATCH] Codechange: Allow use of SetDParam for tooltips --- src/misc_gui.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 7248efd6a6..1a3ba2b05c 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -672,7 +672,7 @@ struct TooltipsWindow : public Window { StringID string_id; ///< String to display as tooltip. byte paramcount; ///< Number of string parameters in #string_id. - uint64 params[5]; ///< The string parameters. + uint64 params[8]; ///< The string parameters. TooltipCloseCondition close_cond; ///< Condition for closing the window. TooltipsWindow(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window(&_tool_tips_desc) @@ -681,6 +681,10 @@ struct TooltipsWindow : public Window this->string_id = str; static_assert(sizeof(this->params[0]) == sizeof(params[0])); assert(paramcount <= lengthof(this->params)); + if (params == nullptr) { + _global_string_params.offset = 0; + params = _global_string_params.GetDataPointer(); + } if (paramcount > 0) memcpy(this->params, params, sizeof(this->params[0]) * paramcount); this->paramcount = paramcount; this->close_cond = close_tooltip;