game_shared/SoundEmitterSystem.cpp
504505506507508509
params.volume = ep.m_flVolume;
}
#if !defined( CLIENT_DLL )
bool bSwallowed = CEnvMicrophone::OnSoundPlayed(
entindex,
504505506507508509510511512513514515
params.volume = ep.m_flVolume;
}
// needed for ac rev sound to play at the same time as ac loop shot sound - Jon
if( ep.m_nFlags & SND_CHANGE_CHAN )
{
params.channel = ep.m_nChannel;
}
#if !defined( CLIENT_DLL )
bool bSwallowed = CEnvMicrophone::OnSoundPlayed(
entindex,
558559560561562563564
// Don't caption modulations to the sound
if ( !( ep.m_nFlags & ( SND_CHANGE_PITCH | SND_CHANGE_VOL ) ) )
{
EmitCloseCaption( filter, entindex, params, ep );
}
564565566567568569570
// Don't caption modulations to the sound
if ( !( ep.m_nFlags & ( SND_CHANGE_PITCH | SND_CHANGE_VOL | SND_CHANGE_CHAN ) ) )
{
EmitCloseCaption( filter, entindex, params, ep );
}
903904905906907908909
StopSoundByHandle( entindex, soundname, (HSOUNDSCRIPTHANDLE &)soundindex );
}
void StopSound( int iEntIndex, int iChannel, const char *pSample )
{
if ( pSample && ( Q_stristr( pSample, ".wav" ) || Q_stristr( pSample, ".mp3" ) || pSample[0] == '!' ) )
909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
StopSoundByHandle( entindex, soundname, (HSOUNDSCRIPTHANDLE &)soundindex );
}
// Jon: so we can stop sounds in a specific channel that's different from what the script defines
void StopSoundInChannelByHandle( int entindex, const char *soundname, HSOUNDSCRIPTHANDLE& handle, const int channel )
{
if ( handle == SOUNDEMITTER_INVALID_HANDLE )
{
handle = (HSOUNDSCRIPTHANDLE)soundemitterbase->GetSoundIndex( soundname );
}
if ( handle == SOUNDEMITTER_INVALID_HANDLE )
return;
CSoundParametersInternal *params;
params = soundemitterbase->InternalGetParametersForSound( (int)handle );
if ( !params )
{
return;
}
// HACK: we have to stop all sounds if there are > 1 in the rndwave section...
int c = params->NumSoundNames();
for ( int i = 0; i < c; ++i )
{
char const *wavename = soundemitterbase->GetWaveName( params->GetSoundNames()[ i ].symbol );
Assert( wavename );
enginesound->StopSound(
entindex,
channel,
wavename );
TraceEmitSound( "StopSound: '%s' stopped as '%s' (ent %i)\n",
soundname, wavename, entindex );
}
}
// Jon: so we can stop sounds in a specific channel that's different from what the script defines
void StopSoundInChannel( int entindex, const char *soundname, const int channel )
{
int soundindex = soundemitterbase->GetSoundIndex( soundname );
if ( soundindex == -1 )
{
return;
}
StopSoundInChannelByHandle( entindex, soundname, (HSOUNDSCRIPTHANDLE &)soundindex, channel );
}
void StopSound( int iEntIndex, int iChannel, const char *pSample )
{
if ( pSample && ( Q_stristr( pSample, ".wav" ) || Q_stristr( pSample, ".mp3" ) || pSample[0] == '!' ) )
974975976977978979980
#if defined( CLIENT_DLL )
CON_COMMAND( cl_soundemitter_flush, "Flushes the sounds.txt system (client only)" )
#else
CON_COMMAND( sv_soundemitter_flush, "Flushes the sounds.txt system (server only)" )
#endif
{
// save the current soundscape
1028102910301031103210331034
#if defined( CLIENT_DLL )
CON_COMMAND( cl_soundemitter_flush, "Flushes the sounds.txt system (client only)" )
#else
CON_COMMAND_F( sv_soundemitter_flush, "Flushes the sounds.txt system (server only)", FCVAR_CHEAT )
#endif
{
// save the current soundscape
1002100310041005100610071008100910101011101210131014
#if !defined( _XBOX )
CON_COMMAND( sv_soundemitter_filecheck, "Report missing wave files for sounds and game_sounds files." )
{
int missing = soundemitterbase->CheckForMissingWavFiles( true );
DevMsg( "---------------------------\nTotal missing files %i\n", missing );
}
CON_COMMAND( sv_findsoundname, "Find sound names which reference the specified wave files." )
{
if ( engine->Cmd_Argc() != 2 )
return;
1056105710581059106010611062106310641065106610671068
#if !defined( _XBOX )
CON_COMMAND_F( sv_soundemitter_filecheck, "Report missing wave files for sounds and game_sounds files.", FCVAR_CHEAT )
{
int missing = soundemitterbase->CheckForMissingWavFiles( true );
DevMsg( "---------------------------\nTotal missing files %i\n", missing );
}
CON_COMMAND_F( sv_findsoundname, "Find sound names which reference the specified wave files.", FCVAR_CHEAT )
{
if ( engine->Cmd_Argc() != 2 )
return;
111811191120112111221123
// Purpose: Non-static override for doing the general case of CPASAttenuationFilter( this ), and EmitSound( filter, entindex(), etc. );
// Input : *soundname -
//-----------------------------------------------------------------------------
void CBaseEntity::EmitSound( const char *soundname, float soundtime /*= 0.0f*/, float *duration /*=NULL*/ )
{
//VPROF( "CBaseEntity::EmitSound" );
1172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
// Purpose: Non-static override for doing the general case of CPASAttenuationFilter( this ), and EmitSound( filter, entindex(), etc. );
// Input : *soundname -
//-----------------------------------------------------------------------------
void CBaseEntity::EmitSoundShared( const char *soundname, float soundtime /*= 0.0f*/, float *duration /*=NULL*/ )
{
//VPROF( "CBaseEntity::EmitSound" );
VPROF_BUDGET( "CBaseEntity::EmitSound", _T( "CBaseEntity::EmitSound" ) );
CPASAttenuationFilter filter( this, soundname );
#ifdef GAME_DLL
// FF: AfterShock: Don't send to self. This fixes clientside prediction on sounds and means we can just do 1 shared EmitSound(bla)
if (gpGlobals->maxClients > 1)
{
CBasePlayer *pPlayer = ToBasePlayer( this );
if ( pPlayer )
filter.RemoveRecipient(pPlayer);
}
#endif
EmitSound_t params;
params.m_pSoundName = soundname;
params.m_flSoundTime = soundtime;
params.m_pflSoundDuration = duration;
params.m_bWarnOnDirectWaveReference = true;
EmitSound( filter, entindex(), params );
}
//-----------------------------------------------------------------------------
// Purpose: Non-static override for doing the general case of CPASAttenuationFilter( this ), and EmitSound( filter, entindex(), etc. );
// Input : *soundname -
//-----------------------------------------------------------------------------
void CBaseEntity::EmitSound( const char *soundname, float soundtime /*= 0.0f*/, float *duration /*=NULL*/ )
{
//VPROF( "CBaseEntity::EmitSound" );
126412651266126712681269
g_SoundEmitterSystem.StopSoundByHandle( entindex(), soundname, handle );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : iEntIndex -
134913501351135213531354135513561357135813591360136113621363136413651366136713681369
g_SoundEmitterSystem.StopSoundByHandle( entindex(), soundname, handle );
}
// Jon: so we can stop sounds in a specific channel that's different from what the script defines
void CBaseEntity::StopSoundInChannel( const char *soundname, HSOUNDSCRIPTHANDLE& handle, const int channel )
{
#if defined( CLIENT_DLL )
if ( entindex() == -1 )
{
// If we're a clientside entity, we need to use the soundsourceindex instead of the entindex
StopSoundInChannel( GetSoundSourceIndex(), soundname, channel );
return;
}
#endif
g_SoundEmitterSystem.StopSoundInChannelByHandle( entindex(), soundname, handle, channel );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : iEntIndex -
127412751276127712781279
g_SoundEmitterSystem.StopSound( iEntIndex, soundname );
}
void CBaseEntity::StopSound( int iEntIndex, int iChannel, const char *pSample )
{
g_SoundEmitterSystem.StopSound( iEntIndex, iChannel, pSample );
137413751376137713781379138013811382138313841385
g_SoundEmitterSystem.StopSound( iEntIndex, soundname );
}
// Jon: so we can stop sounds in a specific channel that's different from what the script defines
void CBaseEntity::StopSoundInChannel( int iEntIndex, const char *soundname, const int channel )
{
g_SoundEmitterSystem.StopSoundInChannel( iEntIndex, soundname, channel );
}
void CBaseEntity::StopSound( int iEntIndex, int iChannel, const char *pSample )
{
g_SoundEmitterSystem.StopSound( iEntIndex, iChannel, pSample );