Skip to content

Commit 1d15b40

Browse files
authored
refactor: log suspicion fails (#1116)
1 parent 01c525a commit 1d15b40

8 files changed

Lines changed: 31 additions & 13 deletions

File tree

bathbot/src/active/impls/bookmarks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl BookmarksPagination {
190190
let mut max_pp = 0.0;
191191

192192
if let Some(pp_map) = pp_map {
193-
let attrs_opt = Context::pp_parsed(pp_map, map.mode)
193+
let attrs_opt = Context::pp_parsed(pp_map, map.map_id, map.mode)
194194
.lazer(true)
195195
.performance()
196196
.await;
@@ -262,7 +262,7 @@ impl BookmarksPagination {
262262
let mut pp_97 = 0.0;
263263

264264
if let Some(pp_map) = pp_map {
265-
let attrs_opt = Context::pp_parsed(pp_map, map.mode)
265+
let attrs_opt = Context::pp_parsed(pp_map, map.map_id, map.mode)
266266
.lazer(true)
267267
.performance()
268268
.await;

bathbot/src/active/impls/snipe/difference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl IActiveMessage for SnipeDifferencePagination {
6767
.await
6868
.wrap_err("Failed to get pp map")?;
6969

70-
let stars = Context::pp_parsed(&map, GameMode::Osu)
70+
let stars = Context::pp_parsed(&map, score.map_id, GameMode::Osu)
7171
.difficulty()
7272
.await
7373
.map_or(0.0, DifficultyAttributes::stars);

bathbot/src/commands/osu/cards.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async fn card(orig: CommandOrigin<'_>, args: Card<'_>) -> Result<()> {
236236
.await
237237
.wrap_err("Failed to get pp map")?;
238238

239-
let difficulty = Context::pp_parsed(&map, mode)
239+
let difficulty = Context::pp_parsed(&map, score.map_id, mode)
240240
.lazer(score.set_on_lazer)
241241
.mods(score.mods.clone())
242242
.difficulty()

bathbot/src/commands/osu/recent/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ async fn process_scores(
572572
stars = attrs.stars() as f32;
573573
max_combo = attrs.max_combo();
574574

575-
let mut calc = Context::pp_parsed(pp_map, score.mode)
575+
let mut calc = Context::pp_parsed(pp_map, score.map_id, score.mode)
576576
.mode(score.mode)
577577
.mods(score.mods.clone())
578578
.lazer(score.set_on_lazer);

bathbot/src/core/context/manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ impl Context {
2727
PpManager::new(map)
2828
}
2929

30-
pub fn pp_parsed(map: &Beatmap, mode: GameMode) -> PpManager<'_> {
31-
PpManager::from_parsed(map).mode(mode)
30+
pub fn pp_parsed(map: &Beatmap, map_id: u32, mode: GameMode) -> PpManager<'_> {
31+
PpManager::from_parsed(map, map_id).mode(mode)
3232
}
3333

3434
pub fn approx() -> ApproxManager {

bathbot/src/core/context/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,14 @@ impl Context {
239239

240240
let ordr = match tokio::time::timeout(Duration::from_secs(20), ordr_fut).await {
241241
Ok(Ok(ordr)) => Some(Arc::new(ordr)),
242-
Ok(Err(err)) => return Err(err),
242+
Ok(Err(err)) => {
243+
error!(
244+
?err,
245+
"Failed to create ordr client, initializing without it"
246+
);
247+
248+
None
249+
}
243250
Err(_) => {
244251
warn!("o!rdr timed out, initializing without it");
245252

bathbot/src/manager/osu_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl MapManager {
9090
) -> Result<Option<DifficultyAttributes>> {
9191
let map = this.pp_map(map_id).await.wrap_err("Failed to get pp map")?;
9292

93-
let attrs = PpManager::from_parsed(&map)
93+
let attrs = PpManager::from_parsed(&map, map_id)
9494
.mode(mode)
9595
.mods(mods)
9696
.difficulty()

bathbot/src/manager/pp.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::commands::{osu::LeaderboardScore, utility::ScoreEmbedDataRaw};
1717
#[derive(Clone)]
1818
pub struct PpManager<'m> {
1919
map: Cow<'m, Beatmap>,
20+
map_id: u32,
2021
attrs: Option<DifficultyAttributes>,
2122
mods: Mods,
2223
state: Option<ScoreState>,
@@ -26,14 +27,15 @@ pub struct PpManager<'m> {
2627

2728
impl<'m> PpManager<'m> {
2829
pub fn new(map: &'m OsuMap) -> Self {
29-
Self::from_parsed(&map.pp_map)
30+
Self::from_parsed(&map.pp_map, map.map_id())
3031
}
3132

32-
pub fn from_parsed(map: &'m Beatmap) -> Self {
33+
pub fn from_parsed(map: &'m Beatmap, map_id: u32) -> Self {
3334
// Cannot check for suspicion yet because the mode might still change
3435

3536
Self {
3637
map: Cow::Borrowed(map),
38+
map_id,
3739
attrs: None,
3840
mods: Mods::default(),
3941
state: None,
@@ -123,7 +125,16 @@ impl<'m> PpManager<'m> {
123125
return Some(attrs);
124126
}
125127

126-
if self.map.check_suspicion().is_err() {
128+
if let Err(reason) = self.map.check_suspicion() {
129+
warn!(
130+
?reason,
131+
map_id = self.map_id,
132+
mods = ?self.mods.inner,
133+
clock_rate = self.mods.clock_rate,
134+
lazer = self.lazer,
135+
"Suspicion check failed",
136+
);
137+
127138
return None;
128139
}
129140

@@ -308,7 +319,7 @@ fn stats_to_state(max_combo: u32, mode: GameMode, stats: &ScoreStatistics) -> Sc
308319
}
309320

310321
/// Mods with an optional custom clock rate.
311-
#[derive(Clone, Default, PartialEq)]
322+
#[derive(Clone, Debug, Default, PartialEq)]
312323
pub struct Mods {
313324
pub inner: rosu_pp::GameMods,
314325
pub clock_rate: Option<f64>,

0 commit comments

Comments
 (0)