diff --git a/resources/unix/easyrpg-player.6.adoc b/resources/unix/easyrpg-player.6.adoc index 6c25be6da7f..0a4081d08e7 100644 --- a/resources/unix/easyrpg-player.6.adoc +++ b/resources/unix/easyrpg-player.6.adoc @@ -95,8 +95,14 @@ NOTE: For games that only use ASCII (English games) use '1252'. *--patch-key-patch*:: Enable support for the Key Patch by Ineluki. -*--patch-maniac*:: +*--patch-maniac*:: _[N]_ Enable support for the Maniac Patch by BingShan. + Values for N: + - 1: Enable the patch (default) + - 2: Enable the patch but do not adjust variable ranges to 32 bit. + + Not adjusting the variable ranges is useful if you are adding the patch to an + existing game, as this reduces the likelihood that the game will stop working. *--patch-pic-unlock*:: Picture movement is not interrupted by messages in any version of the engine. diff --git a/src/game_config_game.cpp b/src/game_config_game.cpp index 1a5d3d54bd5..c297936e5fa 100644 --- a/src/game_config_game.cpp +++ b/src/game_config_game.cpp @@ -99,8 +99,13 @@ void Game_ConfigGame::LoadFromArgs(CmdlineParser& cp) { patch_override = true; continue; } - if (cp.ParseNext(arg, 0, {"--patch-maniac", "--no-patch-maniac"})) { + if (cp.ParseNext(arg, 1, {"--patch-maniac", "--no-patch-maniac"})) { patch_maniac.Set(arg.ArgIsOn()); + + if (arg.ArgIsOn() && arg.ParseValue(0, li_value)) { + patch_maniac.Set(li_value); + } + patch_override = true; continue; } diff --git a/src/game_config_game.h b/src/game_config_game.h index b7cd8cfe437..0106d67b287 100644 --- a/src/game_config_game.h +++ b/src/game_config_game.h @@ -40,7 +40,7 @@ struct Game_ConfigGame { BoolConfigParam fake_resolution{ "Fake Metrics", "Makes games run on higher resolutions (with some success)", "Game", "FakeResolution", false }; BoolConfigParam patch_easyrpg{ "EasyRPG", "EasyRPG Engine Extensions", "Patch", "EasyRPG", false }; BoolConfigParam patch_dynrpg{ "DynRPG", "", "Patch", "DynRPG", false }; - BoolConfigParam patch_maniac{ "Maniac Patch", "", "Patch", "Maniac", false }; + ConfigParam patch_maniac{ "Maniac Patch", "", "Patch", "Maniac", 0 }; BoolConfigParam patch_common_this_event{ "Common This Event", "Support \"This Event\" in Common Events", "Patch", "CommonThisEvent", false }; BoolConfigParam patch_unlock_pics{ "Unlock Pictures", "Allow picture commands while a message is shown", "Patch", "PicUnlock", false }; BoolConfigParam patch_key_patch{ "Ineluki Key Patch", "Support \"Ineluki Key Patch\"", "Patch", "KeyPatch", false }; diff --git a/src/player.cpp b/src/player.cpp index ea71ec5ed84..46e20d9de9e 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -880,7 +880,7 @@ void Player::ResetGameObjects() { auto min_var = lcf::Data::system.easyrpg_variable_min_value; if (min_var == 0) { - if (Player::IsPatchManiac()) { + if ((Player::game_config.patch_maniac.Get() & 1) == 1) { min_var = std::numeric_limits::min(); } else { min_var = Player::IsRPG2k3() ? Game_Variables::min_2k3 : Game_Variables::min_2k; @@ -888,7 +888,7 @@ void Player::ResetGameObjects() { } auto max_var = lcf::Data::system.easyrpg_variable_max_value; if (max_var == 0) { - if (Player::IsPatchManiac()) { + if ((Player::game_config.patch_maniac.Get() & 1) == 1) { max_var = std::numeric_limits::max(); } else { max_var = Player::IsRPG2k3() ? Game_Variables::max_2k3 : Game_Variables::max_2k; @@ -1402,7 +1402,10 @@ Engine options: --patch-dynrpg Enable support of DynRPG patch by Cherry (very limited). --patch-easyrpg Enable EasyRPG extensions. --patch-key-patch Enable Key Patch by Ineluki. - --patch-maniac Enable Maniac Patch by BingShan. + --patch-maniac [N] Enable Maniac Patch by BingShan. Values for N: + - 1: Enable the patch (default) + - 2: Enable the patch but do not adjust variable ranges + to 32 bit. --patch-pic-unlock Picture movement is not interrupted by messages in any version of the engine. --patch-rpg2k3-cmds Support all RPG Maker 2003 event commands in any version diff --git a/src/player.h b/src/player.h index 812cb5b00d7..bf220f91fcd 100644 --- a/src/player.h +++ b/src/player.h @@ -478,7 +478,7 @@ inline bool Player::IsPatchDynRpg() { } inline bool Player::IsPatchManiac() { - return game_config.patch_maniac.Get(); + return game_config.patch_maniac.Get() > 0; } inline bool Player::IsPatchKeyPatch() { diff --git a/tests/cmdline_parser.cpp b/tests/cmdline_parser.cpp index 2ce378cfa3f..faff3823b86 100644 --- a/tests/cmdline_parser.cpp +++ b/tests/cmdline_parser.cpp @@ -69,6 +69,23 @@ TEST_CASE("ParseMulti") { REQUIRE_EQ(li, 2); } +TEST_CASE("Parse Optional Value") { + std::vector args = { "testapp", "--arg1", "--arg2", "1", "--arg3", "a", "b" }; + + CmdlineParser cp(args); + + CmdlineArg arg; + + REQUIRE(cp.ParseNext(arg, 1, "--arg1")); + REQUIRE(arg.NumValues() == 0); + + REQUIRE(cp.ParseNext(arg, 2, "--arg2")); + REQUIRE(arg.NumValues() == 1); + + REQUIRE(cp.ParseNext(arg, 3, "--arg3")); + REQUIRE(arg.NumValues() == 2); +} + TEST_CASE("ParseNull") { std::vector args; CmdlineParser cp(args);