From 28659bb1f9ffd65af582ce29223a0e707bf35617 Mon Sep 17 00:00:00 2001 From: Goober5000 Date: Tue, 27 Aug 2024 14:53:19 -0400 Subject: [PATCH] fix deletion of looping sounds Per the comment earlier in this function, both -1 and -2 are expected values for sound indexes. Update the sound validity check accordingly. Fixes an assertion in `obj_snd_delete()` encountered by FotG when a sound index was -2. --- code/ship/ship.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index 6c0af566125..1bda9545226 100644 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -10360,11 +10360,10 @@ void update_firing_sounds(object* objp, ship* shipp) end_snd_played = wip->end_firing_snd; } - if (wip->loop_firing_snd.isValid()) { + if (swp->firing_loop_sounds[i] >= 0) { obj_snd_delete(objp, swp->firing_loop_sounds[i]); - swp->firing_loop_sounds[i] = -1; - } else - swp->firing_loop_sounds[i] = -1; + } + swp->firing_loop_sounds[i] = -1; } } }