From 7d4637613a856b9be5eff28fbe5ff5530ccac22c Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 31 Dec 2020 15:59:15 +0200 Subject: [PATCH] Format the integers into temporary buffer to fix inline sprites --- src/openrct2/localisation/Formatting.cpp | 26 ++++++------------------ 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/openrct2/localisation/Formatting.cpp b/src/openrct2/localisation/Formatting.cpp index 30a2e5e355..57d2e0073d 100644 --- a/src/openrct2/localisation/Formatting.cpp +++ b/src/openrct2/localisation/Formatting.cpp @@ -593,31 +593,17 @@ namespace OpenRCT2 } break; case FormatToken::String: - if constexpr (std::is_same()) - { - if (arg != nullptr) - { - ss << arg; - } - } - else if constexpr (std::is_same()) - { - ss << arg.c_str(); - } - else if constexpr (std::is_same()) - { - ss << arg.c_str(); - } + ss << arg; break; case FormatToken::Sprite: if constexpr (std::is_integral()) { auto idx = static_cast(arg); - ss << "{INLINE_SPRITE}"; - ss << "{" << ((idx >> 0) & 0xFF) << "}"; - ss << "{" << ((idx >> 8) & 0xFF) << "}"; - ss << "{" << ((idx >> 16) & 0xFF) << "}"; - ss << "{" << ((idx >> 24) & 0xFF) << "}"; + char inlineBuf[64]; + size_t len = snprintf( + inlineBuf, sizeof(inlineBuf), "{INLINE_SPRITE}{%u}{%u}{%u}{%u}", ((idx >> 0) & 0xFF), + ((idx >> 8) & 0xFF), ((idx >> 16) & 0xFF), ((idx >> 24) & 0xFF)); + ss.append(inlineBuf, len); } break; default: