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); }