diff --git a/SilentPatch/Common.cpp b/SilentPatch/Common.cpp index 4d5bf81..a1fb2e8 100644 --- a/SilentPatch/Common.cpp +++ b/SilentPatch/Common.cpp @@ -90,6 +90,19 @@ namespace TaxiCoronaFix } }; + +// ============= Reset requested extras if created vehicle has no extras ============= +namespace CompsToUseFix +{ + static int8_t* ms_compsUsed = *hook::get_pattern( "89 E9 88 1D", 4 ); + static int8_t* ms_compsToUse = *hook::get_pattern( "0F BE 05 ? ? ? ? 83 C4 28", 3 ); + static void ResetCompsForNoExtras() + { + ms_compsUsed[0] = ms_compsUsed[1] = -1; + ms_compsToUse[0] = ms_compsToUse[1] = -2; + } +}; + // ============= Delayed patches ============= namespace DelayedPatches { @@ -226,6 +239,16 @@ namespace Common { InjectHook( match.get(), GetTransformedCoronaPos ); } } + + + // Reset requested extras if created vehicle has no extras + { + using namespace CompsToUseFix; + + auto resetComps = pattern( "8B 04 24 83 C4 08 5D 5F" ).get_one(); + InjectHook( resetComps.get( -14 ), ResetCompsForNoExtras, PATCH_CALL ); + Nop( resetComps.get( -9 ), 9 ); + } } void III_VC_SetDelayedPatchesFunc( void(*func)() ) diff --git a/SilentPatchSA/ModelInfoSA.cpp b/SilentPatchSA/ModelInfoSA.cpp index 84e47e1..9a6e30c 100644 --- a/SilentPatchSA/ModelInfoSA.cpp +++ b/SilentPatchSA/ModelInfoSA.cpp @@ -17,6 +17,9 @@ bool (*CCustomCarPlateMgr::GeneratePlateText)(char* pBuf, int nLen); // Read fro CBaseModelInfo** const ms_modelInfoPtrs = *AddressByVersion(0x509CB1, 0x4C0C96, 0x403DB7); +int8_t* CVehicleModelInfo::ms_compsUsed = *AddressByVersion( 0x4C973B + 2, 0, 0 ); +int8_t* CVehicleModelInfo::ms_compsToUse = *AddressByVersion( 0x4C8057 + 2, 0, 0 ); + static RwTexture** const ms_aDirtTextures = *AddressByVersion( 0x5D5DCC + 3, 0, 0x5F259C + 3 ); void RemapDirt( CVehicleModelInfo* modelInfo, uint32_t dirtID ) @@ -106,6 +109,12 @@ void CVehicleModelInfo::SetCarCustomPlate() CCustomCarPlateMgr::SetupClump(reinterpret_cast(pRwObject), m_apPlateMaterials); } +void CVehicleModelInfo::ResetCompsForNoExtras() +{ + ms_compsUsed[0] = ms_compsUsed[1] = -1; + ms_compsToUse[0] = ms_compsToUse[1] = -2; +} + void CCustomCarPlateMgr::PollPlates( RpClump* clump, PlateMaterialsData* materials ) { std::vector carplates; diff --git a/SilentPatchSA/ModelInfoSA.h b/SilentPatchSA/ModelInfoSA.h index 5e934ed..97de730 100644 --- a/SilentPatchSA/ModelInfoSA.h +++ b/SilentPatchSA/ModelInfoSA.h @@ -308,6 +308,11 @@ public: class CAnimBlock* m_pAnimBlock; public: + static int8_t* ms_compsUsed; + static int8_t* ms_compsToUse; + + static void ResetCompsForNoExtras(); + inline const char* GetCustomCarPlateText() { return m_plateText[0] ? m_plateText : nullptr; } diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 85c3b6d..07eecf1 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -4228,6 +4228,12 @@ void Patch_SA_10() } + // Reset requested extras if created vehicle has no extras + // Fixes eg. lightless taxis + InjectHook( 0x4C97B1, CVehicleModelInfo::ResetCompsForNoExtras, PATCH_CALL ); + Nop( 0x4C97B1 + 5, 9 ); + + #if FULL_PRECISION_D3D // Test - full precision D3D device Patch( 0x7F672B+1, *(uint8_t*)(0x7F672B+1) | D3DCREATE_FPU_PRESERVE ); diff --git a/SilentPatchSA/VehicleSA.h b/SilentPatchSA/VehicleSA.h index 83c1911..6f2c770 100644 --- a/SilentPatchSA/VehicleSA.h +++ b/SilentPatchSA/VehicleSA.h @@ -389,7 +389,7 @@ private: uint16_t m_carMods[15]; uint8_t m_colour[4]; uint8_t m_radioStation; - uint8_t m_extra[2]; + int8_t m_extra[2]; uint8_t m_bombType; uint8_t m_remapIndex; uint8_t m_nitro;