From 2f79eb1c8f464d0851e1ea0bcfcedb825ace5f15 Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 31 Oct 2024 23:27:53 +0100 Subject: [PATCH] SA: Fix the driving school cones fix so it doesn't leave cones from "Cone Coil" and "Burn and Lap" behind Fixes #62 --- CHANGELOG-SA.md | 1 + SilentPatchSA/SilentPatchSA.cpp | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-SA.md b/CHANGELOG-SA.md index 4511963..4ddb489 100644 --- a/CHANGELOG-SA.md +++ b/CHANGELOG-SA.md @@ -102,6 +102,7 @@ All the remaining, non-critical fixes. * ➕ The boundaries of the cursor on the Map screen, and the cursor itself now scale to resolution correctly (contributed by **Wesser**). * ➕ The inner padding of the text boxes with a background now scales to resolution correctly (contributed by **Wesser**). * ➕ Nitrous will no longer regenerate faster when reversing the car (contributed by **Wesser**). +* ➕ Hydra's jet thrusters no longer randomly fail to appear (contributed by **B1ack_Wh1te**). * Detached vehicle parts will now keep the same color and lighting as the vehicle they came from. * Detached vehicle parts are now rendered from both sides. * Resolved single-pixel wide seams showing on the Map screen with Anti-Aliasing enabled. diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index b354eea..8040e5a 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -603,7 +603,7 @@ static hook::pattern MakeScriptPattern(bool isMission, std::string_view bytes) begin = uintptr_t(ScriptSpace); end = begin + ScriptFileSize; } - return hook::make_range_pattern(begin, end, bytes).count_hint(100); + return hook::make_range_pattern(begin, end, bytes); } static void MountainCloudBoysFix() @@ -631,7 +631,10 @@ static void SupplyLinesFix( bool isBeefyBaron ) static void DrivingSchoolConesFix() { auto pattern = MakeScriptPattern(true, "04 00 02 20 03 04 00 D6 00 04 00 1A 00 04 2E 02 20 03 4D 00 01 60 75 FF FF BE 00 08 01 07 24 03 20 03 2E 80 08 00 02 20 03 04 01"); - if (pattern.size() == 1) // Only destroy as many cones as were created + auto coneCoilConeCount = MakeScriptPattern(true, "1A 00 04 17 02 20 03"); + auto burnAndLapConeCount = MakeScriptPattern(true, "1A 00 04 23 02 20 03"); + // Only destroy as many cones as were created, and correct trafficcone_counter for "Cone Coil" and "Burn and Lap" + if (pattern.size() == 1 && coneCoilConeCount.size() == 1 && burnAndLapConeCount.size() == 1) { const uint8_t gotoSkipAssignment[] = { 0x02, 0x00, 0x01, 0x8B, 0x75, 0xFF, 0xFF }; memcpy(pattern.get(0).get(0), gotoSkipAssignment, sizeof(gotoSkipAssignment)); @@ -646,6 +649,15 @@ static void DrivingSchoolConesFix() // Also set trafficcone_counter to 0 so the first destruction doesn't happen int32_t* trafficcone_counter = reinterpret_cast(ScriptSpace+800); *trafficcone_counter = 0; + + // Correct the final trafficcone_counter in Cone Coil + // 23 -> 30 + *coneCoilConeCount.get(0).get(3) = 30; + + + // Correct the final trafficcone_counter in Burn and Lap + // 35 -> 42 + *burnAndLapConeCount.get(0).get(3) = 42; } }