From 2a3c80f95d5abeae0e53ccc6c2b7830613e0f854 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 1 Aug 2019 07:10:16 +0000 Subject: [PATCH] Fix issue with sounds being expired from cache git-svn-id: https://svn.eduke32.com/eduke32@7874 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/cache1d.cpp | 4 ++-- source/duke3d/src/sounds.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/source/build/src/cache1d.cpp b/source/build/src/cache1d.cpp index e5af55672..47953ef81 100644 --- a/source/build/src/cache1d.cpp +++ b/source/build/src/cache1d.cpp @@ -191,7 +191,7 @@ int32_t cacheFindBlock(int32_t newbytes, int32_t *besto, int32_t *bestz) for (native_t i=o1, zz=z; i= 200) { @@ -317,7 +317,7 @@ void cacheAgeEntries(void) { if ((((*cac[agecount].lock)-2)&255) < 198) (*cac[agecount].lock)--; - else if (*cac[agecount].lock >= 200) + else if (*cac[agecount].lock == 255) cnt++; } diff --git a/source/duke3d/src/sounds.cpp b/source/duke3d/src/sounds.cpp index b6df0e085..7f50e80ef 100644 --- a/source/duke3d/src/sounds.cpp +++ b/source/duke3d/src/sounds.cpp @@ -72,7 +72,9 @@ void S_SoundStartup(void) voice.clock = 0; } +#ifdef CACHING_DOESNT_SUCK g_soundlocks[i] = 199; +#endif } cacheAllSounds(); @@ -448,7 +450,7 @@ int32_t S_LoadSound(int num) } int32_t l = kfilelength(fp); - g_soundlocks[num] = 200; + g_soundlocks[num] = 255; snd.siz = l; cacheAllocateBlock((intptr_t *)&snd.ptr, l, (char *)&g_soundlocks[num]); l = kread(fp, snd.ptr, l); @@ -705,14 +707,18 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos) if (snd.num > 0 && PN(spriteNum) != MUSICANDSFX) S_StopEnvSound(sndNum, spriteNum); +#ifdef CACHING_DOESNT_SUCK if (++g_soundlocks[sndNum] < 200) g_soundlocks[sndNum] = 200; +#endif int const sndSlot = S_GetSlot(sndNum); if (sndSlot >= MAXSOUNDINSTANCES) { +#ifdef CACHING_DOESNT_SUCK g_soundlocks[sndNum]--; +#endif return -1; } @@ -720,7 +726,9 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos) if (repeatp && (snd.m & SF_ONEINST_INTERNAL) && snd.num > 0) { +#ifdef CACHING_DOESNT_SUCK g_soundlocks[sndNum]--; +#endif return -1; } @@ -729,7 +737,9 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos) if (voice <= FX_Ok) { +#ifdef CACHING_DOESNT_SUCK g_soundlocks[sndNum]--; +#endif return -1; } @@ -764,14 +774,18 @@ int S_PlaySound(int num) int const pitch = S_GetPitch(num); +#ifdef CACHING_DOESNT_SUCK if (++g_soundlocks[num] < 200) g_soundlocks[num] = 200; +#endif sndnum = S_GetSlot(num); if (sndnum >= MAXSOUNDINSTANCES) { +#ifdef CACHING_DOESNT_SUCK g_soundlocks[num]--; +#endif return -1; } @@ -782,7 +796,9 @@ int S_PlaySound(int num) if (voice <= FX_Ok) { +#ifdef CACHING_DOESNT_SUCK g_soundlocks[num]--; +#endif return -1; }