From 4f7fb7125bb83d0c3d1446f703c978db4b10a7e4 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 5 Aug 2023 23:51:26 +0100 Subject: [PATCH] Fix crash for some files --- tracker/agb-xm-core/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tracker/agb-xm-core/src/lib.rs b/tracker/agb-xm-core/src/lib.rs index ccc1251e..b2f53192 100644 --- a/tracker/agb-xm-core/src/lib.rs +++ b/tracker/agb-xm-core/src/lib.rs @@ -147,8 +147,10 @@ pub fn parse_module(module: &Module) -> TokenStream { if let InstrumentType::Default(ref instrument) = module.instrument[instrument_index].instr_type { - let sample_slot = - instrument.sample_for_note[slot.note as usize - 1] as usize; + let sample_slot = *instrument + .sample_for_note + .get(slot.note as usize) + .unwrap_or(&0) as usize; instruments_map .get(&(instrument_index, sample_slot)) .map(|sample_idx| sample_idx + 1) @@ -163,7 +165,7 @@ pub fn parse_module(module: &Module) -> TokenStream { let previous_note_and_sample = note_and_sample[channel_number]; let maybe_note_and_sample = if matches!(slot.note, Note::KeyOff) { effect1 = PatternEffect::Stop; - // note_and_sample[channel_number] = None; + ¬e_and_sample[channel_number] } else if !matches!(slot.note, Note::None) { if sample != 0 {