ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/Patches/Patches.c
(Generate patch)

Comparing Daodan/src/Patches/Patches.c (file contents):
Revision 1000 by alloc, Sun May 4 18:17:11 2014 UTC vs.
Revision 1163 by rossy, Sun Oct 24 02:50:48 2021 UTC

# Line 5 | Line 5
5   #include "Cheater.h"
6   #include "../Daodan_Config.h"
7   #include "GL.h"
8 + #include "Input.h"
9   #include "../Daodan_Patch.h"
10   #include "Utility.h"
11   #include "Win32.h"
# Line 131 | Line 132 | int16_t ONICALL DD_COrTextArea_Resize(vo
132          return Oni_COrTextArea_Resize(inTextArea, inBounds, inNumTextEntries);
133   }
134  
135 +
136 +
137   #define IMcShade_Red (0xFFFF0000)
138   #define IMcShade_Green (0xFF00FF00)
139   #define IMcShade_Blue (0xFF0000FF)
# Line 180 | Line 183 | int16_t ONICALL DD_ONrMechanics_Register
183          return Oni_ONrMechanics_Register(inObjectType, inObjectTypeIndex, inGroupName, inSizeInMemory, inObjectMethods, inFlags, inMechanicsMethods);
184   }
185  
183 _ONrGameState_HandleUtilityInput Oni_ONrGameState_HandleUtilityInput = (_ONrGameState_HandleUtilityInput)0;
184 void ONICALL DD_ONrGameState_HandleUtilityInput(const void* inInput)
185 {
186        Oni_ONrGameState_HandleUtilityInput(inInput);
187        
188        if (ONrDebugKey_WentDown(7)) {
189                OBJgTriggerVolume_Visible = !OBJgTriggerVolume_Visible;
190        }
191 }
192
193
186   // Enables d_regen script command. Instead of one global flag to only regenerate player each char has a flag to enable local regeneration
187   void DD_Patch_Regeneration()
188   {
# Line 277 | Line 269 | void DD_Patch_ShowNames()
269   }
270  
271  
272 <
272 > void DD_Patch_CharacterAwareness()
273 > {
274 >        const unsigned char patch[] =
275 >        {
276 >                0x52,                           //  0: push   edx
277 >                0xBA, 0xA0, 0x16, 0x00, 0x00,   //  1: mov    edx,0x16a0
278 >                0x89, 0xF8,                     //  6: mov    eax,edi
279 >                0xF7, 0xE2,                     //  8: mul    edx
280 >                0x89, 0xC2,                     //  a: mov    edx,eax
281 >                0xE8, 0x00, 0x00, 0x00, 0x00,   //  c: call   ONrGameState_LivingCharacterList_Get (-> OniExe + 0x000fca90)
282 >                0x8B, 0x00,                     // 11: mov    eax,[eax]
283 >                0x01, 0xD0,                     // 13: add    eax,edx
284 >                0x89, 0xC6,                     // 15: mov    esi,eax
285 >                0x5A,                           // 17: pop    edx
286 >                0x8B, 0x46, 0x04,               // 18: (ORIG) mov        eax, dword [ds:esi+0x4]
287 >                0xF6, 0xC4, 0x80                // 1b: (ORIG) test       ah, 0x80
288 >        };
289 >        void* newCode = DDrPatch_ExecutableASM((char*)(OniExe + 0x0009A609), (char*)(OniExe + 0x0009A60F), patch, sizeof(patch));
290 >        if ((int)newCode > 0) {
291 >                DDrPatch_MakeCall((char*)(newCode+0xC), (char*)(OniExe + 0x000FCA90));
292 >                DDrPatch_NOOP((char*)(OniExe + 0x0009A60E), 1);
293 >        }
294 > }
295  
296  
297  
# Line 321 | Line 335 | bool DD_Patch_Init()
335          if (DDrConfig_GetOptOfType("modding.d_regen", C_BOOL)->value.intBoolVal)
336                  DD_Patch_Regeneration();
337  
338 +        if (DDrConfig_GetOptOfType("gameplay.characterawareness", C_BOOL)->value.intBoolVal)
339 +                DD_Patch_CharacterAwareness();
340 +
341          // Cheats always enabled
342          if (DDrConfig_GetOptOfType("gameplay.cheatsenabled", C_BOOL)->value.intBoolVal)
343          {
# Line 346 | Line 363 | bool DD_Patch_Init()
363  
364                  // At end of ONrUnlockLevel to init values on level loading
365                  DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad);
366 +                
367 +                if (DDrConfig_GetOptOfType("gameplay.bindablecheats", C_BOOL)->value.intBoolVal)
368 +                {
369 +                        InitBindableCheats();
370 +                }
371          }
372          
373          if (DDrConfig_GetOptOfType("language.chinese", C_BOOL)->value.intBoolVal)
374                  DD_Patch_Chinese();
375  
354        // Limit cursor to Oni's window
355        if (DDrConfig_GetOptOfType("windows.clipcursor", C_BOOL)->value.intBoolVal)
356        {
357                // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook.
358                DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set);
359
360                // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook.
361                DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set);
362        
363                // LIrTerminate: replace LIrPlatform_Terminate call with our hook.
364                DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate);
365        }
366
376          // Disables weapon cooldown exploit
377          if (DDrConfig_GetOptOfType("gameplay.cooldowntimer", C_BOOL)->value.intBoolVal)
378          {
# Line 376 | Line 385 | bool DD_Patch_Init()
385          {
386                  DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes);
387          }
388 <        
389 <        // Forced DirectInput (for Windows NT)
381 <        if (DDrConfig_GetOptOfType("windows.directinput", C_BOOL)->value.intBoolVal)
388 >
389 >        if (DDrConfig_GetOptOfType("windows.daodaninput", C_BOOL)->value.intBoolVal)
390          {
391 <                // LIrPlatform_Initialize: replace conditional jump by unconditional
392 <                DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb);
391 >                DDrInput_PatchDaodanInput();
392 >        }
393 >        else
394 >        {
395 >                // The following patches aren't compatible with, or are superseded by
396 >                // Daodan input
397 >
398 >                // Limit cursor to Oni's window
399 >                if (DDrConfig_GetOptOfType("windows.clipcursor", C_BOOL)->value.intBoolVal)
400 >                {
401 >                        // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook.
402 >                        DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set);
403 >
404 >                        // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook.
405 >                        DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set);
406 >
407 >                        // LIrTerminate: replace LIrPlatform_Terminate call with our hook.
408 >                        DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate);
409 >                }
410 >
411 >                // Forced DirectInput (for Windows NT)
412 >                if (DDrConfig_GetOptOfType("windows.directinput", C_BOOL)->value.intBoolVal)
413 >                {
414 >                        // LIrPlatform_Initialize: replace conditional jump by unconditional
415 >                        DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb);
416 >                }
417          }
418  
419          // Disable Oni's command line parser so it doesn't interfere with ours
# Line 413 | Line 445 | bool DD_Patch_Init()
445                  Oni_COrTextArea_Resize = DDrPatch_MakeDetour((void*)COrTextArea_Resize, (void*)DD_COrTextArea_Resize);
446          }
447          
448 +        // Allow custom actions to be bound through Daodan
449 +        if (DDrConfig_GetOptOfType("gameplay.customactions", C_BOOL)->value.intBoolVal)
450 +                DDrInput_PatchCustomActions();
451 +
452          // Hackish fix for Konoko not kicking guns
453          // Don't use this, it breaks stairs.
454          if (DDrConfig_GetOptOfType("gameplay.kickguns", C_BOOL)->value.intBoolVal)
# Line 531 | Line 567 | bool DD_Patch_Init()
567          // Allow bsl-var show_triggervolumes or ctrl+shift+x (devmode) to work
568          if (DDrConfig_GetOptOfType("devmode.showtriggervolumes", C_BOOL)->value.intBoolVal)
569          {
570 +                DDrInput_PatchUtilityInput();
571                  Oni_ONrMechanics_Register = DDrPatch_MakeDetour((void*)ONrMechanics_Register, (void*)DD_ONrMechanics_Register);
535                Oni_ONrGameState_HandleUtilityInput = DDrPatch_MakeDetour((void*)ONrGameState_HandleUtilityInput, (void*)DD_ONrGameState_HandleUtilityInput);
572          }
573 <        
573 >
574          // Experiment with allowing enemies to be thrown over railings
575          if (DDrConfig_GetOptOfType("gameplay.throwtest", C_BOOL)->value.intBoolVal)
576          {
# Line 552 | Line 588 | bool DD_Patch_Init()
588                  DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6);
589                  DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect);
590  
591 +                // Note: Daodan input makes the following GetCursorPos and SetCursorPos
592 +                // patches unnecessary
593 +
594                  // LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates.
595                  DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6);
596                  DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos);

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)