2121#include " vaudio/ivaudio.h"
2222#include " ../../client.h"
2323#include " ../../cl_main.h"
24- #include " utldict.h"
24+ #include " tier1/ utldict.h"
2525#include " mempool.h"
2626#include " ../../enginetrace.h" // for traceline
2727#include " ../../public/bspflags.h" // for traceline
3737#include " ../../pure_server.h"
3838#include " filesystem/IQueuedLoader.h"
3939#include " voice.h"
40- #if defined( _X360 )
41- #include " xbox/xbox_console.h"
42- #include " xmp.h"
43- #endif
4440
4541#include " replay/iclientreplaycontext.h"
4642#include " replay/ireplaymovierenderer.h"
4743
4844#include " video/ivideoservices.h"
4945extern IVideoServices *g_pVideo;
5046
51- /*
52- #include "gl_model_private.h"
53- #include "world.h"
54- #include "vphysics_interface.h"
55- #include "client_class.h"
56- #include "server_class.h"
57- */
58-
5947// memdbgon must be the last include file in a .cpp file!!!
6048#include " tier0/memdbgon.h"
6149
@@ -66,8 +54,23 @@ extern IVideoServices *g_pVideo;
6654//
6755// #define DEBUG_CHANNELS
6856
69- #define SNDLVL_TO_DIST_MULT ( sndlvl ) ( sndlvl ? ((powf( 10 .0f , snd_refdb.GetFloat() / 20 ) / powf( 10 .0f , (float )sndlvl / 20 )) / snd_refdist.GetFloat()) : 0 )
70- #define DIST_MULT_TO_SNDLVL ( dist_mult ) (soundlevel_t )(int )( (dist_mult) ? ( 20 * log10f ( powf( 10 .0f , snd_refdb.GetFloat() / 20 ) / ((dist_mult) * snd_refdist.GetFloat()) ) ) : 0 )
57+ extern ConVar snd_refdb;
58+ extern ConVar snd_refdist;
59+
60+ inline float SNDLVL_TO_DIST_MULT ( soundlevel_t sndlvl )
61+ {
62+ return sndlvl != SNDLVL_NONE
63+ ? powf ( 10 .0f , ( snd_refdb.GetFloat () - static_cast <float >( sndlvl ) ) / 20 ) / snd_refdist.GetFloat ()
64+ : 0 ;
65+ }
66+
67+ inline soundlevel_t DIST_MULT_TO_SNDLVL ( float dist_mult )
68+ {
69+ // dimhotepus: Rewrite and simplify to match SNDLVL_TO_DIST_MULT.
70+ return (soundlevel_t )(int )( dist_mult
71+ ? snd_refdb.GetFloat () - log10f ( dist_mult * snd_refdist.GetFloat () ) * 20
72+ : 0 );
73+ }
7174
7275extern ConVar dsp_spatial;
7376extern IPhysicsSurfaceProps *physprop;
@@ -447,7 +450,7 @@ typedef struct
447450
448451static soundfade_t soundfade; // Client sound fading singleton object
449452
450- // 0)headphones 2)stereo speakers 4)quad 5)5point1
453+ // 0)headphones 2)stereo speakers 4)quad 5)5point1 7)7point1
451454// autodetected from windows settings
452455ConVar snd_surround ( " snd_surround_speakers" , " -1" , FCVAR_INTERNAL_USE );
453456ConVar snd_legacy_surround ( " snd_legacy_surround" , " 0" , FCVAR_ARCHIVE );
@@ -497,7 +500,7 @@ class CResourcePreloadSound : public CResourcePreload
497500 {
498501 bool bSpew = ( g_pQueuedLoader->GetSpewDetail () & LOADER_DETAIL_PURGES ) != 0 ;
499502
500- for ( int i = s_Sounds.FirstInorder (); i != s_Sounds.InvalidIndex (); i = s_Sounds.NextInorder ( i ) )
503+ for ( auto i = s_Sounds.FirstInorder (); i != s_Sounds.InvalidIndex (); i = s_Sounds.NextInorder ( i ) )
501504 {
502505 // the master sound table grows forever
503506 // remove sound sources from the master sound table that were not in the preload list
@@ -538,7 +541,7 @@ class CResourcePreloadSound : public CResourcePreload
538541 {
539542 bool bSpew = ( g_pQueuedLoader->GetSpewDetail () & LOADER_DETAIL_PURGES ) != 0 ;
540543
541- for ( int i = s_Sounds.FirstInorder (); i != s_Sounds.InvalidIndex (); i = s_Sounds.NextInorder ( i ) )
544+ for ( auto i = s_Sounds.FirstInorder (); i != s_Sounds.InvalidIndex (); i = s_Sounds.NextInorder ( i ) )
542545 {
543546 // the master sound table grows forever
544547 // remove sound sources from the master sound table that were not in the preload list
@@ -1010,8 +1013,8 @@ void S_ReloadFilesInList( IFileList *pFilesToReload )
10101013
10111014 CUtlVector< CSfxTable * > processed;
10121015
1013- int iLast = s_Sounds.LastInorder ();
1014- for ( int i = s_Sounds.FirstInorder (); i != iLast; i = s_Sounds.NextInorder ( i ) )
1016+ auto iLast = s_Sounds.LastInorder ();
1017+ for ( auto i = s_Sounds.FirstInorder (); i != iLast; i = s_Sounds.NextInorder ( i ) )
10151018 {
10161019 FileNameHandle_t fnHandle = s_Sounds.Key ( i );
10171020 char filename[MAX_PATH * 3 ];
@@ -1812,15 +1815,13 @@ void SND_GetDopplerPoints( channel_t *pChannel, QAngle &source_angles, Vector &v
18121815
18131816 pitch = DOPPLER_PITCH_MAX - dist * (DOPPLER_PITCH_MAX - DOPPLER_PITCH_MIN);
18141817
1815- pChannel->basePitch = (int )(pitch * 100.0 );
1818+ pChannel->basePitch = (int )(pitch * 100 .0f );
18161819}
18171820
18181821// console variables used to construct gain curve - don't change these!
18191822
18201823extern ConVar snd_foliage_db_loss;
18211824extern ConVar snd_gain;
1822- extern ConVar snd_refdb;
1823- extern ConVar snd_refdist;
18241825extern ConVar snd_gain_max;
18251826extern ConVar snd_gain_min;
18261827
@@ -6411,7 +6412,7 @@ void S_Update_Thread()
64116412 float frameTime = THREADED_MIX_TIME * 0 .001f ;
64126413 double lastFrameTime = Plat_FloatTime ();
64136414
6414- while ( !g_bMixThreadExit )
6415+ while ( !g_bMixThreadExit. load (std::memory_order::memory_order_relaxed) )
64156416 {
64166417 double t0 = Plat_FloatTime ();
64176418
@@ -6441,7 +6442,7 @@ void S_ShutdownMixThread()
64416442{
64426443 if ( g_hMixThread )
64436444 {
6444- g_bMixThreadExit = true ;
6445+ g_bMixThreadExit. store ( true , std::memory_order::memory_order_relaxed) ;
64456446 ThreadJoin ( g_hMixThread );
64466447 ReleaseThreadHandle ( g_hMixThread );
64476448 g_hMixThread = NULL ;
@@ -6460,7 +6461,7 @@ void S_Update_( float mixAheadTime )
64606461 {
64616462 if ( !g_hMixThread )
64626463 {
6463- g_bMixThreadExit = false ;
6464+ g_bMixThreadExit. store ( false , std::memory_order::memory_order_relaxed) ;
64646465 g_hMixThread = ThreadExecuteSolo ( " SoundMixer" , S_Update_Thread );
64656466 }
64666467 }
0 commit comments