apply proper sorting for catch objects

This commit is contained in:
MaxOhn
2024-02-16 01:18:37 +01:00
parent 100d01483c
commit 05b588a2d1
4 changed files with 67 additions and 34 deletions
+11 -2
View File
@@ -8,7 +8,7 @@ use crate::{
hit_object::{HitObject, HitObjectKind, HoldNote, Spinner},
mode::ConvertStatus,
},
util::{float_ext::FloatExt, random::Random, sort},
util::{float_ext::FloatExt, random::Random, sort::TandemSorter},
};
use super::{
@@ -75,12 +75,21 @@ pub fn convert_objects(
palpable_objects.extend(new_objects);
}
sort::csharp(&mut palpable_objects, |a, b| {
// Initializing hyper dashes requires objects to be sorted by C#'s unstable
// sort. After that, we unsort the objects again and then apply a stable
// sort to have the correct order for generating difficulty objects.
// Required e.g. due to map /b/102923.
let mut sorter = TandemSorter::new_unstable(&mut palpable_objects, |a, b| {
a.start_time.total_cmp(&b.start_time)
});
sorter.sort(&mut palpable_objects);
initialize_hyper_dash(cs, &mut palpable_objects);
sorter.unsort(&mut palpable_objects);
palpable_objects.sort_by(|a, b| a.start_time.total_cmp(&b.start_time));
palpable_objects
}