From b6450d18534674244fabe9c85875739b6e69ec1b Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 10 Oct 2024 21:02:57 +0200 Subject: [PATCH] Changed the resolution scaling variable to a safer one Improves compatibility with wsfix HUD scaling --- SilentPatchIII/SilentPatchIII.cpp | 8 ++++---- SilentPatchSA/SilentPatchSA.cpp | 16 ++++++++-------- SilentPatchVC/SilentPatchVC.cpp | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index bef3aa3..8d297de 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -101,14 +101,14 @@ auto WorldRemove = reinterpret_cast(hook::get_pattern("8A 4 float GetWidthMult() { - static const float& ResolutionWidthMult = **AddressByVersion(0x57E956, 0x57ECA6, 0x57EBA6); - return ResolutionWidthMult; + static float** ResolutionWidthMult = hook::get_pattern("D8 0D ? ? ? ? 89 54 24 0C", 2); + return **ResolutionWidthMult; } float GetHeightMult() { - static const float& ResolutionHeightMult = **AddressByVersion(0x57E940, 0x57EC90, 0x57EB90); - return ResolutionHeightMult; + static float** ResolutionHeightMult = hook::get_pattern("D8 0D ? ? ? ? 89 44 24 04 50 D8 0D", 2); + return **ResolutionHeightMult; } void ShowRadarTrace(float fX, float fY, unsigned int nScale, BYTE r, BYTE g, BYTE b, BYTE a) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index ae9d44e..ad8837f 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -490,27 +490,27 @@ namespace ScalingInternals // 1.0 - fast math uses a scaling multiplier float ScaleX_Multiplier(float val) { - static const float& ResolutionWidthMult = **(float**)(0x43CF57 + 2); - return val * RsGlobal->MaximumWidth * ResolutionWidthMult; + static float** ResolutionWidthMult = (float**)(0x5733FD + 2); + return val * RsGlobal->MaximumWidth * **ResolutionWidthMult; } float ScaleY_Multiplier(float val) { - static const float& ResolutionHeightMult = **(float**)(0x43CF47 + 2); - return val * RsGlobal->MaximumHeight * ResolutionHeightMult; + static float** ResolutionHeightMult = (float**)(0x57342D + 2); + return val * RsGlobal->MaximumHeight * **ResolutionHeightMult; } // New binaries - precise math uses a scaling divisor float ScaleX_Divisor(float val) { - static const double& ResolutionWidthDiv = **hook::get_pattern("DC 35 ? ? ? ? DC 0D ? ? ? ? DE E9 D9 5D F0", 2); - return static_cast(val * RsGlobal->MaximumWidth / ResolutionWidthDiv); + static double** ResolutionWidthDiv = hook::get_pattern("DC 35 ? ? ? ? DC 0D ? ? ? ? DE E9 D9 5D F0", 2); + return static_cast(val * RsGlobal->MaximumWidth / **ResolutionWidthDiv); } float ScaleY_Divisor(float val) { - static const double& ResolutionHeightDiv = **hook::get_pattern("50 DC 35 ? ? ? ? DC 0D", 1 + 2); - return static_cast(val * RsGlobal->MaximumHeight / ResolutionHeightDiv); + static double** ResolutionHeightDiv = hook::get_pattern("50 DC 35 ? ? ? ? DC 0D", 1 + 2); + return static_cast(val * RsGlobal->MaximumHeight / **ResolutionHeightDiv); } } diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 5bc4adf..29b8672 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -74,14 +74,14 @@ int32_t& numModelInfos = *hook::get_pattern("81 FD ? ? ? ? 7C B7", 2); float GetWidthMult() { - static const float& ResolutionWidthMult = **AddressByVersion(0x5FA15E, 0x5FA17E, 0x5F9DBE); - return ResolutionWidthMult; + static float** ResolutionWidthMult = hook::get_pattern("D8 0D ? ? ? ? D1 F8 52", 2); + return **ResolutionWidthMult; } float GetHeightMult() { - static const float& ResolutionHeightMult = **AddressByVersion(0x5FA148, 0x5FA168, 0x5F9DA8); - return ResolutionHeightMult; + static float** ResolutionHeightMult = hook::get_pattern("D8 0D ? ? ? ? D1 F8 C7 44 24 ? 00 00 00 00 89 04 24", 2); + return **ResolutionHeightMult; } static bool bGameInFocus = true;