diff --git a/src/p_setup.c b/src/p_setup.c index 7b4a3db2b..0b3ab35bf 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2936,7 +2936,11 @@ boolean P_SetupLevel(boolean skipprecip) // Make sure all sounds are stopped before Z_FreeTags. S_StopSounds(); - S_ClearSfx(); + + if ((!(!sound_disabled && (M_CheckParm("-precachesound")))) || (!precachesound.value)) //why do this with soundprecaching enabled?????? + { + S_ClearSfx(); + } // As oddly named as this is, this handles music only. // We should be fine starting it here. diff --git a/src/s_sound.c b/src/s_sound.c index 4be55a8a0..81572ec94 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -53,6 +53,7 @@ static void Command_ShowMusicCredit_f(void); static void GameMIDIMusic_OnChange(void); #endif static void GameSounds_OnChange(void); +static void SoundPrecache_OnChange(void); static void GameDigiMusic_OnChange(void); static void BufferSize_OnChange(void); @@ -74,7 +75,7 @@ consvar_t cv_audbuffersize = {"buffersize", "2048", CV_SAVE, audbuffersize_cons_ consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // if true, all sounds are loaded at game startup -static consvar_t precachesound = {"precachesound", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t precachesound = {"precachesound", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, SoundPrecache_OnChange, 0, NULL, NULL, 0, 0, NULL}; // actual general (maximum) sound & music volume, saved into the config consvar_t cv_soundvolume = {"soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1269,9 +1270,9 @@ void S_InitSfxChannels(INT32 sfxVolume) // Initialize external data (all sounds) at start, keep static. CONS_Printf(M_GetText("Loading sounds... ")); - for (i = 1; i < NUMSFX; i++) - if (S_sfx[i].name) - S_sfx[i].data = I_GetSfx(&S_sfx[i]); + for (i = 1; i < NUMSFX; i++) + if (S_sfx[i].name && !S_sfx[i].data) + S_sfx[i].data = I_GetSfx(&S_sfx[i]); CONS_Printf(M_GetText(" pre-cached all sound data\n")); } @@ -2388,6 +2389,19 @@ void GameSounds_OnChange(void) } } +static void SoundPrecache_OnChange(void) +{ + if ((precachesound.value) && (!sound_disabled)) + { + S_InitSfxChannels(cv_soundvolume.value); + } + else if (!precachesound.value) + { + S_ClearSfx(); + if (!sound_disabled) + S_InitSfxChannels(cv_soundvolume.value); + } +} void GameDigiMusic_OnChange(void) { diff --git a/src/s_sound.h b/src/s_sound.h index 72d4bd38d..d974079a4 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -69,6 +69,7 @@ extern consvar_t cv_resume; extern consvar_t cv_fading; extern consvar_t cv_birdmusic; +extern consvar_t precachesound; extern CV_PossibleValue_t soundvolume_cons_t[];