Fix sound issue

git-svn-id: https://svn.eduke32.com/eduke32@7940 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-08-09 11:00:34 +00:00 committed by Christoph Oelckers
parent ef7f4f8a60
commit 9ee310ce71
2 changed files with 21 additions and 20 deletions

View file

@ -842,37 +842,38 @@ int A_PlaySound(int soundNum, int spriteNum)
S_PlaySound3D(soundNum, spriteNum, (vec3_t *)&sprite[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) if (EDUKE32_PREDICT_FALSE((unsigned)sndNum > (unsigned)g_highestSoundIdx) || g_sounds[sndNum].num <= 0)
|| g_sounds[num].num <= 0)
return; return;
int j;
do
{
for (j=0; j<MAXSOUNDINSTANCES; ++j)
{
S_Cleanup(); S_Cleanup();
for (int j=0; j<MAXSOUNDINSTANCES; ++j) auto &voice = g_sounds[sndNum].voices[j];
{
auto &voice = g_sounds[num].voices[j];
if ((i == -1 && voice.id > FX_Ok) || (i != -1 && voice.owner == i)) if ((sprNum == -1 && voice.id > FX_Ok) || (sprNum != -1 && voice.owner == sprNum))
{ {
#ifdef DEBUGGINGAIDS #ifdef DEBUGGINGAIDS
if (EDUKE32_PREDICT_FALSE(i >= 0 && voice.id <= FX_Ok)) 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, num, j); initprintf(OSD_ERROR "S_StopEnvSound(): bad voice %d for sound ID %d index %d!\n", voice.id, sndNum, j);
else else
#endif #endif
if (voice.id > FX_Ok) if (voice.id > FX_Ok)
{ {
if (FX_SoundActive(voice.id)) if (FX_SoundActive(voice.id))
{
FX_StopSound(voice.id); FX_StopSound(voice.id);
S_Cleanup(); break;
}
j = 0;
continue;
} }
} }
} }
}
while (j < MAXSOUNDINSTANCES);
} }
// Do not remove this or make it inline. // Do not remove this or make it inline.

View file

@ -88,7 +88,7 @@ int S_PlaySound(int num);
int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos); int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos);
void S_SoundShutdown(void); void S_SoundShutdown(void);
void S_SoundStartup(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_StopAllSounds(void);
void S_StopMusic(void); void S_StopMusic(void);
void S_Update(void); void S_Update(void);