Exemple #1
0
//=========================================================
// Initialize - clears all sounds and moves them into the 
// free sound list.
//=========================================================
void CSoundEnt::Initialize ( void )
{
  	int i;
	int iSound;

	m_cLastActiveSounds;
	m_iFreeSound = 0;
	m_iActiveSound = SOUNDLIST_EMPTY;

	for ( i = 0 ; i < MAX_WORLD_SOUNDS ; i++ )
	{// clear all sounds, and link them into the free sound list.
		m_SoundPool[ i ].Clear();
		m_SoundPool[ i ].m_iNext = i + 1;
	}

	m_SoundPool[ i - 1 ].m_iNext = SOUNDLIST_EMPTY;// terminate the list here.

	
	// now reserve enough sounds for each client
	for ( i = 0 ; i < gpGlobals->maxClients ; i++ )
	{
		iSound = IAllocSound();

		if ( iSound == SOUNDLIST_EMPTY )
		{
			DevMsg( "Could not AllocSound() for Client Reserve! (DLL)\n" );
			return;
		}

		m_SoundPool[ iSound ].m_bNoExpirationTime = true;
	}
}
Exemple #2
0
//---------------------------------------------------------
//---------------------------------------------------------
int CSoundEnt::FindOrAllocateSound( CBaseEntity *pOwner, int soundChannelIndex )
{
	int iSound = m_iActiveSound; 

	while ( iSound != SOUNDLIST_EMPTY )
	{
		CSound &sound = m_SoundPool[iSound];
		
		if ( sound.m_ownerChannelIndex == soundChannelIndex && sound.m_hOwner == pOwner )
		{
			return iSound;
		}

		iSound = sound.m_iNext;
	}

	return IAllocSound();
}
Exemple #3
0
//=========================================================
// Initialize - clears all sounds and moves them into the 
// free sound list.
//=========================================================
void CSoundEnt::Initialize ( void )
{
  	int i;
	int iSound;

	m_cLastActiveSounds;
	m_iFreeSound = 0;
	m_iActiveSound = SOUNDLIST_EMPTY;

	// In SP, we should only use the first 64 slots so save/load works right.
	// In MP, have one for each player and 32 extras.
	int nTotalSoundsInPool = MAX_WORLD_SOUNDS_SP;
	if ( gpGlobals->maxClients > 1 )
		nTotalSoundsInPool = MIN( MAX_WORLD_SOUNDS_MP, gpGlobals->maxClients + 32 );

	if ( gpGlobals->maxClients+16 > nTotalSoundsInPool )
	{
		Warning( "CSoundEnt pool is low on sounds due to high number of clients.\n" );
	}

	for ( i = 0 ; i < nTotalSoundsInPool ; i++ )
	{
		// clear all sounds, and link them into the free sound list.
		m_SoundPool[ i ].Clear();
		m_SoundPool[ i ].m_iNext = i + 1;
	}

	m_SoundPool[ i - 1 ].m_iNext = SOUNDLIST_EMPTY;// terminate the list here.

	
	// now reserve enough sounds for each client
	for ( i = 0 ; i < gpGlobals->maxClients ; i++ )
	{
		iSound = IAllocSound();

		if ( iSound == SOUNDLIST_EMPTY )
		{
			DevMsg( "Could not AllocSound() for Client Reserve! (DLL)\n" );
			return;
		}

		m_SoundPool[ iSound ].m_bNoExpirationTime = true;
	}
}