From b79a05f25b52e3c5cf5704d151d043d90ae52bc2 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 21 Jan 2024 17:44:51 +0300 Subject: [PATCH] Fix freeing sounds that aren't actually replaced --- src/p_setup.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index d6c93ea5b..010a28fd3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3508,11 +3508,12 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) for (i = 0; i < numlumps; i++, lumpinfo++) { name = lumpinfo->name; + lumpnum_t lumpnum = i|(wadnum<<16); if (name[0] == 'D') { if (name[1] == 'S') for (j = 1; j < NUMSFX; j++) { - if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6)) + if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6) && S_sfx[j].lumpnum != lumpnum && S_sfx[j].lumpnum != LUMPERROR) { // the sound will be reloaded when needed, // since sfx->data will be NULL @@ -3520,6 +3521,10 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) I_FreeSfx(&S_sfx[j]); + // Re-cache it + if (!sound_disabled && (M_CheckParm("-precachesound") || precachesound.value)) + S_sfx[j].data = I_GetSfx(&S_sfx[j]); + sreplaces++; } }