store duration instead of end_time (/b/1901200+Mania)
This commit is contained in:
@@ -107,9 +107,9 @@ fn convert_object<'a>(
|
||||
|
||||
ObjectIterState::JuiceStream(stream)
|
||||
}
|
||||
HitObjectKind::Spinner(Spinner { end_time })
|
||||
| HitObjectKind::Hold(HoldNote { end_time }) => {
|
||||
ObjectIterState::BananaShower(BananaShower::new(h.start_time, end_time))
|
||||
HitObjectKind::Spinner(Spinner { duration })
|
||||
| HitObjectKind::Hold(HoldNote { duration }) => {
|
||||
ObjectIterState::BananaShower(BananaShower::new(h.start_time, duration))
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ pub struct BananaShower {
|
||||
}
|
||||
|
||||
impl BananaShower {
|
||||
pub fn new(start_time: f64, end_time: f64) -> Self {
|
||||
let duration = end_time - start_time;
|
||||
pub fn new(start_time: f64, duration: f64) -> Self {
|
||||
let mut spacing = duration;
|
||||
let end_time = start_time + duration;
|
||||
|
||||
while spacing > 100.0 {
|
||||
spacing /= 2.0;
|
||||
|
||||
@@ -132,8 +132,10 @@ fn convert(map: &mut Beatmap) {
|
||||
last_values.pattern = new_pattern;
|
||||
}
|
||||
}
|
||||
HitObjectKind::Spinner(Spinner { end_time })
|
||||
| HitObjectKind::Hold(HoldNote { end_time }) => {
|
||||
HitObjectKind::Spinner(Spinner { duration })
|
||||
| HitObjectKind::Hold(HoldNote { duration }) => {
|
||||
let end_time = obj.start_time + duration;
|
||||
|
||||
let mut gen = EndTimeObjectPatternGenerator::new(
|
||||
&mut random,
|
||||
obj,
|
||||
|
||||
@@ -72,7 +72,7 @@ impl Pattern {
|
||||
pos,
|
||||
start_time: generator.inner.hit_object.start_time,
|
||||
kind: HitObjectKind::Hold(HoldNote {
|
||||
end_time: generator.end_time,
|
||||
duration: generator.end_time - generator.inner.hit_object.start_time,
|
||||
}),
|
||||
}
|
||||
} else {
|
||||
@@ -102,11 +102,13 @@ impl Pattern {
|
||||
kind: HitObjectKind::Circle,
|
||||
}
|
||||
} else {
|
||||
let start_time = f64::from(start_time);
|
||||
|
||||
HitObject {
|
||||
pos,
|
||||
start_time: f64::from(start_time),
|
||||
start_time,
|
||||
kind: HitObjectKind::Hold(HoldNote {
|
||||
end_time: f64::from(end_time),
|
||||
duration: f64::from(end_time) - start_time,
|
||||
}),
|
||||
}
|
||||
};
|
||||
@@ -131,11 +133,13 @@ impl Pattern {
|
||||
kind: HitObjectKind::Circle,
|
||||
}
|
||||
} else {
|
||||
let start_time = f64::from(start_time);
|
||||
|
||||
HitObject {
|
||||
pos,
|
||||
start_time: f64::from(start_time),
|
||||
start_time,
|
||||
kind: HitObjectKind::Hold(HoldNote {
|
||||
end_time: f64::from(end_time),
|
||||
duration: f64::from(end_time) - start_time,
|
||||
}),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -80,9 +80,6 @@ impl<'h> EndTimeObjectPatternGenerator<'h> {
|
||||
&mut self,
|
||||
mut initial_column: u8,
|
||||
lower: Option<i32>,
|
||||
// upper: Option<i32>,
|
||||
// next_column: Option<&dyn Fn(u8) -> u8>,
|
||||
// validation: Option<&dyn Fn(i32) -> bool>,
|
||||
patterns: &[&Pattern],
|
||||
) -> u8 {
|
||||
let lower = lower.unwrap_or_else(|| self.inner.random_start());
|
||||
|
||||
+4
-4
@@ -54,13 +54,13 @@ impl ManiaObject {
|
||||
column,
|
||||
}
|
||||
}
|
||||
HitObjectKind::Spinner(Spinner { end_time })
|
||||
| HitObjectKind::Hold(HoldNote { end_time }) => {
|
||||
params.max_combo += ((end_time - h.start_time) / 100.0) as u32;
|
||||
HitObjectKind::Spinner(Spinner { duration })
|
||||
| HitObjectKind::Hold(HoldNote { duration }) => {
|
||||
params.max_combo += (duration / 100.0) as u32;
|
||||
|
||||
Self {
|
||||
start_time: h.start_time,
|
||||
end_time,
|
||||
end_time: h.start_time + duration,
|
||||
column,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
+4
-4
@@ -39,8 +39,8 @@ impl OsuObject {
|
||||
OsuObjectKind::Slider(OsuSlider::new(h, slider, converted, curve_bufs, ticks_buf))
|
||||
}
|
||||
HitObjectKind::Spinner(spinner) => OsuObjectKind::Spinner(spinner),
|
||||
HitObjectKind::Hold(HoldNote { end_time }) => {
|
||||
OsuObjectKind::Spinner(Spinner { end_time })
|
||||
HitObjectKind::Hold(HoldNote { duration }) => {
|
||||
OsuObjectKind::Spinner(Spinner { duration })
|
||||
}
|
||||
};
|
||||
|
||||
@@ -95,11 +95,11 @@ impl OsuObject {
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn end_time(&self) -> f64 {
|
||||
pub fn end_time(&self) -> f64 {
|
||||
match self.kind {
|
||||
OsuObjectKind::Circle => self.start_time,
|
||||
OsuObjectKind::Slider(ref slider) => slider.end_time,
|
||||
OsuObjectKind::Spinner(ref spinner) => spinner.end_time,
|
||||
OsuObjectKind::Spinner(ref spinner) => self.start_time + spinner.duration,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,9 +93,8 @@ fn convert(map: &mut Beatmap) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Pathological case; shouldn't realistically happen
|
||||
HitObjectKind::Hold(HoldNote { end_time }) => {
|
||||
map.hit_objects[idx].kind = HitObjectKind::Spinner(Spinner { end_time });
|
||||
HitObjectKind::Hold(HoldNote { duration }) => {
|
||||
map.hit_objects[idx].kind = HitObjectKind::Spinner(Spinner { duration });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user