From 5f12ab7f537688f76fa18086c8be84622e7481d3 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 23 Jan 2012 19:13:00 +0000 Subject: [PATCH] Fix sprite[-1] access when aborting playing a sound in Mapster's Sound Index. Also a couple of other cleanup lines... might need more though, I'm not sure it's all good there. git-svn-id: https://svn.eduke32.com/eduke32@2278 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/sounds_mapster32.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/polymer/eduke32/source/sounds_mapster32.c b/polymer/eduke32/source/sounds_mapster32.c index e6f2712da..d61de4f1a 100644 --- a/polymer/eduke32/source/sounds_mapster32.c +++ b/polymer/eduke32/source/sounds_mapster32.c @@ -285,13 +285,13 @@ void S_PlaySound(int32_t num) if (!SM32_havesound) return; if (SoundToggle==0) return; -// if ((g_sounds[num].m&8) && ud.lockout) return; - if (FX_VoiceAvailable(g_sounds[num].pr) == 0) return; - if (num < 0 || num > MAXSOUNDS-1 || !g_sounds[num].filename) + if ((unsigned)num >= MAXSOUNDS || !g_sounds[num].filename) { OSD_Printf("WARNING: invalid sound #%d\n",num); return; } +// if ((g_sounds[num].m&8) && ud.lockout) return; + if (FX_VoiceAvailable(g_sounds[num].pr) == 0) return; pitchs = g_sounds[num].ps; pitche = g_sounds[num].pe; @@ -323,11 +323,13 @@ void S_PlaySound(int32_t num) } else { - voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num); + voice = FX_PlayAuto3D(g_sounds[num].ptr, g_sounds[num].soundsiz, + pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num); } - if (voice >= FX_Ok)// return; + if (voice >= FX_Ok) { + g_sounds[num].SoundOwner[g_sounds[num].num].i = -1; g_sounds[num].SoundOwner[g_sounds[num].num].voice = voice; g_sounds[num].num++; return; @@ -449,11 +451,14 @@ void S_Callback(uint32_t num) for (j=0; j