From 5f78ed97d1fd93c469a571c3d991b4d36f34af8f Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Thu, 15 Jun 2017 15:45:51 +0000 Subject: [PATCH] Fixed crash related to autopilot timing calculations for VC --- SilentPatchVC/SilentPatchVC.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 5d70bf4..3a51535 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -192,6 +192,27 @@ void GaragesInit_SilentPatch() static char aNoDesktopMode[64]; +unsigned int __cdecl AutoPilotTimerCalculation_VC(unsigned int nTimer, int nScaleFactor, float fScaleCoef) +{ + return nTimer - static_cast(nScaleFactor * fScaleCoef); +} + +void __declspec(naked) AutoPilotTimerFix_VC() +{ + _asm { + push dword ptr[esp + 0xC] + push dword ptr[ebx + 0x10] + push eax + call AutoPilotTimerCalculation_VC + add esp, 0xC + mov [ebx + 0xC], eax + add esp, 0x30 + pop ebp + pop ebx + retn 4 + } +} + void Patch_VC_10(const RECT& desktop) { using namespace Memory; @@ -329,6 +350,9 @@ void Patch_VC_10(const RECT& desktop) Patch(0x4AED14+1, 1); // katana Patch(0x4AEB74+1, 1); // chainsaw + // Fixed crash related to autopilot timing calculations + InjectHook(0x418FAE, AutoPilotTimerFix_VC, PATCH_JUMP); + // Adblocker #if DISABLE_FLA_DONATION_WINDOW @@ -477,6 +501,9 @@ void Patch_VC_11(const RECT& desktop) // Fixed ammo for melee weapons in cheats Patch(0x4AED34+1, 1); // katana Patch(0x4AEB94+1, 1); // chainsaw + + // Fixed crash related to autopilot timing calculations + InjectHook(0x418FAE, AutoPilotTimerFix_VC, PATCH_JUMP); } void Patch_VC_Steam(const RECT& desktop) @@ -615,6 +642,9 @@ void Patch_VC_Steam(const RECT& desktop) // Fixed ammo for melee weapons in cheats Patch(0x4AEA44+1, 1); // katana Patch(0x4AEBE4+1, 1); // chainsaw + + // Fixed crash related to autopilot timing calculations + InjectHook(0x418FAE, AutoPilotTimerFix_VC, PATCH_JUMP); } void Patch_VC_JP()