From a4f3ddae5fc33112f8c836c29dcbb7fc5933f3c4 Mon Sep 17 00:00:00 2001 From: frosch Date: Fri, 21 Mar 2025 18:13:08 +0100 Subject: [PATCH] Fix: [NewGRF] String parameter stack and case selection were not processed for control code 0x81. (#13851) --- src/newgrf_text.cpp | 10 +++++++--- src/strings.cpp | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index c13448d26e..d4a948d62e 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -840,6 +840,13 @@ static void ProcessNewGRFStringControlCode(char32_t scc, const char *&str, TextR params.emplace_back(stack.PopUnsignedWord()); break; + case SCC_NEWGRF_STRINL: { + StringID stringid = Utf8Consume(str); + /* We also need to handle the substring's stack usage. */ + HandleNewGRFStringControlCodes(GetStringPtr(stringid), stack, params); + break; + } + case SCC_NEWGRF_PRINT_WORD_STRING_ID: { StringID stringid = MapGRFStringID(stack.grffile->grfid, GRFStringID{stack.PopUnsignedWord()}); params.emplace_back(stringid); @@ -884,9 +891,6 @@ char32_t RemapNewGRFStringControlCode(char32_t scc, const char **str) case SCC_NEWGRF_PRINT_QWORD_CURRENCY: return SCC_CURRENCY_LONG; - case SCC_NEWGRF_PRINT_WORD_STRING_ID: - return SCC_NEWGRF_PRINT_WORD_STRING_ID; - case SCC_NEWGRF_PRINT_WORD_DATE_LONG: case SCC_NEWGRF_PRINT_DWORD_DATE_LONG: return SCC_DATE_LONG; diff --git a/src/strings.cpp b/src/strings.cpp index 84496630d0..397fca491c 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1133,6 +1133,8 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara } else { str_stack.push(ptr); } + case_index = next_substr_case_index; + next_substr_case_index = 0; break; }