Fix client-side entities playing some sounds incorrectly

This commit is contained in:
Thomas Kain 2025-03-03 15:28:38 -05:00
parent aea94b32cb
commit 324be193c9

View file

@ -1138,7 +1138,16 @@ void CBaseEntity::EmitSound( const char *soundname, float soundtime /*= 0.0f*/,
params.m_pflSoundDuration = duration;
params.m_bWarnOnDirectWaveReference = true;
EmitSound( filter, entindex(), params );
int iEntIndex = entindex();
#if defined( CLIENT_DLL )
if ( iEntIndex == -1 )
{
// If we're a clientside entity, we need to use the soundsourceindex instead of the entindex
iEntIndex = GetSoundSourceIndex();
}
#endif
EmitSound( filter, iEntIndex, params );
}
#if !defined ( CLIENT_DLL )
@ -1177,7 +1186,16 @@ void CBaseEntity::EmitSound( const char *soundname, HSOUNDSCRIPTHANDLE& handle,
params.m_pflSoundDuration = duration;
params.m_bWarnOnDirectWaveReference = true;
EmitSound( filter, entindex(), params, handle );
int iEntIndex = entindex();
#if defined( CLIENT_DLL )
if ( iEntIndex == -1 )
{
// If we're a clientside entity, we need to use the soundsourceindex instead of the entindex
iEntIndex = GetSoundSourceIndex();
}
#endif
EmitSound( filter, iEntIndex, params, handle );
}
//-----------------------------------------------------------------------------