From 3506e96e258816e032d64cf1fc5a51c0b599a844 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Fri, 25 Jun 2021 01:23:12 +0200 Subject: [PATCH] Maniac: Support Variable Indirect, Switch (Maps to 0/1) and Switch Indirect for ValueOrVariable function Maniac Patch itself does not support this for all commands but supporting it for all is simpler and makes most sense. --- src/game_interpreter.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 443cd8aea8f..c8799b43907 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -1642,14 +1642,25 @@ bool Game_Interpreter::CommandChangeLevel(lcf::rpg::EventCommand const& com) { / } int Game_Interpreter::ValueOrVariable(int mode, int val) { - switch (mode) { - case 0: - return val; - case 1: - return Main_Data::game_variables->Get(val); - default: - return -1; - } + if (mode == 0) { + return val; + } else if (mode == 1) { + return Main_Data::game_variables->Get(val); + } else if (Player::IsPatchManiac()) { + // Maniac Patch does not implement all modes for all commands + // For simplicity it is enabled for all here + if (mode == 2) { + // Variable indirect + return Main_Data::game_variables->Get(Main_Data::game_variables->Get(val)); + } else if (mode == 3) { + // Switch (F = 0, T = 1) + return Main_Data::game_switches->Get(val) ? 1 : 0; + } else if (mode == 4) { + // Switch through Variable indirect + return Main_Data::game_switches->Get(Main_Data::game_variables->Get(val)) ? 1 : 0; + } + } + return -1; } bool Game_Interpreter::CommandChangeParameters(lcf::rpg::EventCommand const& com) { // Code 10430