コード例 #1
0
ファイル: vsound.cpp プロジェクト: LivingInPortal/sourcemod
bool InternalPrecacheScriptSound(const char *soundname)
{
	int soundIndex = soundemitterbase->GetSoundIndex(soundname);
	if (!soundemitterbase->IsValidIndex(soundIndex))
	{
		return false;
	}

	CSoundParametersInternal *internal = soundemitterbase->InternalGetParametersForSound(soundIndex);

	if (!internal)
		return false;

	int waveCount = internal->NumSoundNames();

	if (!waveCount)
	{
		return false;
	}

	for (int wave = 0; wave < waveCount; wave++)
	{
		const char* waveName = soundemitterbase->GetWaveName(internal->GetSoundNames()[wave].symbol);
		// return true even if we precache no new wavs
		if (!engsound->IsSoundPrecached(waveName))
		{
			engsound->PrecacheSound(waveName);
		}
	}

	return true;
}
コード例 #2
0
	void StopSoundByHandle( int entindex, const char *soundname, HSOUNDSCRIPTHANDLE& handle )
	{
		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, 
				params->GetChannel(), 
				wavename );

			TraceEmitSound( "StopSound:  '%s' stopped as '%s' (ent %i)\n",
				soundname, wavename, entindex );
		}
	}
コード例 #3
0
bool CSoundParametersInternal::operator == ( const CSoundParametersInternal& other ) const
{
	if ( this == &other )
		return true;

	if ( channel != other.channel )
		return false;
	if ( !CompareInterval( volume, other.volume ) )
		return false;
	if ( !CompareInterval( pitch, other.pitch ) )
		return false;
	if ( !CompareInterval( soundlevel, other.soundlevel ) )
		return false;
	if ( delay_msec != other.delay_msec )
		return false;
	if ( play_to_owner_only != other.play_to_owner_only )
		return false;

	if ( m_nSoundNames != other.m_nSoundNames )
		return false;

	// Compare items
	int c = m_nSoundNames;
	for ( int i = 0; i < c; i++ )
	{
		if ( GetSoundNames()[ i ].symbol != other.GetSoundNames()[ i ].symbol )
			return false;
	}

	return true;
}
コード例 #4
0
ファイル: gameui.cpp プロジェクト: Au-heppa/swarm-sdk
//-----------------------------------------------------------------------------
// Precaches all game UI sounds
//-----------------------------------------------------------------------------
void CGameUIGameSystem::PrecacheGameUISounds()
{
	// Precache all UI sounds. These must exist in the game_sounds_ui.txt script file
	KeyValues *pUIGameSounds = new KeyValues( "Game Instructor Counts" );
	if ( !pUIGameSounds->LoadFromFile( g_pFullFileSystem, "scripts/game_sounds_ui.txt", "GAME" ) )
	{
		pUIGameSounds->deleteThis();
		return;
	}

	for ( KeyValues *pKey = pUIGameSounds; pKey; pKey = pKey->GetNextKey() )
	{
		const char *pSoundName = pKey->GetName();
		int nSoundIndex = soundemitterbase->GetSoundIndex( pSoundName );
		if ( !soundemitterbase->IsValidIndex( nSoundIndex ) )
		{
			Log_Warning( LOG_GameUI, "GameUI: Unable to precache gamesound \"%s\"\n", pSoundName );
			continue;
		}

		CSoundParametersInternal *pInternal = soundemitterbase->InternalGetParametersForSound( nSoundIndex );
		if ( !pInternal )
		{
			Log_Warning( LOG_GameUI, "GameUI: Unable to precache gamesound \"%s\"\n", pSoundName );
			continue;
		}

		int nWaveCount = pInternal->NumSoundNames();
		if ( !nWaveCount )
		{
			Log_Warning( LOG_GameUI, "GameUI: game_sounds_ui.txt entry '%s' has no waves listed under 'wave' or 'rndwave' key!!!\n", pSoundName );
			continue;
		}

		for( int nWave = 0; nWave < nWaveCount; ++nWave )
		{
			const char *pWavName = soundemitterbase->GetWaveName( pInternal->GetSoundNames()[ nWave ].symbol );
			enginesound->PrecacheSound( pWavName, true, true );
		}
	}
	pUIGameSounds->deleteThis();
}
コード例 #5
0
	void InternalPrefetchWaves( int soundIndex )
	{
		CSoundParametersInternal *internal = soundemitterbase->InternalGetParametersForSound( soundIndex );
		if ( !internal )
			return;

		int waveCount = internal->NumSoundNames();
		if ( !waveCount )
		{
			DevMsg( "CSoundEmitterSystem:  sounds.txt entry '%s' has no waves listed under 'wave' or 'rndwave' key!!!\n",
				soundemitterbase->GetSoundName( soundIndex ) );
		}
		else
		{
			for( int wave = 0; wave < waveCount; wave++ )
			{
				CBaseEntity::PrefetchSound( soundemitterbase->GetWaveName( internal->GetSoundNames()[ wave ].symbol ) );
			}
		}
	}