Compare commits

...

6 commits

Author SHA1 Message Date
Tomasak
d2dafe1eba
Merge dc545a9b40 into 2f79eb1c8f 2024-11-01 01:41:39 +03:00
Silent
2f79eb1c8f
SA: Fix the driving school cones fix so it doesn't leave cones from "Cone Coil" and "Burn and Lap" behind
Fixes #62
2024-10-31 23:27:53 +01:00
Silent
3017790d44
Fix Hydra's jet thrusters not displaying due to an uninitialized variable in RwMatrix
By B1ack_Wh1te

Fixes #57
2024-10-31 19:07:22 +01:00
Tomasak
dc545a9b40 Update SilentPatchVC.ini 2024-10-25 18:31:44 +02:00
Tomasak
98c9c151b2 Update SilentPatchVC.ini 2024-10-25 18:29:10 +02:00
Tomasak
a4c403e049 two more bfc objects
it never ends
2024-10-25 18:20:23 +02:00
3 changed files with 81 additions and 2 deletions

View file

@ -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.

View file

@ -56,17 +56,30 @@ carsontrack
car_fucko03
chairsntable
chairsntableml
ci_alights1_01
ci_astudlights
ci_backlot1
ci_backlot2
ci_backlot3
ci_backlotprops1
ci_backlotprops2
ci_backlotprops3
ci_blights1_01
ci_camera1_01
ci_flatprop01
ci_flatprop02
ci_fountain
ci_industrial1
ci_lander
ci_lights1_01
ci_manintstuff
ci_mansion1
ci_offices
ci_redhead1_01
ci_setshad1
ci_tankship
ci_watertank
ci_windmach
cl_curtains
cl_tbl_chait_tmp
cl_tbl_chait_tmpb

View file

@ -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<void>(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<int32_t*>(ScriptSpace+800);
*trafficcone_counter = 0;
// Correct the final trafficcone_counter in Cone Coil
// 23 -> 30
*coneCoilConeCount.get(0).get<int8_t>(3) = 30;
// Correct the final trafficcone_counter in Burn and Lap
// 35 -> 42
*burnAndLapConeCount.get(0).get<int8_t>(3) = 42;
}
}
@ -3210,6 +3222,30 @@ namespace NitrousReverseRechargeFix
}
// ============= Fix Hydra's jet thrusters not displaying due to an uninitialized variable in RwMatrix =============
// By B1ack_Wh1te
namespace JetThrustersFix
{
// These are technically CMatrix, but for simplicity we use RwMatrix here
template<std::size_t Index>
static RwMatrix* (*orgMatrixMultiply)(RwMatrix* out, const RwMatrix* lhs, const RwMatrix* rhs);
template<std::size_t Index>
static RwMatrix* MatrixMultiply_ZeroFlags(RwMatrix* out, const RwMatrix* lhs, const RwMatrix* rhs)
{
RwMatrix* result = orgMatrixMultiply<Index>(out, lhs, rhs);
// Technically, this should be the same as RwMatrixUpdate, but this variable is on the stack
// and completely uninitialized, so zero it completely for consistent results.
rwMatrixSetFlags(result, 0);
return result;
}
HOOK_EACH_INIT(MatrixMultiply, orgMatrixMultiply, MatrixMultiply_ZeroFlags);
}
// ============= LS-RP Mode stuff =============
namespace LSRPMode
{
@ -6411,6 +6447,16 @@ void Patch_SA_10(HINSTANCE hInstance)
}
// Fix Hydra's jet thrusters not displaying due to an uninitialized variable in RwMatrix
// By B1ack_Wh1te
{
using namespace JetThrustersFix;
std::array<uintptr_t, 4> matrixMult = { 0x6CA09F, 0x6CA122, 0x6CA1B2, 0x6CA242 };
HookEach_MatrixMultiply(matrixMult, InterceptCall);
}
#if FULL_PRECISION_D3D
// Test - full precision D3D device
Patch<uint8_t>( 0x7F672B+1, *(uint8_t*)(0x7F672B+1) | D3DCREATE_FPU_PRESERVE );
@ -8591,6 +8637,25 @@ void Patch_SA_NewBinaries_Common(HINSTANCE hInstance)
InjectHook(getGasPedal.get<void>(1), &NitrousControl_DontRechargeWhenReversing_NewBinaries, HookType::Call);
}
TXN_CATCH();
// Fix Hydra's jet thrusters not displaying due to an uninitialized variable in RwMatrix
// By B1ack_Wh1te
try
{
using namespace JetThrustersFix;
auto thrust = pattern("D9 5D DC E8 ? ? ? ? 83 C4 0C").count(4);
std::array<void*, 4> matrixMult = {
thrust.get(0).get<void>(3),
thrust.get(1).get<void>(3),
thrust.get(2).get<void>(3),
thrust.get(3).get<void>(3),
};
HookEach_MatrixMultiply(matrixMult, InterceptCall);
}
TXN_CATCH();
}