From afd1bdda9d084d6471f8e83422c5edeae3e092f0 Mon Sep 17 00:00:00 2001 From: MaxOhn Date: Sat, 11 Nov 2023 18:46:09 +0100 Subject: [PATCH] fix: always consider *all* notes for stacking --- src/osu/mod.rs | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/osu/mod.rs b/src/osu/mod.rs index c4e8f58b..f6d7da11 100644 --- a/src/osu/mod.rs +++ b/src/osu/mod.rs @@ -355,12 +355,36 @@ pub(crate) fn create_osu_objects( curve_bufs: CurveBuffers::default(), }; - let mut hit_objects: Vec<_> = map - .hit_objects - .iter() + let mut hit_objects = Vec::with_capacity(map.hit_objects.len()); + let mut iter = map.hit_objects.iter(); + + let hit_object_iter = iter + .by_ref() .take(take) - .map(|h| OsuObject::new(h, &mut params)) - .collect(); + .map(|h| OsuObject::new(h, &mut params)); + hit_objects.extend(hit_object_iter); + + // remaining objects unfortunately still need to be processed since they might influence stacking + if take < map.hit_objects.len() { + let ObjectParameters { + map, + attrs, + ticks, + curve_bufs, + } = params; + + // use a new instance for attributes so that max combo & co remain correct in the original + let mut throw_away_attrs = attrs.clone(); + + let mut params = ObjectParameters { + map, + attrs: &mut throw_away_attrs, + ticks, + curve_bufs, + }; + + hit_objects.extend(iter.map(|h| OsuObject::new(h, &mut params))); + } let stack_threshold = time_preempt * map.stack_leniency as f64; @@ -370,6 +394,8 @@ pub(crate) fn create_osu_objects( old_stacking(&mut hit_objects, stack_threshold); } + hit_objects.truncate(take); + hit_objects .iter_mut() .for_each(|h| h.post_process(hr, scaling_factor));