From b987a848252cd77e5c62fee396b2b91b85727a3f Mon Sep 17 00:00:00 2001 From: florianessl Date: Tue, 11 Feb 2025 15:31:12 +0100 Subject: [PATCH] Amended missing tag "ManiacHook" to Debug::kExecutionType & added some static_asserts so it don't happen again --- src/filefinder.h | 6 ++++-- src/game_interpreter_shared.h | 11 ++++++++--- src/input_buttons.h | 12 ++++++------ src/rtp.h | 4 +++- src/window_gamelist.cpp | 2 +- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/filefinder.h b/src/filefinder.h index ec24d0f6a6..214f3065ef 100644 --- a/src/filefinder.h +++ b/src/filefinder.h @@ -50,7 +50,7 @@ namespace FileFinder { * Type of the project. Used to differentiate between supported games (2kX or EasyRPG) * and known but unsupported (i.e. newer RPG Makers). */ - enum ProjectType { + enum class ProjectType { Unknown, // 2kX or EasyRPG Supported, @@ -62,7 +62,8 @@ namespace FileFinder { WolfRpgEditor, Encrypted2k3Maniacs, RpgMaker95, - SimRpgMaker95 + SimRpgMaker95, + LAST }; constexpr auto kProjectType = lcf::makeEnumTags( @@ -77,6 +78,7 @@ namespace FileFinder { "RPG Maker 95", "Sim RPG Maker 95" ); + static_assert(kProjectType.size() == static_cast(ProjectType::LAST)); /** * Helper struct combining the project's directory and its type (used by Game Browser) diff --git a/src/game_interpreter_shared.h b/src/game_interpreter_shared.h index 943050cb55..d4eaa6f921 100644 --- a/src/game_interpreter_shared.h +++ b/src/game_interpreter_shared.h @@ -33,7 +33,8 @@ namespace Game_Interpreter_Shared { None = 0, MapEvent, CommonEvent, - BattleEvent + BattleEvent, + LAST }; static constexpr auto kEventType = lcf::makeEnumTags( "None", @@ -41,6 +42,7 @@ namespace Game_Interpreter_Shared { "CommonEvent", "BattleEvent" ); + static_assert(kEventType.size() == static_cast(EventType::LAST)); enum class ExecutionType { /* @@ -64,7 +66,8 @@ namespace Game_Interpreter_Shared { /* Event code was dynamically evaluated. (ManiacCallCommand) */ Eval, DebugCall, - ManiacHook + ManiacHook, + LAST }; static constexpr auto kExecutionType = lcf::makeEnumTags( "Action", @@ -79,8 +82,10 @@ namespace Game_Interpreter_Shared { "---", "DeathHandler", "Eval", - "DebugCall" + "DebugCall", + "ManiacHook" ); + static_assert(kExecutionType.size() == static_cast(ExecutionType::LAST)); /* * Indicates how the target of an interpreter operation (lvalue) should be evaluated. diff --git a/src/input_buttons.h b/src/input_buttons.h index e9dce4cb2d..6524062927 100644 --- a/src/input_buttons.h +++ b/src/input_buttons.h @@ -130,8 +130,8 @@ namespace Input { "FAST_FORWARD_A", "FAST_FORWARD_B", "TOGGLE_FULLSCREEN", - "TOGGLE_ZOOM", - "BUTTON_COUNT"); + "TOGGLE_ZOOM"); + static_assert(kInputButtonNames.size() == static_cast(BUTTON_COUNT)); constexpr auto kInputButtonHelp = lcf::makeEnumTags( "Up Direction", @@ -175,8 +175,8 @@ namespace Input { "Run the game at x{} speed", "Run the game at x{} speed", "Toggle Fullscreen mode", - "Toggle Window Zoom level", - "Total Button Count"); + "Toggle Window Zoom level"); + static_assert(kInputButtonHelp.size() == static_cast(BUTTON_COUNT)); /** * Return true if the given button is a system button. @@ -241,8 +241,8 @@ namespace Input { "RIGHT", "UPLEFT", "UP", - "UPRIGHT", - "NUM_DIRECTIONS"); + "UPRIGHT"); + static_assert(kInputDirectionNames.size() == static_cast(NUM_DIRECTIONS)); }; using ButtonMappingArray = FlatUniqueMultiMap; diff --git a/src/rtp.h b/src/rtp.h index b062025c48..d9122b27d8 100644 --- a/src/rtp.h +++ b/src/rtp.h @@ -50,7 +50,8 @@ namespace RTP { RPG2003_VladRussian, RPG2003_RpgUniverseSpanishPortuguese, RPG2003_Korean, - RPG2003_OfficialTraditionalChinese + RPG2003_OfficialTraditionalChinese, + LAST }; constexpr auto kTypes = lcf::makeEnumTags( @@ -66,6 +67,7 @@ namespace RTP { "Korean Translation", "Official Traditional Chinese" ); + static_assert(kTypes.size() == static_cast(Type::LAST)); struct RtpHitInfo { RTP::Type type; diff --git a/src/window_gamelist.cpp b/src/window_gamelist.cpp index 6fd0bb17d5..a7a19a8919 100644 --- a/src/window_gamelist.cpp +++ b/src/window_gamelist.cpp @@ -118,7 +118,7 @@ void Window_GameList::DrawItem(int index) { #ifndef USE_CUSTOM_FILEBUF auto color = Font::ColorDefault; - if (ge.type == FileFinder::Unknown) { + if (ge.type == FileFinder::ProjectType::Unknown) { color = Font::ColorHeal; } else if (ge.type > FileFinder::ProjectType::Supported) { color = Font::ColorKnockout;