From 07fd6a3ad458d976ba03f50dd75a3b0d53b93577 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jan 2024 15:39:25 +0100 Subject: [PATCH] make sound precaching useful at all so it also precaches addon sounds and all thx indev for help <3 --- src/p_setup.c | 2 +- src/s_sound.c | 6 +++++- src/sounds.c | 9 ++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 2b0b5aee1..b0bdb1875 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2938,7 +2938,7 @@ boolean P_SetupLevel(boolean skipprecip) // Make sure all sounds are stopped before Z_FreeTags. S_StopSounds(); - if ((!(!sound_disabled && (M_CheckParm("-precachesound")))) || (!precachesound.value)) //why do this with soundprecaching enabled?????? + if (!(M_CheckParm("-precachesound") || precachesound.value)) //why do this with soundprecaching enabled?????? { S_ClearSfx(); } diff --git a/src/s_sound.c b/src/s_sound.c index dc065edf8..c91ad9007 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1270,10 +1270,14 @@ 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++) + for (i = 1; i < sfx_freeslot0; i++) if (S_sfx[i].name && !S_sfx[i].data) S_sfx[i].data = I_GetSfx(&S_sfx[i]); + for (i = sfx_freeslot0; i < NUMSFX; i++) + if (S_sfx[i].priority && !S_sfx[i].data) + S_sfx[i].data = I_GetSfx(&S_sfx[i]); + CONS_Printf(M_GetText(" pre-cached all sound data\n")); } } diff --git a/src/sounds.c b/src/sounds.c index d949c27ab..e815d0554 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -14,6 +14,8 @@ #include "doomtype.h" #include "i_sound.h" #include "sounds.h" +#include "s_sound.h" //for soundprecaching +#include "m_argv.h" #include "r_defs.h" #include "r_things.h" #include "z_zone.h" @@ -1032,7 +1034,12 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean S_sfx[i].usefulness = -1; /// \todo if precached load it here - S_sfx[i].data = NULL; + if (!sound_disabled && (M_CheckParm("-precachesound") || precachesound.value)){ + CONS_Printf("Precaching sounds...\n"); + S_sfx[i].data = I_GetSfx(&S_sfx[i]); + } + else + S_sfx[i].data = NULL; return i; } }