fixed object count in map attributes of converted maps

This commit is contained in:
Max
2023-01-28 18:59:28 +01:00
parent 92cf2e9bfc
commit 8ab467b2c7
2 changed files with 11 additions and 5 deletions
+8 -2
View File
@@ -1,3 +1,5 @@
use std::borrow::Cow;
use pyo3::{
exceptions::{PyTypeError, PyValueError},
pyclass, pymethods,
@@ -192,7 +194,11 @@ impl PyCalculator {
}
fn map_attributes(&self, map: &PyBeatmap) -> PyResult<PyBeatmapAttributes> {
let map = &map.inner;
let (map, mode) = match self.mode {
Some(mode) => (map.inner.convert_mode(mode), mode),
None => (Cow::Borrowed(&map.inner), map.inner.mode),
};
let mut calc = map.attributes();
if let Some(mode) = self.mode {
@@ -211,7 +217,7 @@ impl PyCalculator {
calc.clock_rate(clock_rate);
}
Ok(PyBeatmapAttributes::new(calc.build(), map))
Ok(PyBeatmapAttributes::new(calc.build(), mode, map.as_ref()))
}
fn difficulty(&self, map: &PyBeatmap) -> PyResult<PyDifficultyAttributes> {
+3 -3
View File
@@ -1,7 +1,7 @@
use std::fmt::{Display, Formatter, Result as FmtResult};
use pyo3::{pyclass, pymethods};
use rosu_pp::{beatmap::BeatmapAttributes, Beatmap};
use rosu_pp::{beatmap::BeatmapAttributes, Beatmap, GameMode};
#[pyclass(name = "BeatmapAttributes")]
pub struct PyBeatmapAttributes {
@@ -34,7 +34,7 @@ pub struct PyBeatmapAttributes {
}
impl PyBeatmapAttributes {
pub fn new(attrs: BeatmapAttributes, map: &Beatmap) -> Self {
pub fn new(attrs: BeatmapAttributes, mode: GameMode, map: &Beatmap) -> Self {
Self {
ar: attrs.ar,
cs: attrs.cs,
@@ -44,7 +44,7 @@ impl PyBeatmapAttributes {
od_hit_window: attrs.hit_windows.od,
clock_rate: attrs.clock_rate,
bpm: map.bpm() * attrs.clock_rate,
mode: map.mode as u8,
mode: mode as u8,
version: map.version,
n_circles: map.n_circles,
n_sliders: map.n_sliders,