@@ -619,6 +619,77 @@ static void __declspec(naked) HOOK_CWeapon_Update()
619619 }
620620}
621621
622+ #define HOOKPOS_CPhysical__ApplyAirResistance 0x544D29
623+ #define HOOKSIZE_CPhysical__ApplyAirResistance 5
624+ static const unsigned int RETURN_CPhysical__ApplyAirResistance = 0x544D4D ;
625+ static void _declspec (naked) HOOK_CPhysical__ApplyAirResistance()
626+ {
627+ _asm {
628+ fld ds:[0x862CD0 ] // 0.99000001f
629+ fld ds:[0xB7CB5C ] // CTimer::ms_fTimeStep
630+ fdiv kOriginalTimeStep // 1.666f
631+ mov eax, 0x822130 // powf
632+ call eax
633+
634+ fld st (0 )
635+ fmul [esi+0x50 ]
636+ fstp [esi+0x50 ]
637+
638+ fld st (0 )
639+ fmul [esi+0x54 ]
640+ fstp [esi+0x54 ]
641+
642+ fmul [esi+0x58 ]
643+ fstp [esi+0x58 ]
644+ jmp RETURN_CPhysical__ApplyAirResistance
645+ }
646+ }
647+
648+ template <unsigned int returnAddress>
649+ static void _declspec (naked) HOOK_VehicleRapidStopFix()
650+ {
651+ static unsigned int RETURN_VehicleRapidStopFix = returnAddress;
652+ _asm {
653+ fld ds:[0xC2B9CC ] // mod_HandlingManager.m_fWheelFriction
654+ fmul ds:[0xB7CB5C ] // CTimer::ms_fTimeStep
655+ fdiv kOriginalTimeStep // 1.666f
656+ jmp RETURN_VehicleRapidStopFix
657+ }
658+ }
659+
660+ void CMultiplayerSA::SetRapidVehicleStopFixEnabled (bool enabled)
661+ {
662+ if (isRapidVehicleStopFixEnabled == enabled)
663+ return ;
664+
665+ if (enabled)
666+ {
667+ EZHookInstall (CPhysical__ApplyAirResistance);
668+
669+ // CVehicle::ProcessWheel
670+ HookInstall (0x6D6E69 , (DWORD)HOOK_VehicleRapidStopFix<0x6D6E6F >, 6 );
671+ HookInstall (0x6D6EA8 , (DWORD)HOOK_VehicleRapidStopFix<0x6D6EAE >, 6 );
672+
673+ // CVehicle::ProcessBikeWheel
674+ HookInstall (0x6D767F , (DWORD)HOOK_VehicleRapidStopFix<0x6D7685 >, 6 );
675+ HookInstall (0x6D76AB , (DWORD)HOOK_VehicleRapidStopFix<0x6D76B1 >, 6 );
676+ HookInstall (0x6D76CD , (DWORD)HOOK_VehicleRapidStopFix<0x6D76D3 >, 6 );
677+ }
678+ else
679+ {
680+ MemCpy ((void *)HOOKPOS_CPhysical__ApplyAirResistance, " \xD9\x46\x50\xD8\x0D " , 5 );
681+
682+ MemCpy ((void *)0x6D6E69 , " \xD9\x05\xCC\xB9\xC2\x00 " , 6 );
683+ MemCpy ((void *)0x6D6EA8 , " \xD9\x05\xCC\xB9\xC2\x00 " , 6 );
684+
685+ MemCpy ((void *)0x6D767F , " \xD9\x05\xCC\xB9\xC2\x00 " , 6 );
686+ MemCpy ((void *)0x6D76AB , " \xD9\x05\xCC\xB9\xC2\x00 " , 6 );
687+ MemCpy ((void *)0x6D76CD , " \xD9\x05\xCC\xB9\xC2\x00 " , 6 );
688+ }
689+
690+ isRapidVehicleStopFixEnabled = enabled;
691+ }
692+
622693void CMultiplayerSA::InitHooks_FrameRateFixes ()
623694{
624695 EZHookInstall (CTaskSimpleUseGun__SetMoveAnim);
0 commit comments