From 9ee310ce71157eb99056e15c5b950640d3519f32 Mon Sep 17 00:00:00 2001 From: terminx Date: Fri, 9 Aug 2019 11:00:34 +0000 Subject: [PATCH] Fix sound issue git-svn-id: https://svn.eduke32.com/eduke32@7940 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/sounds.cpp | 39 ++++++++++++++++++------------------ source/duke3d/src/sounds.h | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/source/duke3d/src/sounds.cpp b/source/duke3d/src/sounds.cpp index 1f9b43896..761753557 100644 --- a/source/duke3d/src/sounds.cpp +++ b/source/duke3d/src/sounds.cpp @@ -842,37 +842,38 @@ int A_PlaySound(int soundNum, int spriteNum) S_PlaySound3D(soundNum, spriteNum, (vec3_t *)&sprite[spriteNum]); } -void S_StopEnvSound(int32_t num, int32_t i) +void S_StopEnvSound(int sndNum, int sprNum) { - if (EDUKE32_PREDICT_FALSE((unsigned)num > (unsigned)g_highestSoundIdx) - || g_sounds[num].num <= 0) + if (EDUKE32_PREDICT_FALSE((unsigned)sndNum > (unsigned)g_highestSoundIdx) || g_sounds[sndNum].num <= 0) return; - S_Cleanup(); + int j; - for (int j=0; j FX_Ok) || (i != -1 && voice.owner == i)) + for (j=0; j= 0 && voice.id <= FX_Ok)) - initprintf(OSD_ERROR "S_StopEnvSound(): bad voice %d for sound ID %d index %d!\n", voice.id, num, j); - else -#endif - if (voice.id > FX_Ok) + S_Cleanup(); + + auto &voice = g_sounds[sndNum].voices[j]; + + if ((sprNum == -1 && voice.id > FX_Ok) || (sprNum != -1 && voice.owner == sprNum)) { - if (FX_SoundActive(voice.id)) +#ifdef DEBUGGINGAIDS + if (EDUKE32_PREDICT_FALSE(sprNum >= 0 && voice.id <= FX_Ok)) + initprintf(OSD_ERROR "S_StopEnvSound(): bad voice %d for sound ID %d index %d!\n", voice.id, sndNum, j); + else +#endif + if (voice.id > FX_Ok) { - FX_StopSound(voice.id); - S_Cleanup(); + if (FX_SoundActive(voice.id)) + FX_StopSound(voice.id); + break; } - j = 0; - continue; } } } + while (j < MAXSOUNDINSTANCES); } // Do not remove this or make it inline. diff --git a/source/duke3d/src/sounds.h b/source/duke3d/src/sounds.h index e128523f3..b62f8390e 100644 --- a/source/duke3d/src/sounds.h +++ b/source/duke3d/src/sounds.h @@ -88,7 +88,7 @@ int S_PlaySound(int num); int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos); void S_SoundShutdown(void); void S_SoundStartup(void); -void S_StopEnvSound(int32_t num,int32_t i); +void S_StopEnvSound(int sndNum,int sprNum); void S_StopAllSounds(void); void S_StopMusic(void); void S_Update(void);