Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/game_config_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void Game_ConfigGame::LoadFromArgs(CmdlineParser& cp) {
patch_rpg2k3_commands.Lock(false);
patch_anti_lag_switch.Lock(0);
patch_direct_menu.Lock(0);
patch_powermode.Lock(0);

RuntimePatches::LockPatchesAsDiabled();
patch_override = true;
Expand Down Expand Up @@ -156,6 +157,11 @@ void Game_ConfigGame::LoadFromArgs(CmdlineParser& cp) {
}
continue;
}
if (cp.ParseNext(arg, 0, { "--patch-powermode", "--no-patch-powermode" })) {
patch_powermode.Set(arg.ArgIsOn());
patch_override = true;
continue;
}
if (RuntimePatches::ParseFromCommandLine(cp)) {
patch_override = true;
continue;
Expand Down Expand Up @@ -235,6 +241,10 @@ void Game_ConfigGame::LoadFromStream(Filesystem_Stream::InputStream& is) {
patch_override = true;
}

if (patch_powermode.FromIni(ini)) {
patch_override = true;
}

if (RuntimePatches::ParseFromIni(ini)) {
patch_override = true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/game_config_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ struct Game_ConfigGame {
ConfigParam<int> patch_guardrevamp_normal{ "GuardRevamp", "Changes damage calculation for defense situations (Normal)", "Patch", "GuardRevamp.NormalDefense", 0 };
ConfigParam<int> patch_guardrevamp_strong{ "GuardRevamp", "Changes damage calculation for defense situations (Strong)", "Patch", "GuardRevamp.StrongDefense", 0 };

ConfigParam<int> patch_powermode{ "Power Mode 2003", "", "Patch", "PowerMode2003", 0 };

// Command line only
BoolConfigParam patch_support{ "Support patches", "When OFF all patch support is disabled", "", "", true };

Expand Down
52 changes: 12 additions & 40 deletions src/game_ineluki.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "input.h"
#include "player.h"
#include "system.h"
#include "game_runtime_patches.h"

#include <lcf/inireader.h>

Expand Down Expand Up @@ -180,33 +181,35 @@ bool Game_Ineluki::Execute(std::string_view ini_file) {
}
std::string arg_lower = Utils::LowerCase(cmd.arg);
if (arg_lower == "left") {
mouse_decision_binding = MouseReturnMode::Left;
RuntimePatches::mouse_bindings.bind_decision = RuntimePatches::MouseButtonBindingMode::Left;
} else if (arg_lower == "right") {
mouse_decision_binding = MouseReturnMode::Right;
RuntimePatches::mouse_bindings.bind_decision = RuntimePatches::MouseButtonBindingMode::Right;
} else if (arg_lower == "both") {
mouse_decision_binding = MouseReturnMode::Both;
RuntimePatches::mouse_bindings.bind_decision = RuntimePatches::MouseButtonBindingMode::Both;
} else if (arg_lower == "none") {
mouse_decision_binding = MouseReturnMode::None;
RuntimePatches::mouse_bindings.bind_decision = RuntimePatches::MouseButtonBindingMode::None;
} else {
Output::Warning("Ineluki: Invalid value for setMouseAsReturn");
mouse_decision_binding = MouseReturnMode::None;
RuntimePatches::mouse_bindings.bind_decision = RuntimePatches::MouseButtonBindingMode::None;
}
RuntimePatches::mouse_bindings.enabled = true;
} else if (cmd.name == "setmousewheelaskeys") {
// This command is only found in a few uncommon versions of the patch
if (!mouse_support) {
return true;
}
std::string arg_lower = Utils::LowerCase(cmd.arg);
if (arg_lower == "updown") {
mouse_wheel_binding = MouseWheelMode::UpDown;
RuntimePatches::mouse_bindings.bind_wheel = RuntimePatches::MouseWheelMode::UpDown;
} else if (arg_lower == "leftright") {
mouse_wheel_binding = MouseWheelMode::LeftRight;
RuntimePatches::mouse_bindings.bind_wheel = RuntimePatches::MouseWheelMode::LeftRight;
} else if (arg_lower == "none") {
mouse_wheel_binding = MouseWheelMode::None;
RuntimePatches::mouse_bindings.bind_wheel = RuntimePatches::MouseWheelMode::None;
} else {
Output::Warning("Ineluki: Invalid value for setMouseWheelAsKeys");
mouse_wheel_binding = MouseWheelMode::None;
RuntimePatches::mouse_bindings.bind_wheel = RuntimePatches::MouseWheelMode::None;
}
RuntimePatches::mouse_bindings.enabled = true;
}
}

Expand Down Expand Up @@ -335,9 +338,6 @@ void Game_Ineluki::Update() {
if (key_support) {
UpdateKeys();
}
if (mouse_support) {
UpdateMouse();
}
}

void Game_Ineluki::UpdateKeys() {
Expand Down Expand Up @@ -375,34 +375,6 @@ void Game_Ineluki::UpdateKeys() {
}
}

void Game_Ineluki::UpdateMouse() {
#if defined(USE_MOUSE) && defined(SUPPORT_MOUSE)
if (Input::IsRawKeyTriggered(Input::Keys::MOUSE_LEFT)) {
if ((mouse_decision_binding == MouseReturnMode::Left || mouse_decision_binding == MouseReturnMode::Both)) {
Input::SimulateButtonPress(Input::DECISION);
}
} else if (Input::IsRawKeyTriggered(Input::Keys::MOUSE_RIGHT)) {
if ((mouse_decision_binding == MouseReturnMode::Right || mouse_decision_binding == MouseReturnMode::Both)) {
Input::SimulateButtonPress(Input::DECISION);
}
}

if (Input::IsRawKeyTriggered(Input::Keys::MOUSE_SCROLLUP)) {
if (mouse_wheel_binding == MouseWheelMode::UpDown) {
Input::SimulateButtonPress(Input::UP);
} else if (mouse_wheel_binding == MouseWheelMode::LeftRight) {
Input::SimulateButtonPress(Input::LEFT);
}
} else if (Input::IsRawKeyTriggered(Input::Keys::MOUSE_SCROLLDOWN)) {
if (mouse_wheel_binding == MouseWheelMode::UpDown) {
Input::SimulateButtonPress(Input::DOWN);
} else if (mouse_wheel_binding == MouseWheelMode::LeftRight) {
Input::SimulateButtonPress(Input::RIGHT);
}
}
#endif
}

void Game_Ineluki::OnScriptFileReady(FileRequestResult* result) {
auto it = std::find_if(async_scripts.begin(), async_scripts.end(), [&](const auto& a) {
return a.script_name == result->file;
Expand Down
21 changes: 0 additions & 21 deletions src/game_ineluki.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ class Game_Ineluki {
*/
void UpdateKeys();

/**
* Handles virtual key bindings for mouse buttons.
*/
void UpdateMouse();

/**
* Parses and caches the script.
*
Expand Down Expand Up @@ -134,22 +129,6 @@ class Game_Ineluki {
bool mouse_support = false;
int mouse_id_prefix = 0;

enum class MouseReturnMode {
None,
Left,
Right,
Both
};

enum class MouseWheelMode {
None,
UpDown,
LeftRight
};

MouseReturnMode mouse_decision_binding = MouseReturnMode::None;
MouseWheelMode mouse_wheel_binding = MouseWheelMode::None;

struct Mapping {
Input::Keys::InputKey key;
const char* name;
Expand Down
17 changes: 16 additions & 1 deletion src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,10 @@ void Game_Interpreter::Update(bool reset_loop_count) {
const int key = _keyinput.CheckInput();
Main_Data::game_variables->Set(_keyinput.variable, key);
Game_Map::SetNeedRefreshForVarChange(_keyinput.variable);
if (key == 0) {
RuntimePatches::OnVariableChanged(_keyinput.variable);
// Content of KeyInput value might have changed due to a
// patch side effect -> Read it again
if (Main_Data::game_variables->Get(_keyinput.variable) == 0) {
++_keyinput.wait_frames;
break;
}
Expand All @@ -477,6 +480,7 @@ void Game_Interpreter::Update(bool reset_loop_count) {
Main_Data::game_variables->Set(_keyinput.time_variable,
(_keyinput.wait_frames * 10) / Game_Clock::GetTargetGameFps());
Game_Map::SetNeedRefreshForVarChange(_keyinput.time_variable);
RuntimePatches::OnVariableChanged(_keyinput.time_variable);
}
_keyinput.wait = false;
}
Expand Down Expand Up @@ -1328,6 +1332,7 @@ bool Game_Interpreter::CommandControlVariables(lcf::rpg::EventCommand const& com
break;
}
Game_Map::SetNeedRefreshForVarChange(start);
RuntimePatches::OnVariableChanged(start);
} else if (com.parameters[4] == 1) {
// Multiple variables - Direct variable lookup
int var_id = com.parameters[5];
Expand Down Expand Up @@ -1367,6 +1372,7 @@ bool Game_Interpreter::CommandControlVariables(lcf::rpg::EventCommand const& com
break;
}
Game_Map::SetNeedRefresh(true);
RuntimePatches::OnVariableRangeChanged(start, end);
} else if (com.parameters[4] == 2) {
// Multiple variables - Indirect variable lookup
int var_id = com.parameters[5];
Expand Down Expand Up @@ -1406,6 +1412,7 @@ bool Game_Interpreter::CommandControlVariables(lcf::rpg::EventCommand const& com
break;
}
Game_Map::SetNeedRefresh(true);
RuntimePatches::OnVariableRangeChanged(start, end);
} else if (com.parameters[4] == 3) {
// Multiple variables - random
int rmax = max(com.parameters[5], com.parameters[6]);
Expand Down Expand Up @@ -1446,6 +1453,7 @@ bool Game_Interpreter::CommandControlVariables(lcf::rpg::EventCommand const& com
break;
}
Game_Map::SetNeedRefresh(true);
RuntimePatches::OnVariableRangeChanged(start, end);
} else {
// Multiple variables - constant
switch (operation) {
Expand Down Expand Up @@ -1484,6 +1492,7 @@ bool Game_Interpreter::CommandControlVariables(lcf::rpg::EventCommand const& com
break;
}
Game_Map::SetNeedRefresh(true);
RuntimePatches::OnVariableRangeChanged(start, end);
}
}

Expand Down Expand Up @@ -1947,6 +1956,7 @@ bool Game_Interpreter::CommandSimulatedAttack(lcf::rpg::EventCommand const& com)

if (com.parameters[6] != 0) {
Main_Data::game_variables->Set(com.parameters[7], result);
RuntimePatches::OnVariableChanged(com.parameters[7]);
Game_Map::SetNeedRefresh(true);
}
}
Expand Down Expand Up @@ -2239,6 +2249,7 @@ bool Game_Interpreter::CommandMemorizeLocation(lcf::rpg::EventCommand const& com
Main_Data::game_variables->Set(var_x, player->GetX());
Main_Data::game_variables->Set(var_y, player->GetY());
Game_Map::SetNeedRefreshForVarChange({var_map_id, var_x, var_y});
RuntimePatches::OnVariableChanged({var_map_id, var_x, var_y});
return true;
}

Expand Down Expand Up @@ -2357,6 +2368,7 @@ bool Game_Interpreter::CommandStoreTerrainID(lcf::rpg::EventCommand const& com)
int var_id = com.parameters[3];
Main_Data::game_variables->Set(var_id, Game_Map::GetTerrainTag(x, y));
Game_Map::SetNeedRefreshForVarChange(var_id);
RuntimePatches::OnVariableChanged(var_id);
return true;
}

Expand All @@ -2367,6 +2379,7 @@ bool Game_Interpreter::CommandStoreEventID(lcf::rpg::EventCommand const& com) {
auto* ev = Game_Map::GetEventAt(x, y, false);
Main_Data::game_variables->Set(var_id, ev ? ev->GetId() : 0);
Game_Map::SetNeedRefreshForVarChange(var_id);
RuntimePatches::OnVariableChanged(var_id);
return true;
}

Expand Down Expand Up @@ -3252,6 +3265,7 @@ bool Game_Interpreter::CommandKeyInputProc(lcf::rpg::EventCommand const& com) {
// While waiting the variable is reset to 0 each frame.
Main_Data::game_variables->Set(var_id, 0);
Game_Map::SetNeedRefreshForVarChange(var_id);
RuntimePatches::OnVariableChanged(var_id);
}

if (wait && Game_Message::IsMessageActive()) {
Expand Down Expand Up @@ -3367,6 +3381,7 @@ bool Game_Interpreter::CommandKeyInputProc(lcf::rpg::EventCommand const& com) {
int key = _keyinput.CheckInput();
Main_Data::game_variables->Set(_keyinput.variable, key);
Game_Map::SetNeedRefreshForVarChange(_keyinput.variable);
RuntimePatches::OnVariableChanged(_keyinput.variable);

return true;
}
Expand Down
5 changes: 4 additions & 1 deletion src/game_pictures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "scene.h"
#include "drawable_mgr.h"
#include "sprite_picture.h"
#include "game_runtime_patches.h"

static bool IsEmpty(const lcf::rpg::SavePicture& data, int frames) {
lcf::rpg::SavePicture empty;
Expand Down Expand Up @@ -570,7 +571,9 @@ void Game_Pictures::Picture::Update(bool is_battle) {

// Update rotation
if (data.effect_mode == lcf::rpg::SavePicture::Effect_rotation) {
data.current_rotation += data.current_effect_power;
if (!RuntimePatches::PowerMode2003::ApplyPictureRotation(data)) {
data.current_rotation += data.current_effect_power;
}
}

// Update waver phase
Expand Down
Loading
Loading