From de60ad587cbb608383b5ee951b0e4230d1d96b8a Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 8 Dec 2019 19:33:04 +0100 Subject: [PATCH] III: Corrected FBI Car secondary siren sound --- SilentPatchIII/SilentPatchIII.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index ffb9e7c..0d26fe6 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -485,7 +485,19 @@ namespace AudioInitializedFix orgLoadAllAudioScriptObjects( buffer, a2 ); } } -} +}; + + +// ============= Corrected FBI Car secondary siren sound ============= +namespace SirenSwitchingFix +{ + static bool (__thiscall *orgUsesSirenSwitching)(void* pThis, unsigned int index); + static bool __fastcall UsesSirenSwitching_FbiCar( void* pThis, void*, unsigned int index ) + { + // index 17 = FBICAR + return index == 17 || orgUsesSirenSwitching( pThis, index ); + } +}; void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModulePath ) { @@ -514,6 +526,21 @@ void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModul Patch( canPickBlista.get_first( 2 ), 127 ); // coach } } + + + // Corrected FBI Car secondary siren sound + { + using namespace SirenSwitchingFix; + + // Other mods might be touching it, so only patch specific vehicles if their code has not been touched at all + auto usesSirenSwitching = pattern( "E8 ? ? ? ? 84 C0 74 12 83 C4 08" ).count_hint(1); + if ( usesSirenSwitching.size() == 1 ) + { + auto match = usesSirenSwitching.get_one(); + ReadCall( match.get(), orgUsesSirenSwitching ); + InjectHook( match.get(), UsesSirenSwitching_FbiCar ); + } + } } void InjectDelayedPatches_III_Common()