From 1db0d4f6d4eb7d2b4e8d858958f091541eecbfeb Mon Sep 17 00:00:00 2001 From: tsunyoku Date: Mon, 18 Nov 2024 17:09:42 +0000 Subject: [PATCH] add aim accuracy fix --- Cargo.lock | 12 +++++++++++- Cargo.toml | 1 + src/processor/mod.rs | 27 +++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index bf6afda..644025d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,6 +117,15 @@ dependencies = [ "rosu-mods", ] +[[package]] +name = "akatsuki-pp" +version = "1.1.2" +source = "git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=ee4e33bdc3beff690eed9cda4c8b164a21643a7e#ee4e33bdc3beff690eed9cda4c8b164a21643a7e" +dependencies = [ + "rosu-map", + "rosu-mods", +] + [[package]] name = "allocator-api2" version = "0.2.18" @@ -2095,7 +2104,8 @@ dependencies = [ "akatsuki-pp 1.0.1 (git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=72fa5510ef66898308fc6bb3b2f9d3be1dd606c5)", "akatsuki-pp 1.0.1 (git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=773fc16a60546c92b501ad1782757ab897365227)", "akatsuki-pp 1.0.1 (git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=bb1c8ee99a6788f4706fbadee47894590c4fded6)", - "akatsuki-pp 1.1.2", + "akatsuki-pp 1.1.2 (git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=281ff8816fbabfb22959b6da367264a56a50759e)", + "akatsuki-pp 1.1.2 (git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=ee4e33bdc3beff690eed9cda4c8b164a21643a7e)", "anyhow", "async-trait", "axum", diff --git a/Cargo.toml b/Cargo.toml index e6bf7c9..6b54539 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,4 +59,5 @@ remove-manual-adjustments = { package = "akatsuki-pp", git = "https://github.com fix-inconsistent-powers = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "773fc16a60546c92b501ad1782757ab897365227", features = [ "async_tokio", ] } +aim-accuracy-fix = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "ee4e33bdc3beff690eed9cda4c8b164a21643a7e" } md5 = "0.7.0" diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 4e9e1d0..f24f098 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -19,6 +19,7 @@ use crate::{ usecases, }; +use aim_accuracy_fix::Beatmap as AimAccuracyFixBeatmap; use fix_inconsistent_powers::Beatmap as FixInconsistentPowersBeatmap; use flashlight_hotfix::Beatmap as FlashlightHotfixBeatmap; use improved_miss_penalty::Beatmap as ImprovedMissPenaltyBeatmap; @@ -181,6 +182,31 @@ async fn calculate_fix_inconsistent_powers_pp( Ok(pp) } +async fn calculate_aim_accuracy_fix_pp( + score: &RippleScore, + context: Arc, +) -> anyhow::Result { + let beatmap_bytes = + usecases::beatmaps::fetch_beatmap_osu_file(score.beatmap_id, context).await?; + let beatmap = AimAccuracyFixBeatmap::from_bytes(&beatmap_bytes)?; + + let result = aim_accuracy_fix::osu_2019::OsuPP::from_map(&beatmap) + .mods(score.mods as u32) + .combo(score.max_combo as u32) + .n300(score.count_300 as u32) + .n100(score.count_100 as u32) + .n50(score.count_50 as u32) + .misses(score.count_misses as u32) + .calculate(); + + let mut pp = round(result.pp as f32, 2); + if pp.is_infinite() || pp.is_nan() { + pp = 0.0; + } + + Ok(pp) +} + async fn process_scores( rework: &Rework, scores: Vec, @@ -196,6 +222,7 @@ async fn process_scores( 23 => calculate_stream_nerf_speed_value_pp(score, context.clone()).await?, 24 => calculate_remove_manual_adjustments_pp(score, context.clone()).await?, 25 => calculate_fix_inconsistent_powers_pp(score, context.clone()).await?, + 26 => calculate_aim_accuracy_fix_pp(score, context.clone()).await?, _ => unreachable!(), };