Skip to content

Commit

Permalink
Maniac Patch: Add flag "2" to disable the annoying/game-breaking vari…
Browse files Browse the repository at this point in the history
…able range adjustment.
  • Loading branch information
Ghabry committed May 9, 2024
1 parent 89b4537 commit 13a5006
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
8 changes: 7 additions & 1 deletion resources/unix/easyrpg-player.6.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion src/game_config_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game_config_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> 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 };
Expand Down
9 changes: 6 additions & 3 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,15 +880,15 @@ 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<Game_Variables::Var_t>::min();
} else {
min_var = Player::IsRPG2k3() ? Game_Variables::min_2k3 : Game_Variables::min_2k;
}
}
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<Game_Variables::Var_t>::max();
} else {
max_var = Player::IsRPG2k3() ? Game_Variables::max_2k3 : Game_Variables::max_2k;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
17 changes: 17 additions & 0 deletions tests/cmdline_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ TEST_CASE("ParseMulti") {
REQUIRE_EQ(li, 2);
}

TEST_CASE("Parse Optional Value") {
std::vector<std::string> 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<std::string> args;
CmdlineParser cp(args);
Expand Down

0 comments on commit 13a5006

Please sign in to comment.