mania: use stable sort first
This commit is contained in:
+2
-2
@@ -151,7 +151,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn mania_single() {
|
fn mania_single() {
|
||||||
let file = match File::open("./maps/1355822.osu") {
|
let file = match File::open("./maps/1529790.osu") {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(why) => panic!("Could not open file: {}", why),
|
Err(why) => panic!("Could not open file: {}", why),
|
||||||
};
|
};
|
||||||
@@ -161,7 +161,7 @@ mod tests {
|
|||||||
Err(why) => panic!("Error while parsing map: {}", why),
|
Err(why) => panic!("Error while parsing map: {}", why),
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = ManiaPP::new(&map).mods(256).calculate();
|
let result = ManiaPP::new(&map).mods(0).calculate();
|
||||||
|
|
||||||
println!("Stars: {}", result.stars());
|
println!("Stars: {}", result.stars());
|
||||||
println!("PP: {}", result.pp());
|
println!("PP: {}", result.pp());
|
||||||
|
|||||||
+6
-2
@@ -12,7 +12,7 @@ pub use error::{ParseError, ParseResult};
|
|||||||
pub use hitobject::{HitObject, HitObjectKind};
|
pub use hitobject::{HitObject, HitObjectKind};
|
||||||
pub use hitsound::HitSound;
|
pub use hitsound::HitSound;
|
||||||
pub use pos2::Pos2;
|
pub use pos2::Pos2;
|
||||||
use sort::sort;
|
use sort::legacy_sort;
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::io::{BufRead, BufReader, Read};
|
use std::io::{BufRead, BufReader, Read};
|
||||||
@@ -443,7 +443,11 @@ impl Beatmap {
|
|||||||
// BUG: If [General] section comes after [HitObjects] then the mode
|
// BUG: If [General] section comes after [HitObjects] then the mode
|
||||||
// won't be set yet so mania objects won't be sorted properly
|
// won't be set yet so mania objects won't be sorted properly
|
||||||
if self.mode == GameMode::MNA {
|
if self.mode == GameMode::MNA {
|
||||||
sort(&mut self.hit_objects);
|
// First a stable sort by time, then the legacy sort for correct position order
|
||||||
|
self.hit_objects
|
||||||
|
.sort_by(|p1, p2| p1.partial_cmp(&p2).unwrap_or(Ordering::Equal));
|
||||||
|
|
||||||
|
legacy_sort(&mut self.hit_objects);
|
||||||
} else if unsorted {
|
} else if unsorted {
|
||||||
sort!(self.hit_objects);
|
sort!(self.hit_objects);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ use std::cmp::Ordering;
|
|||||||
const QUICK_SORT_DEPTH_THRESHOLD: usize = 32;
|
const QUICK_SORT_DEPTH_THRESHOLD: usize = 32;
|
||||||
|
|
||||||
/// Algorithm from https://github.com/ppy/osu/blob/master/osu.Game.Rulesets.Mania/MathUtils/LegacySortHelper.cs#L21
|
/// Algorithm from https://github.com/ppy/osu/blob/master/osu.Game.Rulesets.Mania/MathUtils/LegacySortHelper.cs#L21
|
||||||
pub(crate) fn sort(keys: &mut [HitObject]) {
|
pub(crate) fn legacy_sort(keys: &mut [HitObject]) {
|
||||||
if keys.is_empty() {
|
if keys.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user