support passed_objects in osu_2019 again
This commit is contained in:
+16
-1
@@ -40,6 +40,8 @@ pub struct OsuPP<'m> {
|
||||
n100: Option<u32>,
|
||||
n50: Option<u32>,
|
||||
n_misses: u32,
|
||||
|
||||
passed_objects: Option<u32>,
|
||||
}
|
||||
|
||||
impl<'m> OsuPP<'m> {
|
||||
@@ -56,6 +58,7 @@ impl<'m> OsuPP<'m> {
|
||||
n100: None,
|
||||
n50: None,
|
||||
n_misses: 0,
|
||||
passed_objects: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +75,7 @@ impl<'m> OsuPP<'m> {
|
||||
n100: None,
|
||||
n50: None,
|
||||
n_misses: 0,
|
||||
passed_objects: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +129,13 @@ impl<'m> OsuPP<'m> {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn passed_objects(mut self, passed_objects: u32) -> Self {
|
||||
self.passed_objects = self.passed_objects.replace(passed_objects);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Generate the hit results with respect to the given accuracy between `0` and `100`.
|
||||
///
|
||||
/// Be sure to set `misses` beforehand!
|
||||
@@ -224,7 +235,7 @@ impl<'m> OsuPP<'m> {
|
||||
/// containing stars and other attributes.
|
||||
pub fn calculate(mut self) -> OsuPerformanceAttributes {
|
||||
if self.attributes.is_none() {
|
||||
let attributes = stars(self.map.unwrap(), self.mods.clone());
|
||||
let attributes = stars(self.map.unwrap(), self.mods.clone(), self.passed_objects);
|
||||
self.attributes.replace(attributes);
|
||||
}
|
||||
|
||||
@@ -517,6 +528,10 @@ impl<'m> OsuPP<'m> {
|
||||
|
||||
#[inline]
|
||||
fn n_objects(&self) -> u32 {
|
||||
if let Some(passed_objects) = self.passed_objects {
|
||||
return passed_objects;
|
||||
}
|
||||
|
||||
match self.attributes.as_ref() {
|
||||
Some(attributes) => {
|
||||
(attributes.n_circles + attributes.n_sliders + attributes.n_spinners) as u32
|
||||
|
||||
@@ -22,7 +22,11 @@ const NORMALIZED_RADIUS: f32 = 52.0;
|
||||
/// processing stack leniency is relatively expensive.
|
||||
///
|
||||
/// In case of a partial play, e.g. a fail, one can specify the amount of passed objects.
|
||||
pub fn stars(map: &Beatmap, mods: GameMods) -> OsuDifficultyAttributes {
|
||||
pub fn stars(
|
||||
map: &Beatmap,
|
||||
mods: GameMods,
|
||||
passed_objects: Option<u32>,
|
||||
) -> OsuDifficultyAttributes {
|
||||
let map_attributes = map.attributes().mods(mods).build();
|
||||
|
||||
let mut diff_attributes = OsuDifficultyAttributes {
|
||||
@@ -34,7 +38,9 @@ pub fn stars(map: &Beatmap, mods: GameMods) -> OsuDifficultyAttributes {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
if map.hit_objects.len() < 2 {
|
||||
let take = passed_objects.unwrap_or(map.hit_objects.len() as u32) as usize;
|
||||
|
||||
if take < 2 {
|
||||
return diff_attributes;
|
||||
}
|
||||
|
||||
@@ -50,7 +56,7 @@ pub fn stars(map: &Beatmap, mods: GameMods) -> OsuDifficultyAttributes {
|
||||
let mut ticks_buf = Vec::new();
|
||||
let mut curve_bufs = CurveBuffers::default();
|
||||
|
||||
let mut hit_objects = map.hit_objects.iter().filter_map(|h| {
|
||||
let mut hit_objects = map.hit_objects.iter().take(take).filter_map(|h| {
|
||||
Some(OsuObject::new(
|
||||
h,
|
||||
map,
|
||||
|
||||
Reference in New Issue
Block a user