diff --git a/osu.Server.DifficultyCalculator/ServerDifficultyCalculator.cs b/osu.Server.DifficultyCalculator/ServerDifficultyCalculator.cs index d4d24a5..15e28ce 100644 --- a/osu.Server.DifficultyCalculator/ServerDifficultyCalculator.cs +++ b/osu.Server.DifficultyCalculator/ServerDifficultyCalculator.cs @@ -67,7 +67,7 @@ public void Process(WorkingBeatmap beatmap, ProcessingMode mode) public void ProcessLegacyAttributes(WorkingBeatmap beatmap) => run(beatmap, processLegacyAttributes); - private void run(WorkingBeatmap beatmap, Action callback) + private void run(WorkingBeatmap beatmap, Action callback) { try { @@ -89,10 +89,10 @@ private void run(WorkingBeatmap beatmap, Action r.RulesetInfo.OnlineID == beatmap.BeatmapInfo.Ruleset.OnlineID)) - callback(new ProcessableItem(beatmap, beatmap.BeatmapInfo.Ruleset.CreateInstance(), ranked), conn); + callback(new ProcessableBeatmap(beatmap, beatmap.BeatmapInfo.Ruleset.CreateInstance(), ranked), conn); } } catch (Exception e) @@ -101,14 +101,14 @@ private void run(WorkingBeatmap beatmap, Action(); @@ -130,8 +130,8 @@ private void processDifficulty(ProcessableItem item, MySqlConnection conn) { parameters.Add(new { - BeatmapId = item.BeatmapID, - Mode = item.RulesetID, + BeatmapId = beatmap.BeatmapID, + Mode = beatmap.RulesetID, Mods = (int)legacyMods, Attribute = mapping.attributeId, Value = Convert.ToSingle(mapping.value) @@ -145,19 +145,19 @@ private void processDifficulty(ProcessableItem item, MySqlConnection conn) parameters.ToArray()); } - if (legacyMods == LegacyMods.None && item.Ruleset.RulesetInfo.Equals(item.Beatmap.BeatmapInfo.Ruleset)) + if (legacyMods == LegacyMods.None && beatmap.Ruleset.RulesetInfo.Equals(beatmap.Beatmap.BeatmapInfo.Ruleset)) { - double beatLength = item.Beatmap.Beatmap.GetMostCommonBeatLength(); + double beatLength = beatmap.Beatmap.Beatmap.GetMostCommonBeatLength(); double bpm = beatLength > 0 ? 60000 / beatLength : 0; object param = new { - BeatmapId = item.BeatmapID, + BeatmapId = beatmap.BeatmapID, Diff = attribute.StarRating, - AR = item.Beatmap.BeatmapInfo.Difficulty.ApproachRate, - OD = item.Beatmap.BeatmapInfo.Difficulty.OverallDifficulty, - HP = item.Beatmap.BeatmapInfo.Difficulty.DrainRate, - CS = item.Beatmap.BeatmapInfo.Difficulty.CircleSize, + AR = beatmap.Beatmap.BeatmapInfo.Difficulty.ApproachRate, + OD = beatmap.Beatmap.BeatmapInfo.Difficulty.OverallDifficulty, + HP = beatmap.Beatmap.BeatmapInfo.Difficulty.DrainRate, + CS = beatmap.Beatmap.BeatmapInfo.Difficulty.CircleSize, BPM = Math.Round(bpm, 2), MaxCombo = attribute.MaxCombo, }; @@ -181,13 +181,13 @@ private void processDifficulty(ProcessableItem item, MySqlConnection conn) } } - private void processLegacyAttributes(ProcessableItem item, MySqlConnection conn) + private void processLegacyAttributes(ProcessableBeatmap beatmap, MySqlConnection conn) { - Mod? classicMod = item.Ruleset.CreateMod(); + Mod? classicMod = beatmap.Ruleset.CreateMod(); Mod[] mods = classicMod != null ? new[] { classicMod } : Array.Empty(); - ILegacyScoreSimulator simulator = ((ILegacyRuleset)item.Ruleset).CreateLegacyScoreSimulator(); - LegacyScoreAttributes attributes = simulator.Simulate(item.Beatmap, item.Beatmap.GetPlayableBeatmap(item.Ruleset.RulesetInfo, mods)); + ILegacyScoreSimulator simulator = ((ILegacyRuleset)beatmap.Ruleset).CreateLegacyScoreSimulator(); + LegacyScoreAttributes attributes = simulator.Simulate(beatmap.Beatmap, beatmap.Beatmap.GetPlayableBeatmap(beatmap.Ruleset.RulesetInfo, mods)); if (dryRun) return; @@ -198,8 +198,8 @@ private void processLegacyAttributes(ProcessableItem item, MySqlConnection conn) + "ON DUPLICATE KEY UPDATE `legacy_accuracy_score` = @AccuracyScore, `legacy_combo_score` = @ComboScore, `legacy_bonus_score_ratio` = @BonusScoreRatio, `legacy_bonus_score` = @BonusScore, `max_combo` = @MaxCombo", new { - BeatmapId = item.BeatmapID, - Mode = item.RulesetID, + BeatmapId = beatmap.BeatmapID, + Mode = beatmap.RulesetID, AccuracyScore = attributes.AccuracyScore, ComboScore = attributes.ComboScore, BonusScoreRatio = attributes.BonusScoreRatio, @@ -231,7 +231,7 @@ private static List getRulesets() return rulesetsToProcess; } - private readonly record struct ProcessableItem(WorkingBeatmap Beatmap, Ruleset Ruleset, bool Ranked) + private readonly record struct ProcessableBeatmap(WorkingBeatmap Beatmap, Ruleset Ruleset, bool Ranked) { public int BeatmapID => Beatmap.BeatmapInfo.OnlineID; public int RulesetID => Ruleset.RulesetInfo.OnlineID;