diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index b43a4b5a17..0b1a2d6c0e 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -1267,6 +1267,9 @@ void CL_Snd_Restart_f( void ) { extern void S_RestartMusic( void ); S_RestartMusic(); + + extern void AS_ParseSets( void ); + AS_ParseSets(); } diff --git a/codemp/client/snd_ambient.cpp b/codemp/client/snd_ambient.cpp index 0b187088c9..9ec039b1fd 100644 --- a/codemp/client/snd_ambient.cpp +++ b/codemp/client/snd_ambient.cpp @@ -758,13 +758,21 @@ Loads the ambient sound sets and prepares to play them when needed ------------------------- */ +static namePrecache_m *TheNamePrecache( void ) +{ + // Use a static singleton so pMap persists across sound restarts. + // This fixes ambient sounds not playing after snd_restart. + static namePrecache_m singleton; + return &singleton; +} + void AS_Init( void ) { if (!aSets) { numSets = 0; - pMap = new namePrecache_m; + pMap = TheNamePrecache(); //Setup the structure aSets = new CSetGroup(); @@ -882,8 +890,7 @@ void AS_FreePartial(void) numSets = 0; - delete pMap; - pMap = new namePrecache_m; + // pMap is now a static singleton, just clear it instead of delete/new pMap->clear(); } }