@@ -413,31 +413,29 @@ void CAudioEngineSA::UpdateAmbientSoundSettings()
413413 MemPut<BYTE>(0x507814 , 0x33 ); // No gunfire
414414}
415415
416- __declspec (noinline) bool _cdecl IsAmbientSoundGeneralEnabled()
416+ static bool IsAmbientSoundGeneralEnabled ()
417417{
418- if (pGame)
419- {
420- return pGame->GetAudioEngine ()->IsAmbientSoundEnabled (AMBIENT_SOUND_GENERAL);
421- }
422- return false ;
418+ return pGame && pGame->GetAudioEngine ()->IsAmbientSoundEnabled (AMBIENT_SOUND_GENERAL);
423419}
424420
425421// Hook for manual ambient sound pause
426- void __declspec (naked) HOOK_CAEAmbienceTrackManager_CheckForPause()
422+ static void __declspec (naked) HOOK_CAEAmbienceTrackManager_CheckForPause()
427423{
424+ MTA_VERIFY_HOOK_LOCAL_SIZE;
425+
428426 __asm
429427 {
430- // Hooked from 004D6E21 6 bytes
431- call IsAmbientSoundGeneralEnabled
432- test al, al
433- jnz skip
434- mov dword ptr [esp+08h ], 0 // Pause
435- skip:
436-
437- // orig
438- mov edi, [esp+08h ]
428+ push esi
429+ call IsAmbientSoundGeneralEnabled
430+ test al, al
431+ jnz continueWithOriginalCode
432+ mov dword ptr [esp+8 ], 0 // Pause by setting 0.0f for the last argument to CAEAudioHardware::SetChannelFrequencyScalingFactor
433+
434+ continueWithOriginalCode:
435+ pop esi
436+ mov edi, [esp+8 ]
439437 xor ecx, ecx
440- jmp RETURN_CAEAmbienceTrackManager_CheckForPause // 4D6E27
438+ jmp RETURN_CAEAmbienceTrackManager_CheckForPause
441439 }
442440}
443441
@@ -506,33 +504,34 @@ bool CAudioEngineSA::OnWorldSound(CAESound* pAESound)
506504
507505// //////////////////////////////////////////////////////////////////////////////////////////////
508506// Return false to skip sound
509- __declspec (noinline) bool _cdecl On_CAESoundManager_RequestNewSound (CAESound* pAESound)
507+ static bool _cdecl OnRequestNewSound (CAESound* pAESound)
510508{
511509 return g_pAudioSA->OnWorldSound (pAESound);
512510}
513511
514- void __declspec (naked) HOOK_CAESoundManager_RequestNewSound()
512+ static void __declspec (naked) HOOK_CAESoundManager_RequestNewSound()
515513{
514+ MTA_VERIFY_HOOK_LOCAL_SIZE;
515+
516516 __asm
517517 {
518518 pushad
519519 push [esp+32 +4 *1 ]
520- call On_CAESoundManager_RequestNewSound
521- add esp, 4 *1
522- cmp al, 0
523- jz skip
520+ call OnRequestNewSound
521+ add esp, 4
522+ test al, al
524523 popad
524+ jnz continueWithOriginalCode
525525
526- // Continue with standard code
526+ // Skip playing sound
527+ xor eax, eax
528+ retn 4
529+
530+ continueWithOriginalCode:
527531 push esi
528532 push edi
529533 xor esi, esi
530534 jmp RETURN_CAESoundManager_RequestNewSound
531-
532- skip: // Skip playing sound
533- popad
534- xor eax, eax
535- retn 4
536535 }
537536}
538537
0 commit comments