From 82fba227af74b3f151a76195b7bb1a5710196cc3 Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 21 Mar 2024 20:44:51 +0100 Subject: [PATCH] Don't reset mouse sensitivity on New Game --- SilentPatchVC/SilentPatchVC.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index ea5909b..e566fa4 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -552,6 +552,21 @@ namespace NullTerminatedLines } +// ============= Don't reset mouse sensitivity on New Game ============= +namespace MouseSensNewGame +{ + static float DefaultHorizontalAccel; + static float* fMouseAccelHorzntl; + + static void (*orgSetDirMyDocuments)(); + static void SetDirMyDocuments_ResetMouse() + { + orgSetDirMyDocuments(); + *fMouseAccelHorzntl = DefaultHorizontalAccel; + } +} + + void InjectDelayedPatches_VC_Common( bool bHasDebugMenu, const wchar_t* wcModulePath ) { using namespace Memory; @@ -1324,6 +1339,21 @@ void Patch_VC_Common() InterceptCall(loadPath, orgSscanf_LoadPath, sscanf1_LoadPath_Terminate); } + + + // Don't reset mouse sensitivity on New Game + { + using namespace MouseSensNewGame; + + auto cameraInit = pattern("C7 85 14 09 00 00 00 00 00 00 C7 05 ? ? ? ? ? ? ? ? C7 05").get_one(); + auto setDirMyDocuments = get_pattern("89 CD E8 ? ? ? ? 68", 2); + + DefaultHorizontalAccel = *cameraInit.get(20 + 2 + 4); + fMouseAccelHorzntl = *cameraInit.get(20 + 2); + + Nop(cameraInit.get(20), 10); + InterceptCall(setDirMyDocuments, orgSetDirMyDocuments, SetDirMyDocuments_ResetMouse); + } } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)