diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index dbf11ce..fdaf4ab 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -2117,6 +2117,22 @@ namespace GetCorrectPedModel_Lapdm1 } +// ============= Only allow impounding cars and bikes (and their subclasses), as impounding helicopters, planes, boats makes no sense ============= +namespace RestrictImpoundVehicleTypes +{ + template + static bool (*orgIsThisVehicleInteresting)(CVehicle* vehicle); + + template + static bool IsThisVehicleInteresting_AndCanBeImpounded(CVehicle* vehicle) + { + return vehicle->CanThisVehicleBeImpounded() && orgIsThisVehicleInteresting(vehicle); + } + + HOOK_EACH_FUNC(ShouldImpound, orgIsThisVehicleInteresting, IsThisVehicleInteresting_AndCanBeImpounded) +} + + // ============= LS-RP Mode stuff ============= namespace LSRPMode { @@ -4796,6 +4812,14 @@ void Patch_SA_10(HINSTANCE hInstance) } + // Only allow impounding cars and bikes (and their subclasses), as impounding helicopters, planes, boats makes no sense + { + using namespace RestrictImpoundVehicleTypes; + + std::array isThisVehicleInteresting = { 0x566794, 0x56A378 }; + HookEach_ShouldImpound(isThisVehicleInteresting, InterceptCall); + } + #if FULL_PRECISION_D3D // Test - full precision D3D device Patch( 0x7F672B+1, *(uint8_t*)(0x7F672B+1) | D3DCREATE_FPU_PRESERVE ); @@ -6417,6 +6441,19 @@ void Patch_SA_NewBinaries_Common(HINSTANCE hInstance) Patch(jumpTablePtr+4, &BikerCop_Steam); } } + + + // Only allow impounding cars and bikes (and their subclasses), as impounding helicopters, planes, boats makes no sense + { + using namespace RestrictImpoundVehicleTypes; + + auto isThisVehicleInteresting_pattern = pattern("56 E8 ? ? ? ? 83 C4 04 84 C0 74 09 56 E8 ? ? ? ? 83 C4 04 56").count(2); + std::array isThisVehicleInteresting = { + isThisVehicleInteresting_pattern.get(0).get(1), + isThisVehicleInteresting_pattern.get(1).get(1), + }; + HookEach_ShouldImpound(isThisVehicleInteresting, InterceptCall); + } } diff --git a/SilentPatchSA/VehicleSA.cpp b/SilentPatchSA/VehicleSA.cpp index fd448ca..3f7a0da 100644 --- a/SilentPatchSA/VehicleSA.cpp +++ b/SilentPatchSA/VehicleSA.cpp @@ -362,6 +362,13 @@ CPed* CVehicle::PickRandomPassenger() return nullptr; } +bool CVehicle::CanThisVehicleBeImpounded() const +{ + const bool bIsBike = m_dwVehicleClass == VEHICLE_BIKE; + const bool bIsCar = m_dwVehicleClass == VEHICLE_AUTOMOBILE && m_dwVehicleSubClass != VEHICLE_HELI && m_dwVehicleSubClass != VEHICLE_PLANE && m_dwVehicleSubClass != VEHICLE_TRAILER; + return bIsCar || bIsBike; +} + int32_t CVehicle::GetRemapIndex() { int32_t remapTxd = m_remapTxdSlot.Get(); diff --git a/SilentPatchSA/VehicleSA.h b/SilentPatchSA/VehicleSA.h index d0fdcb9..de799be 100644 --- a/SilentPatchSA/VehicleSA.h +++ b/SilentPatchSA/VehicleSA.h @@ -267,6 +267,7 @@ public: bool IsLawEnforcementVehicle(); CPed* PickRandomPassenger(); + bool CanThisVehicleBeImpounded() const; int32_t GetRemapIndex();