From 1d007aed68bf62665b41d15bbcca6868cf975985 Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 26 Dec 2019 23:18:01 +0100 Subject: [PATCH] SA: Disallow moving cam up/down with mouse when looking back/left/right in vehicle (1.0 only for now) --- SilentPatchSA/SilentPatchSA.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 2ed5b20..5057d22 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -1669,6 +1669,21 @@ namespace MoonphasesFix } } +// ============= Disallow moving cam up/down with mouse when looking back/left/right in vehicle ============= +namespace FollowCarMouseCamFix +{ + static uint32_t& camLookDirection = **AddressByVersion( 0x525526 + 2, 0, 0 ); + static void* (*orgGetPad)(int); + static bool* orgUseMouse3rdPerson; + + static bool useMouseAndLooksForwards; + static void* getPadAndSetFlag( int padNum ) + { + useMouseAndLooksForwards = *orgUseMouse3rdPerson && camLookDirection == 3; + return orgGetPad( padNum ); + } +}; + // ============= LS-RP Mode stuff ============= namespace LSRPMode @@ -4238,6 +4253,18 @@ void Patch_SA_10() Patch( 0x4C8010 + 4, 6 ); + // Disallow moving cam up/down with mouse when looking back/left/right in vehicle + { + using namespace FollowCarMouseCamFix; + + orgUseMouse3rdPerson = *(bool**)(0x525615 + 1); + Patch( 0x525615 + 1, &useMouseAndLooksForwards ); + + ReadCall( 0x5245E4, orgGetPad ); + InjectHook( 0x5245E4, getPadAndSetFlag ); + } + + #if FULL_PRECISION_D3D // Test - full precision D3D device Patch( 0x7F672B+1, *(uint8_t*)(0x7F672B+1) | D3DCREATE_FPU_PRESERVE );