store duration instead of end_time (/b/1901200+Mania)

This commit is contained in:
MaxOhn
2024-02-19 15:03:05 +01:00
parent 305041376b
commit f2bb6ce6cb
10 changed files with 39 additions and 33 deletions
+6 -2
View File
@@ -615,7 +615,9 @@ impl DecodeBeatmap for Beatmap {
parse_custom_sound(split.next())?;
HitObjectKind::Spinner(Spinner { end_time })
let duration = (end_time - start_time).max(0.0);
HitObjectKind::Spinner(Spinner { duration })
} else if hit_object_type.has_flag(HitObjectType::HOLD) {
let end_time = if let Some(s) = split.next().filter(|s| !s.is_empty()) {
let (end_time, bank_info) = s
@@ -629,7 +631,9 @@ impl DecodeBeatmap for Beatmap {
start_time
};
HitObjectKind::Hold(HoldNote { end_time })
let duration = end_time - start_time;
HitObjectKind::Hold(HoldNote { duration })
} else {
return Err(ParseBeatmapError::UnknownHitObjectType);
};
+5 -5
View File
@@ -35,11 +35,11 @@ impl HitObject {
/// The end time of the object.
///
/// Note that this will not return the correct value for sliders.
pub(crate) const fn end_time(&self) -> f64 {
pub(crate) fn end_time(&self) -> f64 {
match &self.kind {
HitObjectKind::Circle | HitObjectKind::Slider { .. } => self.start_time,
HitObjectKind::Spinner(Spinner { end_time })
| HitObjectKind::Hold(HoldNote { end_time }) => *end_time,
HitObjectKind::Spinner(Spinner { duration })
| HitObjectKind::Hold(HoldNote { duration }) => self.start_time + *duration,
}
}
}
@@ -84,11 +84,11 @@ impl Slider {
/// A spinner.
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Spinner {
pub end_time: f64,
pub duration: f64,
}
/// A hold note.
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct HoldNote {
pub end_time: f64,
pub duration: f64,
}