From 73600974c588ca10e0fcfc44782ae4fec1b578ba Mon Sep 17 00:00:00 2001 From: Silent Date: Mon, 18 Nov 2024 18:32:09 +0100 Subject: [PATCH] SA: Fix 1.0 EU executable crashes when losing police pursuit and triggering the replay US and EU no-DVD executables were decrypted slightly differently, and the patches did not account for that previously. Fixes #76 --- SilentPatchIII/versionmeta.props | 2 +- SilentPatchSA/PedSA.cpp | 2 +- SilentPatchSA/SilentPatchSA.cpp | 22 ++++++++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/SilentPatchIII/versionmeta.props b/SilentPatchIII/versionmeta.props index c7bb85a..444f842 100644 --- a/SilentPatchIII/versionmeta.props +++ b/SilentPatchIII/versionmeta.props @@ -6,7 +6,7 @@ .asi SilentPatch for GTA III 9 - 1 + 2 2013-2024 diff --git a/SilentPatchSA/PedSA.cpp b/SilentPatchSA/PedSA.cpp index 748820e..a372e92 100644 --- a/SilentPatchSA/PedSA.cpp +++ b/SilentPatchSA/PedSA.cpp @@ -131,7 +131,7 @@ uint8_t CPed::GetWeaponSkillForRenderWeaponPedsForPC_SAMP() bool CTaskComplexSequence::Contains(int taskID) const { - for (CTask* task : m_taskSequence) + for (const CTask* task : m_taskSequence) { if (task != nullptr && task->GetTaskType() == taskID) { diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index d9857f3..55a8762 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -6115,13 +6115,20 @@ void Patch_SA_10(HINSTANCE hInstance) bool HoodlumPatched = false; if (*reinterpret_cast(0x41BFA0) == 0xE9) { + // Since this function differs between EU and US Hoodlum, exceptionally use patterns + using namespace hook::txn; + uintptr_t backToCruisingIfNoWantedLevel_Obfuscated; ReadCall(0x41BFA0, backToCruisingIfNoWantedLevel_Obfuscated); - if (ModCompat::Utils::GetModuleHandleFromAddress(backToCruisingIfNoWantedLevel_Obfuscated) == hInstance) + if (ModCompat::Utils::GetModuleHandleFromAddress(backToCruisingIfNoWantedLevel_Obfuscated) == hInstance) try { - VP::InterceptCall(backToCruisingIfNoWantedLevel_Obfuscated + 0x86, orgJoinCarWithRoadSystem, JoinCarWithRoadSystem_AbortDriveByTask); + auto joinCarWithRoadSystem = make_range_pattern(backToCruisingIfNoWantedLevel_Obfuscated, backToCruisingIfNoWantedLevel_Obfuscated + 0x100, + "56 E8 ? ? ? ? 8A 96 2D 04 00 00").get_first(1); + + VP::InterceptCall(joinCarWithRoadSystem, orgJoinCarWithRoadSystem, JoinCarWithRoadSystem_AbortDriveByTask); HoodlumPatched = true; } + TXN_CATCH(); } if (!HoodlumPatched) { @@ -6203,13 +6210,20 @@ void Patch_SA_10(HINSTANCE hInstance) bool HoodlumPatched = false; if (*reinterpret_cast(0x45CEA0) == 0xE9) { + // Since this function differs between EU and US Hoodlum, exceptionally use patterns + using namespace hook::txn; + uintptr_t DealWithNewPedPacket_Obfuscated; ReadCall(0x45CEA0, DealWithNewPedPacket_Obfuscated); - if (ModCompat::Utils::GetModuleHandleFromAddress(DealWithNewPedPacket_Obfuscated) == hInstance) + if (ModCompat::Utils::GetModuleHandleFromAddress(DealWithNewPedPacket_Obfuscated) == hInstance) try { - InterceptCall(DealWithNewPedPacket_Obfuscated + 0xF8, orgRebuildPlayer, RebuildPlayer_LoadAllMotionGroupAnims); + auto DealWithNewPedPacket = make_range_pattern(DealWithNewPedPacket_Obfuscated, DealWithNewPedPacket_Obfuscated + 0x200, + "6A 01 56 E8 ? ? ? ? 83 C4 10").get_first(3); + + VP::InterceptCall(DealWithNewPedPacket, orgRebuildPlayer, RebuildPlayer_LoadAllMotionGroupAnims); HoodlumPatched = true; } + TXN_CATCH(); } if (!HoodlumPatched)