store edge sounds properly

This commit is contained in:
MaxOhn
2024-02-16 22:19:54 +01:00
parent 7988befad1
commit 872920a84e
2 changed files with 21 additions and 15 deletions
+14 -8
View File
@@ -529,13 +529,13 @@ impl DecodeBeatmap for Beatmap {
let mut len = None;
let mut repeats = repeat_count.parse_num::<i32>()?;
let repeats = repeat_count.parse_num::<i32>()?;
if repeats > 9000 {
return Err(ParseBeatmapError::InvalidRepeatCount);
}
repeats = cmp::max(0, repeats - 1);
let repeats = cmp::max(0, repeats - 1) as usize;
if let Some(next) = split.next() {
let new_len = next
@@ -547,22 +547,28 @@ impl DecodeBeatmap for Beatmap {
}
}
let node_sounds = if let Some(sounds) = split.next().map(|sounds| sounds.split('|')) {
sounds.map(|s| s.parse().unwrap_or_default()).collect()
} else {
Box::default()
};
let node_sounds_str = split.next();
let _ = split.next(); // node banks
parse_custom_sound(split.next())?;
let mut node_sounds = vec![sound; repeats + 2].into_boxed_slice();
if let Some(sounds) = node_sounds_str {
sounds
.split('|')
.map(|s| s.parse().unwrap_or_default())
.zip(node_sounds.iter_mut())
.for_each(|(parsed, sound)| *sound = parsed);
}
state.convert_path_str(point_str, pos)?;
let mut control_points = Vec::with_capacity(state.curve_points.len());
control_points.append(&mut state.curve_points);
let slider = Slider {
expected_dist: len,
repeats: repeats as usize,
repeats,
control_points: control_points.into_boxed_slice(),
node_sounds,
};
+7 -7
View File
@@ -65,14 +65,14 @@ fn convert(map: &mut Beatmap) {
kind: HitObjectKind::Circle,
};
let sound = slider
.node_sounds
.get(i)
.copied()
.unwrap_or(map.hit_sounds[idx]);
new_objects.push(h);
new_sounds.push(
slider
.node_sounds
.get(i)
.copied()
.unwrap_or(map.hit_sounds[idx]),
);
new_sounds.push(sound);
if params.tick_spacing.eq(0.0) {
break;