fix: dont sort unstably for catch

This commit is contained in:
MaxOhn
2024-10-11 17:49:03 +02:00
committed by tsunyoku
parent eba1259a22
commit 3ca1da7916
2 changed files with 2 additions and 44 deletions
+2 -14
View File
@@ -6,7 +6,7 @@ use crate::{
hit_object::{HitObject, HitObjectKind, HoldNote, Spinner},
mode::ConvertStatus,
},
util::{float_ext::FloatExt, random::Random, sort::TandemSorter},
util::{float_ext::FloatExt, random::Random},
};
use super::{
@@ -82,20 +82,8 @@ pub fn convert_objects(
palpable_objects.extend(new_objects);
}
// 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(&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));
initialize_hyper_dash(cs, &mut palpable_objects);
palpable_objects
}
-30
View File
@@ -26,7 +26,6 @@ macro_rules! new_fn {
impl TandemSorter {
new_fn!(new_stable: <[_]>::sort_by);
new_fn!(new_unstable: super::csharp);
/// Sort the given slice based on the internal ordering.
pub fn sort<T>(&mut self, slice: &mut [T]) {
@@ -59,35 +58,6 @@ impl TandemSorter {
self.should_reset = true;
}
/// Unsort the given slice based on the internal ordering.
pub fn unsort<T>(mut self, slice: &mut [T]) {
if self.should_reset {
self.toggle_marks();
self.should_reset = false;
}
for i in 0..self.indices.len() {
let i_idx = self.indices[i];
if Self::idx_is_marked(i_idx) {
continue;
}
let mut j = i;
let mut j_idx = i_idx;
while j != j_idx {
self.indices[j] = Self::toggle_mark_idx(j_idx);
self.indices.swap(j, j_idx);
slice.swap(j, j_idx);
j = self.indices[j];
j_idx = self.indices[j];
}
self.indices[j] = Self::toggle_mark_idx(j_idx);
}
}
fn toggle_marks(&mut self) {
for idx in self.indices.iter_mut() {
*idx = Self::toggle_mark_idx(*idx);