From ceb427fd646daba71eb5f2ce5dbe07d8b41a4986 Mon Sep 17 00:00:00 2001 From: mochi Date: Wed, 16 Sep 2020 13:11:41 +0200 Subject: [PATCH] Fix synthesized music's last note cutting short --- code/modules/instruments/songs/_song.dm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/code/modules/instruments/songs/_song.dm b/code/modules/instruments/songs/_song.dm index df5c9a74e05..bc9da6f697c 100644 --- a/code/modules/instruments/songs/_song.dm +++ b/code/modules/instruments/songs/_song.dm @@ -255,16 +255,20 @@ * Processes our song. */ /datum/song/proc/process_song(wait) - if(!length(compiled_chords) || current_chord > length(compiled_chords) || should_stop_playing(user_playing)) + if(!length(compiled_chords) || should_stop_playing(user_playing)) stop_playing() return - var/list/chord = compiled_chords[current_chord] if(++elapsed_delay >= delay_by) + // We were sustaining the final note but not anymore + if(current_chord > length(compiled_chords)) + stop_playing() + return + var/list/chord = compiled_chords[current_chord] play_chord(chord) elapsed_delay = 0 delay_by = tempodiv_to_delay(chord[length(chord)]) current_chord++ - if(current_chord > length(compiled_chords)) + if(current_chord > length(compiled_chords) + 1) if(repeat) repeat-- current_chord = 1