diff --git a/Cargo.lock b/Cargo.lock index 1f2ab06..debb337 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1807,10 +1807,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c55926c8f0fed1db12fbe96f7a6083a2c4186443dd32532ab34e6902467a4f3" [[package]] -name = "rosu-mods" -version = "0.1.0" +name = "rosu-map" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d69daf02885f7477085403a6eada6215f44333c7b54355ea1c4e276a02263bde" +checksum = "21de4f8c5cd2738e1c9a2ed477aad2579dacd5acf3845d80738fcec160d0bd8a" + +[[package]] +name = "rosu-mods" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0fb1475e860c987673e8abc1df5d23f22c4e1ae62e9459e656cff4d82f603b" dependencies = [ "paste", "serde", @@ -1819,17 +1825,16 @@ dependencies = [ [[package]] name = "rosu-pp" version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a6b12cedcb185f4051f0b3d0466e0b61ff414a9ca8375f09be581c0e70f06" +source = "git+https://github.com/MaxOhn/rosu-pp?branch=main#9f45d9594d08ba79d3c1c73ec43aef2fd7b54c0d" dependencies = [ - "rosu-map", + "rosu-map 0.2.0", "rosu-mods", ] [[package]] name = "rosu-v2" version = "0.9.0" -source = "git+https://github.com/MaxOhn/rosu-v2?branch=lazer#04744c606962f21824d7398f1c15c34fe7fa9eef" +source = "git+https://github.com/MaxOhn/rosu-v2?branch=lazer#4552ffa6e4e8d375c4a6f0a4cc2d21c4f61a129f" dependencies = [ "bytes", "dashmap 6.0.1", @@ -3310,7 +3315,7 @@ dependencies = [ "rand", "regex", "reqwest", - "rosu-map", + "rosu-map 0.1.1", "rosu-pp", "rosu-v2", "serde", diff --git a/youmubot-osu/Cargo.toml b/youmubot-osu/Cargo.toml index 8d8b430..70b5e0b 100644 --- a/youmubot-osu/Cargo.toml +++ b/youmubot-osu/Cargo.toml @@ -14,7 +14,7 @@ dashmap = "5.3.4" lazy_static = "1.4.0" regex = "1.5.6" reqwest = "0.11.10" -rosu-pp = "1.1" +rosu-pp = { git = "https://github.com/MaxOhn/rosu-pp", branch = "main" } rosu-v2 = { git = "https://github.com/MaxOhn/rosu-v2", branch = "lazer" } rosu-map = "0.1" time = "0.3" diff --git a/youmubot-osu/src/discord/link_parser.rs b/youmubot-osu/src/discord/link_parser.rs index 7010aae..2f7075c 100644 --- a/youmubot-osu/src/discord/link_parser.rs +++ b/youmubot-osu/src/discord/link_parser.rs @@ -23,13 +23,13 @@ pub struct ToPrint<'a> { lazy_static! { // Beatmap(set) hooks static ref OLD_LINK_REGEX: Regex = Regex::new( - r"(?:https?://)?osu\.ppy\.sh/(?Ps|b|beatmaps)/(?P\d+)(?:[\&\?]m=(?P[0123]))?(?:\+(?P[A-Z]+))?" + r"(?:https?://)?osu\.ppy\.sh/(?Ps|b|beatmaps)/(?P\d+)(?:[\&\?]m=(?P[0123]))?(?:\+(?P\S+\b))?" ).unwrap(); static ref NEW_LINK_REGEX: Regex = Regex::new( - r"(?:https?://)?osu\.ppy\.sh/beatmapsets/(?P\d+)/?(?:\#(?Posu|taiko|fruits|mania)(?:/(?P\d+)|/?))?(?:\+(?P[A-Z]+))?" + r"(?:https?://)?osu\.ppy\.sh/beatmapsets/(?P\d+)/?(?:\#(?Posu|taiko|fruits|mania)(?:/(?P\d+)|/?))?(?:\+(?P\S+\b))?" ).unwrap(); static ref SHORT_LINK_REGEX: Regex = Regex::new( - r"(?:^|\s|\W)(?P
/b/(?P\d+)(?:/(?Posu|taiko|fruits|mania))?(?:\+(?P[A-Z]+))?)" + r"(?:^|\s|\W)(?P
/b/(?P\d+)(?:/(?Posu|taiko|fruits|mania))?(?:\+(?P\S+\b))?)" ).unwrap(); // Score hook diff --git a/youmubot-osu/src/models/mod.rs b/youmubot-osu/src/models/mod.rs index 877a85d..16e560d 100644 --- a/youmubot-osu/src/models/mod.rs +++ b/youmubot-osu/src/models/mod.rs @@ -424,7 +424,7 @@ impl Beatmap { Some(mode) if mode != self.mode => format!("/{}", mode.as_str_new_site()), _ => "".to_owned(), }, - mods.strip_lazer(override_mode.unwrap_or(Mode::Std)) + mods ) } diff --git a/youmubot-osu/src/models/mods.rs b/youmubot-osu/src/models/mods.rs index eddcfac..65f4001 100644 --- a/youmubot-osu/src/models/mods.rs +++ b/youmubot-osu/src/models/mods.rs @@ -23,7 +23,7 @@ lazy_static::lazy_static! { #[derive(Debug, Clone, PartialEq, Default)] pub struct UnparsedMods { mods: Cow<'static, str>, - clock: Option, + clock: Option, } impl FromStr for UnparsedMods { @@ -47,7 +47,7 @@ impl FromStr for UnparsedMods { mods: mods.map(|v| v.into()).unwrap_or("".into()), clock: ms .name("clock") - .map(|v| v.as_str().parse::().unwrap()) + .map(|v| v.as_str().parse::<_>().unwrap()) .filter(|v| *v > 0.0), }) } @@ -149,13 +149,8 @@ pub struct Stats { } impl Stats { - pub fn from_f32(ar: Option, od: Option, hp: Option, cs: Option) -> Self { - Self { - ar: ar.map(|v| v as f64), - od: od.map(|v| v as f64), - hp: hp.map(|v| v as f64), - cs: cs.map(|v| v as f64), - } + pub fn from_option(ar: Option, od: Option, hp: Option, cs: Option) -> Self { + Self { ar, od, hp, cs } } pub fn has_any(&self) -> bool { @@ -168,26 +163,20 @@ impl Mods { inner: GameMods::new(), }; - pub fn strip_lazer(&self, mode: Mode) -> Self { - let mut m = self.clone(); - m.inner.insert(Self::classic_mod_of(mode)); - m - } - - fn classic_mod_of(mode: Mode) -> rosu::GameMod { - match mode { - Mode::Std => rosu::GameMod::ClassicOsu(rosu::generated_mods::ClassicOsu::default()), - Mode::Taiko => { - rosu::GameMod::ClassicTaiko(rosu::generated_mods::ClassicTaiko::default()) - } - Mode::Catch => { - rosu::GameMod::ClassicCatch(rosu::generated_mods::ClassicCatch::default()) - } - Mode::Mania => { - rosu::GameMod::ClassicMania(rosu::generated_mods::ClassicMania::default()) - } - } - } + // fn classic_mod_of(mode: Mode) -> rosu::GameMod { + // match mode { + // Mode::Std => rosu::GameMod::ClassicOsu(rosu::generated_mods::ClassicOsu::default()), + // Mode::Taiko => { + // rosu::GameMod::ClassicTaiko(rosu::generated_mods::ClassicTaiko::default()) + // } + // Mode::Catch => { + // rosu::GameMod::ClassicCatch(rosu::generated_mods::ClassicCatch::default()) + // } + // Mode::Mania => { + // rosu::GameMod::ClassicMania(rosu::generated_mods::ClassicMania::default()) + // } + // } + // } pub fn overrides(&self) -> Stats { use rosu_v2::prelude::GameMod::*; @@ -195,23 +184,23 @@ impl Mods { .iter() .find_map(|m| { Some(match m { - DifficultyAdjustOsu(da) => Stats::from_f32( + DifficultyAdjustOsu(da) => Stats::from_option( da.approach_rate, da.overall_difficulty, da.drain_rate, da.circle_size, ), DifficultyAdjustTaiko(da) => { - Stats::from_f32(None, da.overall_difficulty, da.drain_rate, None) + Stats::from_option(None, da.overall_difficulty, da.drain_rate, None) } - DifficultyAdjustCatch(da) => Stats::from_f32( + DifficultyAdjustCatch(da) => Stats::from_option( da.approach_rate, da.overall_difficulty, da.drain_rate, da.circle_size, ), DifficultyAdjustMania(da) => { - Stats::from_f32(None, da.overall_difficulty, da.drain_rate, None) + Stats::from_option(None, da.overall_difficulty, da.drain_rate, None) } _ => return None, }) @@ -329,7 +318,7 @@ impl Mods { use rosu::GameMod::*; fn fmt_speed_change( mod_name: &str, - speed_change: &Option, + speed_change: &Option, adjust_pitch: &Option, ) -> Option { if speed_change.is_none() && adjust_pitch.is_none() { @@ -350,10 +339,10 @@ impl Mods { Some(s) } fn fmt_diff_adj( - ar: Option, - od: Option, - hp: Option, - cs: Option, + ar: Option, + od: Option, + hp: Option, + cs: Option, ) -> Option { let stats = [("AR", ar), ("OD", od), ("HP", hp), ("CS", cs)]; let mut output = String::with_capacity(4 * (2 + 3 + 4) + 3 * 2); @@ -423,11 +412,11 @@ impl Mods { } let intermode = GameModsIntermode::try_from_acronyms(s).ok_or_else(|| error!("Invalid mods: {}", s))?; - let mut inner = intermode + let inner = intermode .try_with_mode(mode.into()) .ok_or_else(|| error!("Invalid mods for `{}`: {}", mode, intermode))?; // Always add classic mod to `inner` - inner.insert(Self::classic_mod_of(mode)); + // inner.insert(Self::classic_mod_of(mode)); if !inner.is_valid() { return Err(error!("Incompatible mods found: {}", inner)); }