Fixed host_timescale scaling sounds when cheats are off

This commit is contained in:
Blixibon 2021-01-24 22:31:48 -06:00
parent 6595b96418
commit f484653f41

View File

@ -132,6 +132,15 @@ void Hack_FixEscapeChars( char *str )
#ifdef MAPBASE #ifdef MAPBASE
static const ConVar *pHostTimescale; static const ConVar *pHostTimescale;
static float GetSoundPitchScale()
{
static ConVarRef sv_cheats( "sv_cheats" );
if (sv_cheats.GetBool())
return pHostTimescale->GetFloat();
return 1.0f;
}
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -534,7 +543,7 @@ public:
(soundlevel_t)params.soundlevel, (soundlevel_t)params.soundlevel,
ep.m_nFlags, ep.m_nFlags,
#ifdef MAPBASE #ifdef MAPBASE
pHostTimescale->GetFloat() != 0.0f ? params.pitch * pHostTimescale->GetFloat() : params.pitch, params.pitch * GetSoundPitchScale(),
#else #else
params.pitch, params.pitch,
#endif #endif
@ -617,7 +626,7 @@ public:
ep.m_SoundLevel, ep.m_SoundLevel,
ep.m_nFlags, ep.m_nFlags,
#ifdef MAPBASE #ifdef MAPBASE
pHostTimescale->GetFloat() != 0.0f ? ep.m_nPitch * pHostTimescale->GetFloat() : ep.m_nPitch, ep.m_nPitch * GetSoundPitchScale(),
#else #else
ep.m_nPitch, ep.m_nPitch,
#endif #endif
@ -843,10 +852,7 @@ public:
} }
#ifdef MAPBASE #ifdef MAPBASE
if ( pHostTimescale->GetFloat() != 0.0f ) params.pitch *= GetSoundPitchScale();
{
params.pitch *= pHostTimescale->GetFloat();
}
#endif #endif
#if defined( CLIENT_DLL ) #if defined( CLIENT_DLL )
@ -978,10 +984,7 @@ public:
if ( pSample && ( Q_stristr( pSample, ".wav" ) || Q_stristr( pSample, ".mp3" )) ) if ( pSample && ( Q_stristr( pSample, ".wav" ) || Q_stristr( pSample, ".mp3" )) )
{ {
#ifdef MAPBASE #ifdef MAPBASE
if ( pHostTimescale->GetFloat() != 0.0f ) pitch *= GetSoundPitchScale();
{
pitch *= pHostTimescale->GetFloat();
}
#endif #endif
#if defined( CLIENT_DLL ) #if defined( CLIENT_DLL )