1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-22 23:33:04 +01:00

Format the integers into temporary buffer to fix inline sprites

This commit is contained in:
Matt
2020-12-31 15:59:15 +02:00
parent c2fd7708ad
commit 7d4637613a

View File

@@ -593,31 +593,17 @@ namespace OpenRCT2
}
break;
case FormatToken::String:
if constexpr (std::is_same<T, const char*>())
{
if (arg != nullptr)
{
ss << arg;
}
}
else if constexpr (std::is_same<T, const std::string&>())
{
ss << arg.c_str();
}
else if constexpr (std::is_same<T, std::string>())
{
ss << arg.c_str();
}
ss << arg;
break;
case FormatToken::Sprite:
if constexpr (std::is_integral<T>())
{
auto idx = static_cast<uint32_t>(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: