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
This commit is contained in:
Silent 2024-11-18 18:32:09 +01:00
parent c733f3e7d1
commit 73600974c5
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
3 changed files with 20 additions and 6 deletions

View file

@ -6,7 +6,7 @@
<SILENTPATCH_EXT>.asi</SILENTPATCH_EXT> <SILENTPATCH_EXT>.asi</SILENTPATCH_EXT>
<SILENTPATCH_FULL_NAME>SilentPatch for GTA III</SILENTPATCH_FULL_NAME> <SILENTPATCH_FULL_NAME>SilentPatch for GTA III</SILENTPATCH_FULL_NAME>
<SILENTPATCH_REVISION_ID>9</SILENTPATCH_REVISION_ID> <SILENTPATCH_REVISION_ID>9</SILENTPATCH_REVISION_ID>
<SILENTPATCH_BUILD_ID>1</SILENTPATCH_BUILD_ID> <SILENTPATCH_BUILD_ID>2</SILENTPATCH_BUILD_ID>
<SILENTPATCH_COPYRIGHT>2013-2024</SILENTPATCH_COPYRIGHT> <SILENTPATCH_COPYRIGHT>2013-2024</SILENTPATCH_COPYRIGHT>
</PropertyGroup> </PropertyGroup>
<PropertyGroup /> <PropertyGroup />

View file

@ -131,7 +131,7 @@ uint8_t CPed::GetWeaponSkillForRenderWeaponPedsForPC_SAMP()
bool CTaskComplexSequence::Contains(int taskID) const bool CTaskComplexSequence::Contains(int taskID) const
{ {
for (CTask* task : m_taskSequence) for (const CTask* task : m_taskSequence)
{ {
if (task != nullptr && task->GetTaskType() == taskID) if (task != nullptr && task->GetTaskType() == taskID)
{ {

View file

@ -6115,13 +6115,20 @@ void Patch_SA_10(HINSTANCE hInstance)
bool HoodlumPatched = false; bool HoodlumPatched = false;
if (*reinterpret_cast<const uint8_t*>(0x41BFA0) == 0xE9) if (*reinterpret_cast<const uint8_t*>(0x41BFA0) == 0xE9)
{ {
// Since this function differs between EU and US Hoodlum, exceptionally use patterns
using namespace hook::txn;
uintptr_t backToCruisingIfNoWantedLevel_Obfuscated; uintptr_t backToCruisingIfNoWantedLevel_Obfuscated;
ReadCall(0x41BFA0, 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<void>(1);
VP::InterceptCall(joinCarWithRoadSystem, orgJoinCarWithRoadSystem, JoinCarWithRoadSystem_AbortDriveByTask);
HoodlumPatched = true; HoodlumPatched = true;
} }
TXN_CATCH();
} }
if (!HoodlumPatched) if (!HoodlumPatched)
{ {
@ -6203,13 +6210,20 @@ void Patch_SA_10(HINSTANCE hInstance)
bool HoodlumPatched = false; bool HoodlumPatched = false;
if (*reinterpret_cast<const uint8_t*>(0x45CEA0) == 0xE9) if (*reinterpret_cast<const uint8_t*>(0x45CEA0) == 0xE9)
{ {
// Since this function differs between EU and US Hoodlum, exceptionally use patterns
using namespace hook::txn;
uintptr_t DealWithNewPedPacket_Obfuscated; uintptr_t DealWithNewPedPacket_Obfuscated;
ReadCall(0x45CEA0, 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<void>(3);
VP::InterceptCall(DealWithNewPedPacket, orgRebuildPlayer, RebuildPlayer_LoadAllMotionGroupAnims);
HoodlumPatched = true; HoodlumPatched = true;
} }
TXN_CATCH();
} }
if (!HoodlumPatched) if (!HoodlumPatched)