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