mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-13 04:09:09 +00:00
add source-sdk-2013
This commit is contained in:
+15
-80
@@ -159,8 +159,6 @@ class CAmbientGeneric : public CPointEntity
|
||||
public:
|
||||
DECLARE_CLASS( CAmbientGeneric, CPointEntity );
|
||||
|
||||
CAmbientGeneric();
|
||||
|
||||
bool KeyValue( const char *szKeyName, const char *szValue );
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
@@ -195,15 +193,10 @@ public:
|
||||
bool m_fActive; // only true when the entity is playing a looping sound
|
||||
bool m_fLooping; // true when the sound played will loop
|
||||
|
||||
char m_szSoundFile[MAX_PATH]; // Path/filename of WAV or MP3 file to play.
|
||||
string_t m_iszSound; // Path/filename of WAV file to play.
|
||||
string_t m_sSourceEntName;
|
||||
EHANDLE m_hSoundSource; // entity from which the sound comes
|
||||
int m_nSoundSourceEntIndex; // In case the entity goes away before we finish stopping the sound...
|
||||
|
||||
private:
|
||||
void ValidateSoundFile( void );
|
||||
string_t m_iszSound;
|
||||
string_t m_iszPrevSound; // track if the sound has changed and we need to re-Validate
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( ambient_generic, CAmbientGeneric );
|
||||
@@ -249,16 +242,6 @@ END_DATADESC()
|
||||
#define SF_AMBIENT_SOUND_NOT_LOOPING 32
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
CAmbientGeneric::CAmbientGeneric()
|
||||
{
|
||||
m_szSoundFile[0] = 0;
|
||||
m_iszSound = NULL_STRING;
|
||||
m_iszPrevSound = NULL_STRING;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Spawn
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -267,9 +250,8 @@ void CAmbientGeneric::Spawn( void )
|
||||
m_iSoundLevel = ComputeSoundlevel( m_radius, FBitSet( m_spawnflags, SF_AMBIENT_SOUND_EVERYWHERE )?true:false );
|
||||
ComputeMaxAudibleDistance( );
|
||||
|
||||
ValidateSoundFile();
|
||||
|
||||
if ( V_strlen( m_szSoundFile ) < 1 )
|
||||
char *szSoundFile = (char *)STRING( m_iszSound );
|
||||
if ( !m_iszSound || strlen( szSoundFile ) < 1 )
|
||||
{
|
||||
Warning( "Empty %s (%s) at %.2f, %.2f, %.2f\n", GetClassname(), GetDebugName(), GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z );
|
||||
UTIL_Remove(this);
|
||||
@@ -438,58 +420,14 @@ void CAmbientGeneric::InputFadeOut( inputdata_t &inputdata )
|
||||
}
|
||||
|
||||
|
||||
void CAmbientGeneric::ValidateSoundFile( void )
|
||||
{
|
||||
if ( m_iszSound == NULL_STRING )
|
||||
{
|
||||
m_iszPrevSound = NULL_STRING;
|
||||
m_szSoundFile[0] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_iszSound == m_iszPrevSound )
|
||||
return;
|
||||
|
||||
m_iszPrevSound = m_iszSound;
|
||||
|
||||
char *szSoundFile = (char *)STRING( m_iszSound );
|
||||
if ( V_strlen( szSoundFile ) < 1 )
|
||||
return;
|
||||
|
||||
char szPathTest[MAX_PATH] = { 0 };
|
||||
char szNewSoundFile[MAX_PATH] = { 0 };
|
||||
|
||||
// try to fix some legacy ambient generic entities that still use .wav file references for vo sounds instead of .mp3
|
||||
if ( V_strncmp( szSoundFile, "vo", 2 ) == 0 )
|
||||
{
|
||||
const char *pszExt = V_GetFileExtension( szSoundFile );
|
||||
if ( pszExt && pszExt[0] && FStrEq( pszExt, "wav" ) )
|
||||
{
|
||||
V_sprintf_safe( szPathTest, "sound/%s", szSoundFile );
|
||||
if ( !g_pFullFileSystem->FileExists( szPathTest ) )
|
||||
{
|
||||
V_strcpy_safe( szNewSoundFile, szSoundFile );
|
||||
V_SetExtension( szNewSoundFile, ".mp3", ARRAYSIZE( szNewSoundFile ) );
|
||||
V_sprintf_safe( szPathTest, "sound/%s", szNewSoundFile );
|
||||
if ( g_pFullFileSystem->FileExists( szPathTest ) )
|
||||
{
|
||||
szSoundFile = szNewSoundFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
V_strcpy_safe( m_szSoundFile, szSoundFile );
|
||||
}
|
||||
|
||||
|
||||
void CAmbientGeneric::Precache( void )
|
||||
{
|
||||
if ( V_strlen( m_szSoundFile ) > 1 )
|
||||
char *szSoundFile = (char *)STRING( m_iszSound );
|
||||
if ( m_iszSound != NULL_STRING && strlen( szSoundFile ) > 1 )
|
||||
{
|
||||
if ( m_szSoundFile[0] != '!' )
|
||||
if (*szSoundFile != '!')
|
||||
{
|
||||
PrecacheScriptSound( m_szSoundFile );
|
||||
PrecacheScriptSound(szSoundFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,10 +756,8 @@ void CAmbientGeneric::RampThink( void )
|
||||
CBaseEntity* pSoundSource = m_hSoundSource;
|
||||
if (pSoundSource)
|
||||
{
|
||||
ValidateSoundFile();
|
||||
|
||||
UTIL_EmitAmbientSound(pSoundSource->GetSoundSourceIndex(), pSoundSource->GetAbsOrigin(),
|
||||
m_szSoundFile, ( vol * 0.01 ), m_iSoundLevel, flags, pitch );
|
||||
STRING( m_iszSound ), (vol * 0.01), m_iSoundLevel, flags, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -941,19 +877,18 @@ void CAmbientGeneric::InputStopSound( inputdata_t &inputdata )
|
||||
|
||||
void CAmbientGeneric::SendSound( SoundFlags_t flags)
|
||||
{
|
||||
ValidateSoundFile();
|
||||
|
||||
char *szSoundFile = (char *)STRING( m_iszSound );
|
||||
CBaseEntity* pSoundSource = m_hSoundSource;
|
||||
if ( pSoundSource )
|
||||
{
|
||||
if ( flags == SND_STOP )
|
||||
{
|
||||
UTIL_EmitAmbientSound( pSoundSource->GetSoundSourceIndex(), pSoundSource->GetAbsOrigin(), m_szSoundFile,
|
||||
UTIL_EmitAmbientSound(pSoundSource->GetSoundSourceIndex(), pSoundSource->GetAbsOrigin(), szSoundFile,
|
||||
0, SNDLVL_NONE, flags, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
UTIL_EmitAmbientSound( pSoundSource->GetSoundSourceIndex(), pSoundSource->GetAbsOrigin(), m_szSoundFile,
|
||||
UTIL_EmitAmbientSound(pSoundSource->GetSoundSourceIndex(), pSoundSource->GetAbsOrigin(), szSoundFile,
|
||||
(m_dpv.vol * 0.01), m_iSoundLevel, flags, m_dpv.pitch);
|
||||
}
|
||||
}
|
||||
@@ -962,7 +897,7 @@ void CAmbientGeneric::SendSound( SoundFlags_t flags)
|
||||
if ( ( flags == SND_STOP ) &&
|
||||
( m_nSoundSourceEntIndex != -1 ) )
|
||||
{
|
||||
UTIL_EmitAmbientSound( m_nSoundSourceEntIndex, GetAbsOrigin(), m_szSoundFile,
|
||||
UTIL_EmitAmbientSound(m_nSoundSourceEntIndex, GetAbsOrigin(), szSoundFile,
|
||||
0, SNDLVL_NONE, flags, 0);
|
||||
}
|
||||
}
|
||||
@@ -1252,7 +1187,7 @@ int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg,
|
||||
name[0] = 0;
|
||||
|
||||
ipick = engine->SentenceGroupPick( isentenceg, name, sizeof( name ) );
|
||||
if ( ( ipick > 0 ) && name[0] )
|
||||
if (ipick > 0 && name)
|
||||
{
|
||||
int sentenceIndex = SENTENCEG_Lookup( name );
|
||||
CPASAttenuationFilter filter( GetContainingEntity( entity ), soundlevel );
|
||||
@@ -1419,9 +1354,9 @@ void UTIL_RestartAmbientSounds( void )
|
||||
CAmbientGeneric *pAmbient = NULL;
|
||||
while ( ( pAmbient = (CAmbientGeneric*) gEntList.FindEntityByClassname( pAmbient, "ambient_generic" ) ) != NULL )
|
||||
{
|
||||
if ( pAmbient->m_fActive )
|
||||
if (pAmbient->m_fActive )
|
||||
{
|
||||
if ( V_strstr( pAmbient->m_szSoundFile, "mp3" ) )
|
||||
if ( strstr( STRING( pAmbient->m_iszSound ), "mp3" ) )
|
||||
{
|
||||
pAmbient->SendSound( SND_CHANGE_VOL ); // fake a change, so we don't create 2 sounds
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user