use osu's bezier approximation
This commit is contained in:
@@ -28,6 +28,7 @@ pub enum ParseError {
|
||||
InvalidPathType,
|
||||
InvalidTimingSignature,
|
||||
MissingField(&'static str),
|
||||
TooManyRepeats,
|
||||
UnknownHitObjectKind,
|
||||
|
||||
#[cfg(not(all(
|
||||
@@ -54,6 +55,7 @@ impl fmt::Display for ParseError {
|
||||
Self::InvalidPathType => f.write_str("invalid path type"),
|
||||
Self::InvalidTimingSignature => f.write_str("invalid timing signature"),
|
||||
Self::MissingField(field) => write!(f, "missing field `{}`", field),
|
||||
Self::TooManyRepeats => f.write_str("repeat count is way too high"),
|
||||
Self::UnknownHitObjectKind => f.write_str("unsupported hitobject kind"),
|
||||
|
||||
#[cfg(not(all(
|
||||
@@ -84,6 +86,7 @@ impl StdError for ParseError {
|
||||
Self::InvalidPathType => None,
|
||||
Self::InvalidTimingSignature => None,
|
||||
Self::MissingField(_) => None,
|
||||
Self::TooManyRepeats => None,
|
||||
Self::UnknownHitObjectKind => None,
|
||||
|
||||
#[cfg(not(all(
|
||||
|
||||
+15
-7
@@ -419,9 +419,9 @@ macro_rules! parse_hitobjects_body {
|
||||
y: next_field!(split.next(), "y position").parse()?,
|
||||
};
|
||||
|
||||
let time = next_field!(split.next(), "hitobject time")
|
||||
let time: f32 = next_field!(split.next(), "hitobject time")
|
||||
.trim()
|
||||
.parse::<f32>()?;
|
||||
.parse()?;
|
||||
|
||||
validate_float!(time);
|
||||
|
||||
@@ -449,6 +449,17 @@ macro_rules! parse_hitobjects_body {
|
||||
|
||||
let mut curve_point_iter = next_field!(split.next(), "curve points").split('|');
|
||||
|
||||
let mut repeats: usize = next_field!(split.next(), "repeats")
|
||||
.parse()?;
|
||||
|
||||
if repeats > 9000 {
|
||||
return Err(ParseError::TooManyRepeats);
|
||||
}
|
||||
|
||||
// * osu-stable treated the first span of the slider
|
||||
// * as a repeat, but no repeats are happening
|
||||
repeats = repeats.saturating_sub(1);
|
||||
|
||||
let mut path_type: PathType =
|
||||
next_field!(curve_point_iter.next(), "path kind").parse()?;
|
||||
|
||||
@@ -499,10 +510,7 @@ macro_rules! parse_hitobjects_body {
|
||||
if curve_points.is_empty() {
|
||||
HitObjectKind::Circle
|
||||
} else {
|
||||
let repeats = next_field!(split.next(), "repeats")
|
||||
.parse::<usize>()?
|
||||
.min(9000);
|
||||
|
||||
// TODO: Should be Option<f32>?
|
||||
let pixel_len = next_field!(split.next(), "pixel len")
|
||||
.parse::<f32>()?
|
||||
.max(0.0)
|
||||
@@ -552,7 +560,7 @@ macro_rules! parse_hitobjects_body {
|
||||
pos,
|
||||
start_time: time,
|
||||
kind,
|
||||
sound,
|
||||
sound, // TODO: omit if not taiko?
|
||||
});
|
||||
|
||||
prev_time = time;
|
||||
|
||||
Reference in New Issue
Block a user