1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Merge pull request #12238 from frutiemax/Fix12223

Close #12223: Assert that Formatter::Add() only receives desired types
This commit is contained in:
Michael Steenbeek
2020-07-14 00:05:37 +02:00
committed by GitHub
2 changed files with 17 additions and 1 deletions

View File

@@ -996,7 +996,7 @@ static void window_title_editor_scrollpaint_commands(rct_window* w, rct_drawpixe
}
else
{
ft.Add<uint8_t*>(command->SpriteName);
ft.Add<utf8*>(command->SpriteName);
}
break;
case TITLE_SCRIPT_WAIT:

View File

@@ -131,6 +131,22 @@ public:
{
static_assert(sizeof(TSpecified) <= sizeof(uintptr_t), "Type too large");
static_assert(sizeof(TDeduced) <= sizeof(uintptr_t), "Type too large");
// clang-format off
static_assert(
std::is_same_v<TSpecified, char*> ||
std::is_same_v<TSpecified, const char*> ||
std::is_same_v<TSpecified, int16_t> ||
std::is_same_v<TSpecified, int32_t> ||
std::is_same_v<TSpecified, money32> ||
std::is_same_v<TSpecified, rct_string_id> ||
std::is_same_v<TSpecified, uint16_t> ||
std::is_same_v<TSpecified, uint32_t> ||
std::is_same_v<TSpecified, utf8*> ||
std::is_same_v<TSpecified, const utf8*>
);
// clang-format on
uintptr_t convertedValue;
if constexpr (std::is_integral_v<TSpecified>)
{