From 9247b2c38dd8c71715cf911676722a663a4ddf9a Mon Sep 17 00:00:00 2001 From: Silent Date: Mon, 20 Mar 2017 21:10:50 +0100 Subject: [PATCH] new timers fix (only 1.0 in SA!!) --- SilentPatchSA/SilentPatchSA.cpp | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index ff0b4d5..83b1dd4 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -1852,6 +1852,66 @@ DarkVehiclesFix4_MakeItDark: } // 1.0 ONLY ENDS HERE +static int _Timers_ftol_internal( double timer, double& remainder ) +{ + if ( timer >= 1.0 ) return int(timer); + + double integral; + remainder = modf( timer + remainder, &integral ); + return int(integral); +} + +int __stdcall Timers_ftol_PauseMode( double timer ) +{ + static double TimersRemainder = 0.0; + return _Timers_ftol_internal( timer, TimersRemainder ); +} + +int __stdcall Timers_ftol_NonClipped( double timer ) +{ + static double TimersRemainder = 0.0; + return _Timers_ftol_internal( timer, TimersRemainder ); +} + +int __stdcall Timers_ftol( double timer ) +{ + static double TimersRemainder = 0.0; + return _Timers_ftol_internal( timer, TimersRemainder ); +} + +void __declspec(naked) asmTimers_ftol_PauseMode() +{ + _asm + { + sub esp, 8 + fstp qword ptr [esp] + call Timers_ftol_PauseMode + retn + } +} + +void __declspec(naked) asmTimers_ftol_NonClipped() +{ + _asm + { + sub esp, 8 + fstp qword ptr [esp] + call Timers_ftol_NonClipped + retn + } +} + +void __declspec(naked) asmTimers_ftol() +{ + _asm + { + sub esp, 8 + fstp qword ptr [esp] + call Timers_ftol + retn + } +} + void __declspec(naked) GetMaxExtraDirectionals() { _asm @@ -3041,6 +3101,12 @@ void Patch_SA_10() InjectHook( 0x73B3AE + 1, WeaponRangeMult_VehicleCheck, PATCH_CALL ); + // New timers fix + InjectHook( 0x561C32, asmTimers_ftol_PauseMode ); + InjectHook( 0x561902, asmTimers_ftol_NonClipped ); + InjectHook( 0x56191A, asmTimers_ftol ); + + // Don't catch WM_SYSKEYDOWN and WM_SYSKEYUP (fixes Alt+F4) InjectHook( AddressByRegion_10(0x748220), AddressByRegion_10(0x748446), PATCH_JUMP ); Patch( AddressByRegion_10(0x7481E3), 0x5C ); // esi -> ebx