Permalink
Browse files

Add parameter to setWorldSoundEnabled to stop sound immediately (#9490)

  • Loading branch information...
Necktrox committed Feb 20, 2018
1 parent 187eb31 commit 44844590d35cf52a1c1bf4e4c659c4dfbe2372fb
@@ -123,9 +123,6 @@
#define VAR_CAEVehicleAudioEntity__s_pPlayerDriver 0xB6B990
#define FUNC_CAESoundManager__CancelSoundsInBankSlot 0x4EFC60
#define VAR_pAESoundManager 0xB62CB0
struct tVehicleAudioSettings
{
char m_nVehicleSoundType;
@@ -17,10 +17,15 @@
DWORD RETURN_CAEAmbienceTrackManager_CheckForPause = 0x4D6E27;
void HOOK_CAEAmbienceTrackManager_CheckForPause ();
#define HOOKPOS_CAESoundManager_RequestNewSound 0x4EFB10
DWORD RETURN_CAESoundManager_RequestNewSound = 0x4EFB15;
#define HOOKPOS_CAESoundManager_RequestNewSound 0x4EFB10
DWORD RETURN_CAESoundManager_RequestNewSound = 0x4EFB15;
void HOOK_CAESoundManager_RequestNewSound();
#define FUNC_CAESoundManager__CancelSoundsInBankSlot 0x4EFC60
#define VAR_pAESoundManager 0xB62CB0
class CAESoundManager;
CAudioEngineSA* g_pAudioSA = NULL;
CAudioEngineSA::CAudioEngineSA ( CAudioEngineSAInterface * pInterface )
@@ -463,16 +468,29 @@ void _declspec(naked) HOOK_CAEAmbienceTrackManager_CheckForPause ()
//
// uiIndex = -1 for all in group
void CAudioEngineSA::SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bEnabled )
void CAudioEngineSA::SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bEnabled, bool bForceCancel )
{
uint uiFirst = ( uiGroup << 8 ) + ( uiIndex != -1 ? uiIndex : 0 );
uint uiLast = ( uiGroup << 8 ) + ( uiIndex != -1 ? uiIndex : 255 );
if ( !bEnabled )
{
m_DisabledWorldSounds.SetRange ( uiFirst, uiLast - uiFirst + 1 );
if ( bForceCancel )
CancelSoundsInBankSlot ( uiGroup, uiIndex );
}
else
m_DisabledWorldSounds.UnsetRange ( uiFirst, uiLast - uiFirst + 1 );
}
static auto CancelSoundsInBankSlot ( uint uiGroup, uint uiIndex )
{
using CAESoundManager__CancelSoundsInBankSlot = CAESound * ( __thiscall * ) ( CAESoundManager *, uint, uint );
static auto pAESoundManager = reinterpret_cast < CAESoundManager * > ( VAR_pAESoundManager );
static auto pCancelSoundsInBankSlot = reinterpret_cast < CAESoundManager__CancelSoundsInBankSlot > ( FUNC_CAESoundManager__CancelSoundsInBankSlot );
return pCancelSoundsInBankSlot ( pAESoundManager, uiGroup, uiIndex );
}
// uiIndex = -1 for all in group
bool CAudioEngineSA::IsWorldSoundEnabled ( uint uiGroup, uint uiIndex )
{
@@ -568,4 +586,4 @@ void CAudioEngineSA::ReportWeaponEvent ( int iEvent, eWeaponType weaponType, CPh
push iEvent
call dwFunc
}
}
}
@@ -142,7 +142,7 @@ class CAudioEngineSA : public CAudioEngine
VOID SetAmbientSoundEnabled ( eAmbientSoundType eType, bool bEnabled );
bool IsAmbientSoundEnabled ( eAmbientSoundType eType );
void ResetAmbientSounds ( void );
VOID SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bEnabled );
VOID SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bEnabled, bool bForceCancel );
bool IsWorldSoundEnabled ( uint uiGroup, uint uiIndex );
void ResetWorldSounds ( void );
void SetWorldSoundHandler ( WorldSoundHandler * pHandler );
@@ -165,4 +165,4 @@ class CAudioEngineSA : public CAudioEngine
CAudioEngineSAInterface * m_pInterface;
};
#endif
#endif
@@ -4276,9 +4276,9 @@ bool CStaticFunctionDefinitions::ResetAmbientSounds ( void )
}
bool CStaticFunctionDefinitions::SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bMute )
bool CStaticFunctionDefinitions::SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bMute, bool bForceCancel )
{
g_pGame->GetAudio ()->SetWorldSoundEnabled ( uiGroup, uiIndex, bMute );
g_pGame->GetAudio ()->SetWorldSoundEnabled ( uiGroup, uiIndex, bMute, bForceCancel );
return true;
}
@@ -334,7 +334,7 @@ class CStaticFunctionDefinitions
static bool SetAmbientSoundEnabled ( eAmbientSoundType eType, bool bMute );
static bool IsAmbientSoundEnabled ( eAmbientSoundType eType, bool& bOutMute );
static bool ResetAmbientSounds ( void );
static bool SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bMute );
static bool SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bMute, bool bForceCancel );
static bool IsWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool& bOutMute );
static bool ResetWorldSounds ( void );
static bool PlaySFX ( CResource* pResource, eAudioLookupIndex containerIndex, int iBankIndex, int iAudioIndex, bool bLoop, CClientSound*& outSound );
@@ -1431,18 +1431,19 @@ int CLuaAudioDefs::ResetAmbientSounds ( lua_State* luaVM )
int CLuaAudioDefs::SetWorldSoundEnabled ( lua_State* luaVM )
{
// setWorldSoundEnabled ( int group, [int index, ], bool enable )
int group; int index = -1; bool bEnabled;
// setWorldSoundEnabled ( int group, [int index, ], bool enable [, bool forceCancel = false ] )
int group; int index = -1; bool bEnabled; bool bForceCancel;
CScriptArgReader argStream ( luaVM );
argStream.ReadNumber ( group );
if ( !argStream.NextIsBool () )
argStream.ReadNumber ( index );
argStream.ReadBool ( bEnabled );
argStream.ReadBool ( bForceCancel, false );
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::SetWorldSoundEnabled ( group, index, bEnabled ) )
if ( CStaticFunctionDefinitions::SetWorldSoundEnabled ( group, index, bEnabled, bForceCancel ) )
{
lua_pushboolean ( luaVM, true );
return 1;
@@ -57,12 +57,12 @@ class CAudioEngine
virtual VOID SetAmbientSoundEnabled ( eAmbientSoundType eType, bool bEnabled ) = 0;
virtual bool IsAmbientSoundEnabled ( eAmbientSoundType eType ) = 0;
virtual void ResetAmbientSounds ( void ) = 0;
virtual VOID SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bEnabled ) = 0;
virtual VOID SetWorldSoundEnabled ( uint uiGroup, uint uiIndex, bool bEnabled, bool bForceCancel ) = 0;
virtual bool IsWorldSoundEnabled ( uint uiGroup, uint uiIndex ) = 0;
virtual void ResetWorldSounds ( void ) = 0;
virtual void SetWorldSoundHandler ( WorldSoundHandler * pHandler ) = 0;
virtual void ReportBulletHit ( CEntity * pEntity, unsigned char ucSurfaceType, CVector * pvecPosition, float f_2 ) = 0;
virtual void ReportWeaponEvent ( int iEvent, eWeaponType weaponType, CPhysical * pPhysical ) = 0;
};
#endif
#endif

0 comments on commit 4484459

Please sign in to comment.