mania: ensure columns index is valid
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
## Upcoming
|
||||
|
||||
- Reduced amount of required features of `async_std` and `async_tokio`
|
||||
- Fixed a panic for some mania difficulty calculations on converts
|
||||
|
||||
# v0.2.2
|
||||
|
||||
|
||||
+5
-4
@@ -47,6 +47,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> S
|
||||
let clock_rate = mods.speed();
|
||||
let section_len = SECTION_LEN * clock_rate;
|
||||
let mut strain = Strain::new(columns);
|
||||
let columns = columns as f32;
|
||||
|
||||
let mut hit_objects = map
|
||||
.hit_objects
|
||||
@@ -54,7 +55,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> S
|
||||
.take(take)
|
||||
.skip(1)
|
||||
.zip(map.hit_objects.iter())
|
||||
.map(|(base, prev)| DifficultyHitObject::new(base, prev, map.cs, clock_rate));
|
||||
.map(|(base, prev)| DifficultyHitObject::new(base, prev, columns, clock_rate));
|
||||
|
||||
// No strain for first object
|
||||
let mut current_section_end =
|
||||
@@ -150,9 +151,9 @@ pub(crate) struct DifficultyHitObject<'o> {
|
||||
|
||||
impl<'o> DifficultyHitObject<'o> {
|
||||
#[inline]
|
||||
fn new(base: &'o HitObject, prev: &'o HitObject, cs: f32, clock_rate: f32) -> Self {
|
||||
let x_divisor = 512.0 / cs;
|
||||
let column = (base.pos.x / x_divisor).floor() as usize;
|
||||
fn new(base: &'o HitObject, prev: &'o HitObject, columns: f32, clock_rate: f32) -> Self {
|
||||
let x_divisor = 512.0 / columns;
|
||||
let column = (base.pos.x / x_divisor).floor().min(columns - 1.0) as usize;
|
||||
|
||||
Self {
|
||||
base,
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ impl Strain {
|
||||
let mut hold_addition = 0.0;
|
||||
|
||||
for col in 0..self.hold_end_times.len() {
|
||||
let hold_end_time = self.hold_end_times[col as usize];
|
||||
let hold_end_time = self.hold_end_times[col];
|
||||
|
||||
if end_time > hold_end_time + 1.0 {
|
||||
if hold_end_time > current.base.start_time + 1.0 {
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ impl fmt::Display for ParseError {
|
||||
)))]
|
||||
Self::UnincludedMode(mode) => write!(
|
||||
f,
|
||||
"cannot process {:?} map its mode's feature has not been included",
|
||||
"cannot process {:?} map; its mode's feature has not been included",
|
||||
mode
|
||||
),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user