From 47612e5175524bd76d22a4e1fc9b0ca8b87217c3 Mon Sep 17 00:00:00 2001 From: ZivDero Date: Wed, 26 Feb 2025 14:56:06 +0300 Subject: [PATCH] Fix a bug where resetting hotkeys in-game would delete Keyboard.ini from subfolders --- src/extensions/options/optionsext_hooks.cpp | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/extensions/options/optionsext_hooks.cpp b/src/extensions/options/optionsext_hooks.cpp index 0f74495ed..e6637e5ef 100644 --- a/src/extensions/options/optionsext_hooks.cpp +++ b/src/extensions/options/optionsext_hooks.cpp @@ -31,6 +31,28 @@ #include "fatal.h" #include "debughandler.h" #include "asserthandler.h" +#include "hooker.h" +#include "hooker_macros.h" +#include "rawfile.h" + + +/** + * Patches Hotkey_Dialog_Proc to use RawFileClass when deleting Keyboard.INI to ensure only + * the file in the game's root directory is deleted. + * + * @author: ZivDero + */ +void _Delete_Keyboard_INI() +{ + RawFileClass keyboard_ini("Keyboard.ini"); + keyboard_ini.Delete(); +} + +DECLARE_PATCH(_Hotkey_Dialog_Proc_Keyboard_INI_RawFileClass_Patch) +{ + _Delete_Keyboard_INI(); + JMP(0x0058AA21); +} /** @@ -42,4 +64,6 @@ void OptionsClassExtension_Hooks() * Initialises the extended class. */ OptionsClassExtension_Init(); + + Patch_Jump(0x0058AA18, &_Hotkey_Dialog_Proc_Keyboard_INI_RawFileClass_Patch); }