From f36b495f22e9319e8337aa7e26724826054cc038 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 4 Sep 2023 19:32:37 +0900 Subject: [PATCH 1/2] Split scoring attributes into its own table --- .../Commands/Queue/ImportHighScoresCommand.cs | 37 ++++--------------- .../Models/BeatmapScoringAttributes.cs | 34 +++++++++++++++++ 2 files changed, 41 insertions(+), 30 deletions(-) create mode 100644 osu.Server.Queues.ScoreStatisticsProcessor/Models/BeatmapScoringAttributes.cs diff --git a/osu.Server.Queues.ScoreStatisticsProcessor/Commands/Queue/ImportHighScoresCommand.cs b/osu.Server.Queues.ScoreStatisticsProcessor/Commands/Queue/ImportHighScoresCommand.cs index 376ece0d..2145e2c1 100644 --- a/osu.Server.Queues.ScoreStatisticsProcessor/Commands/Queue/ImportHighScoresCommand.cs +++ b/osu.Server.Queues.ScoreStatisticsProcessor/Commands/Queue/ImportHighScoresCommand.cs @@ -18,7 +18,6 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets; -using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; @@ -570,42 +569,20 @@ private async Task createReferenceScore(Ruleset ruleset, HighScore hi return scoreInfo; } - const int legacy_accuracy_score = 23; - const int legacy_combo_score = 25; - const int legacy_bonus_score_ratio = 27; - - if (!dbAttributes.ContainsKey(legacy_accuracy_score) || !dbAttributes.ContainsKey(legacy_combo_score) || !dbAttributes.ContainsKey(legacy_bonus_score_ratio)) - { - await Console.Error.WriteLineAsync($"{highScore.score_id}: Could not find legacy scoring values in the difficulty attributes of beatmap {highScore.beatmap_id}."); - return scoreInfo; - } - #pragma warning disable CS0618 // Pad the maximum combo. if ((int)maxComboAttribute.value > maxComboFromStatistics) scoreInfo.MaximumStatistics[HitResult.LegacyComboIncrease] = (int)maxComboAttribute.value - maxComboFromStatistics; #pragma warning restore CS0618 - int maximumLegacyAccuracyScore = (int)dbAttributes[legacy_accuracy_score].value; - int maximumLegacyComboScore = (int)dbAttributes[legacy_combo_score].value; - double maximumLegacyBonusRatio = dbAttributes[legacy_bonus_score_ratio].value; - - // Although the combo-multiplied portion is stored into difficulty attributes, attributes are only present for mod combinations that affect difficulty. - // For example, an incoming highscore may be +HDHR, but only difficulty attributes for +HR exist in the database. - // To handle this case, the combo-multiplied portion is readjusted with the new mod multiplier. - if (difficultyMods != highScore.enabled_mods) - { - double difficultyAdjustmentModMultiplier = ruleset.ConvertFromLegacyMods((LegacyMods)difficultyMods).Select(m => m.ScoreMultiplier).Aggregate(1.0, (c, n) => c * n); - double modMultiplier = scoreInfo.Mods.Select(m => m.ScoreMultiplier).Aggregate(1.0, (c, n) => c * n); - maximumLegacyComboScore = (int)Math.Round(maximumLegacyComboScore * modMultiplier / difficultyAdjustmentModMultiplier); - } + BeatmapScoringAttributes scoreAttributes = await connection.QuerySingleAsync( + "SELECT * FROM osu_beatmap_scoring_attribs WHERE beatmap_id = @BeatmapId AND mode = @RulesetId", new + { + BeatmapId = highScore.beatmap_id, + RulesetId = ruleset.RulesetInfo.OnlineID + }, transaction); - scoreInfo.TotalScore = StandardisedScoreMigrationTools.ConvertFromLegacyTotalScore(scoreInfo, new DifficultyAttributes - { - LegacyAccuracyScore = maximumLegacyAccuracyScore, - LegacyComboScore = maximumLegacyComboScore, - LegacyBonusScoreRatio = maximumLegacyBonusRatio - }); + scoreInfo.TotalScore = StandardisedScoreMigrationTools.ConvertFromLegacyTotalScore(scoreInfo, scoreAttributes.ToAttributes()); int baseScore = scoreInfo.Statistics.Where(kvp => kvp.Key.AffectsAccuracy()).Sum(kvp => kvp.Value * Judgement.ToNumericResult(kvp.Key)); int maxBaseScore = scoreInfo.MaximumStatistics.Where(kvp => kvp.Key.AffectsAccuracy()).Sum(kvp => kvp.Value * Judgement.ToNumericResult(kvp.Key)); diff --git a/osu.Server.Queues.ScoreStatisticsProcessor/Models/BeatmapScoringAttributes.cs b/osu.Server.Queues.ScoreStatisticsProcessor/Models/BeatmapScoringAttributes.cs new file mode 100644 index 00000000..7bb39803 --- /dev/null +++ b/osu.Server.Queues.ScoreStatisticsProcessor/Models/BeatmapScoringAttributes.cs @@ -0,0 +1,34 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Diagnostics.CodeAnalysis; +using Dapper.Contrib.Extensions; +using osu.Game.Rulesets.Scoring.Legacy; + +namespace osu.Server.Queues.ScoreStatisticsProcessor.Models +{ + [SuppressMessage("ReSharper", "InconsistentNaming")] + [Serializable] + [Table("osu_beatmap_scoring_attribs")] + public class BeatmapScoringAttributes + { + [ExplicitKey] + public uint beatmap_id { get; set; } + + public ushort mode { get; set; } + + public int legacy_accuracy_score { get; set; } + + public long legacy_combo_score { get; set; } + + public float legacy_bonus_score_ratio { get; set; } + + public LegacyScoreAttributes ToAttributes() => new LegacyScoreAttributes + { + AccuracyScore = legacy_accuracy_score, + ComboScore = legacy_combo_score, + BonusScoreRatio = legacy_bonus_score_ratio + }; + } +} From 84d8f14d25ed1d52f71b0110e582fb9b8ebc8f09 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Sep 2023 13:35:28 +0900 Subject: [PATCH 2/2] Update game and other libraries --- ...er.Queues.ScoreStatisticsProcessor.Tests.csproj | 8 ++++---- ...u.Server.Queues.ScoreStatisticsProcessor.csproj | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Server.Queues.ScoreStatisticsProcessor.Tests/osu.Server.Queues.ScoreStatisticsProcessor.Tests.csproj b/osu.Server.Queues.ScoreStatisticsProcessor.Tests/osu.Server.Queues.ScoreStatisticsProcessor.Tests.csproj index 72a54f69..d3d1afc3 100644 --- a/osu.Server.Queues.ScoreStatisticsProcessor.Tests/osu.Server.Queues.ScoreStatisticsProcessor.Tests.csproj +++ b/osu.Server.Queues.ScoreStatisticsProcessor.Tests/osu.Server.Queues.ScoreStatisticsProcessor.Tests.csproj @@ -8,13 +8,13 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/osu.Server.Queues.ScoreStatisticsProcessor/osu.Server.Queues.ScoreStatisticsProcessor.csproj b/osu.Server.Queues.ScoreStatisticsProcessor/osu.Server.Queues.ScoreStatisticsProcessor.csproj index c078a872..e0afedf9 100644 --- a/osu.Server.Queues.ScoreStatisticsProcessor/osu.Server.Queues.ScoreStatisticsProcessor.csproj +++ b/osu.Server.Queues.ScoreStatisticsProcessor/osu.Server.Queues.ScoreStatisticsProcessor.csproj @@ -9,14 +9,14 @@ - + - - - - - - + + + + + +