--- Daodan/src/Patches/Patches.c 2014/08/25 23:21:09 1008 +++ Daodan/src/Patches/Patches.c 2021/10/24 02:50:48 1163 @@ -5,6 +5,7 @@ #include "Cheater.h" #include "../Daodan_Config.h" #include "GL.h" +#include "Input.h" #include "../Daodan_Patch.h" #include "Utility.h" #include "Win32.h" @@ -131,6 +132,8 @@ int16_t ONICALL DD_COrTextArea_Resize(vo return Oni_COrTextArea_Resize(inTextArea, inBounds, inNumTextEntries); } + + #define IMcShade_Red (0xFFFF0000) #define IMcShade_Green (0xFF00FF00) #define IMcShade_Blue (0xFF0000FF) @@ -180,17 +183,6 @@ int16_t ONICALL DD_ONrMechanics_Register return Oni_ONrMechanics_Register(inObjectType, inObjectTypeIndex, inGroupName, inSizeInMemory, inObjectMethods, inFlags, inMechanicsMethods); } -_ONrGameState_HandleUtilityInput Oni_ONrGameState_HandleUtilityInput = (_ONrGameState_HandleUtilityInput)0; -void ONICALL DD_ONrGameState_HandleUtilityInput(const void* inInput) -{ - Oni_ONrGameState_HandleUtilityInput(inInput); - - if (ONrDebugKey_WentDown(7)) { - OBJgTriggerVolume_Visible = !OBJgTriggerVolume_Visible; - } -} - - // Enables d_regen script command. Instead of one global flag to only regenerate player each char has a flag to enable local regeneration void DD_Patch_Regeneration() { @@ -371,24 +363,16 @@ bool DD_Patch_Init() // At end of ONrUnlockLevel to init values on level loading DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad); + + if (DDrConfig_GetOptOfType("gameplay.bindablecheats", C_BOOL)->value.intBoolVal) + { + InitBindableCheats(); + } } if (DDrConfig_GetOptOfType("language.chinese", C_BOOL)->value.intBoolVal) DD_Patch_Chinese(); - // Limit cursor to Oni's window - if (DDrConfig_GetOptOfType("windows.clipcursor", C_BOOL)->value.intBoolVal) - { - // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook. - DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set); - - // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook. - DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set); - - // LIrTerminate: replace LIrPlatform_Terminate call with our hook. - DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate); - } - // Disables weapon cooldown exploit if (DDrConfig_GetOptOfType("gameplay.cooldowntimer", C_BOOL)->value.intBoolVal) { @@ -401,12 +385,35 @@ bool DD_Patch_Init() { DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes); } - - // Forced DirectInput (for Windows NT) - if (DDrConfig_GetOptOfType("windows.directinput", C_BOOL)->value.intBoolVal) + + if (DDrConfig_GetOptOfType("windows.daodaninput", C_BOOL)->value.intBoolVal) + { + DDrInput_PatchDaodanInput(); + } + else { - // LIrPlatform_Initialize: replace conditional jump by unconditional - DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb); + // The following patches aren't compatible with, or are superseded by + // Daodan input + + // Limit cursor to Oni's window + if (DDrConfig_GetOptOfType("windows.clipcursor", C_BOOL)->value.intBoolVal) + { + // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook. + DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set); + + // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook. + DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set); + + // LIrTerminate: replace LIrPlatform_Terminate call with our hook. + DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate); + } + + // Forced DirectInput (for Windows NT) + if (DDrConfig_GetOptOfType("windows.directinput", C_BOOL)->value.intBoolVal) + { + // LIrPlatform_Initialize: replace conditional jump by unconditional + DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb); + } } // Disable Oni's command line parser so it doesn't interfere with ours @@ -438,6 +445,10 @@ bool DD_Patch_Init() Oni_COrTextArea_Resize = DDrPatch_MakeDetour((void*)COrTextArea_Resize, (void*)DD_COrTextArea_Resize); } + // Allow custom actions to be bound through Daodan + if (DDrConfig_GetOptOfType("gameplay.customactions", C_BOOL)->value.intBoolVal) + DDrInput_PatchCustomActions(); + // Hackish fix for Konoko not kicking guns // Don't use this, it breaks stairs. if (DDrConfig_GetOptOfType("gameplay.kickguns", C_BOOL)->value.intBoolVal) @@ -556,10 +567,10 @@ bool DD_Patch_Init() // Allow bsl-var show_triggervolumes or ctrl+shift+x (devmode) to work if (DDrConfig_GetOptOfType("devmode.showtriggervolumes", C_BOOL)->value.intBoolVal) { + DDrInput_PatchUtilityInput(); Oni_ONrMechanics_Register = DDrPatch_MakeDetour((void*)ONrMechanics_Register, (void*)DD_ONrMechanics_Register); - Oni_ONrGameState_HandleUtilityInput = DDrPatch_MakeDetour((void*)ONrGameState_HandleUtilityInput, (void*)DD_ONrGameState_HandleUtilityInput); } - + // Experiment with allowing enemies to be thrown over railings if (DDrConfig_GetOptOfType("gameplay.throwtest", C_BOOL)->value.intBoolVal) { @@ -577,6 +588,9 @@ bool DD_Patch_Init() DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6); DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect); + // Note: Daodan input makes the following GetCursorPos and SetCursorPos + // patches unnecessary + // LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates. DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6); DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos);