From 7bab48762190b888dda9bb40c2c228397c0b1ac4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 4 Nov 2021 16:17:50 +0900 Subject: [PATCH 1/4] Remove usage of `ToBeatmapInfo` in `APIScoreInfo.CreateScoreInfo` --- osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs b/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs index 5395fe0429..82f56d27fd 100644 --- a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs +++ b/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs @@ -98,7 +98,7 @@ namespace osu.Game.Online.API.Requests.Responses { TotalScore = TotalScore, MaxCombo = MaxCombo, - BeatmapInfo = Beatmap?.ToBeatmapInfo(rulesets), + BeatmapInfo = beatmap, User = User, Accuracy = Accuracy, OnlineScoreID = OnlineID, @@ -111,9 +111,6 @@ namespace osu.Game.Online.API.Requests.Responses Mods = modInstances, }; - if (beatmap != null) - scoreInfo.BeatmapInfo = beatmap; - if (Statistics != null) { foreach (var kvp in Statistics) From 08d94f864ff7bf50fbf0c9d251fe9a99c7a19675 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 1 Nov 2021 15:43:34 +0900 Subject: [PATCH 2/4] Update `ScoresContainer` to not use `ToBeatmapInfo` --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 4a00c8b4a0..3891d68d35 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -66,7 +66,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (value?.Scores.Any() != true) return; - scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, Beatmap.Value.ToBeatmapInfo(rulesets))).ToArray(), loadCancellationSource.Token) + // TODO: temporary. should be removed once `OrderByTotalScore` can accept `IScoreInfo`. + var beatmapInfo = new BeatmapInfo { MaxCombo = Beatmap.Value.MaxCombo }; + + scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, beatmapInfo)).ToArray(), loadCancellationSource.Token) .ContinueWith(ordered => Schedule(() => { if (loadCancellationSource.IsCancellationRequested) @@ -78,7 +81,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores scoreTable.Show(); var userScore = value.UserScore; - var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets, Beatmap.Value.ToBeatmapInfo(rulesets)); + var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets, beatmapInfo); topScoresContainer.Add(new DrawableTopScore(topScore)); From eb17d897a36166e39b0ec714d23901dae3479582 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 1 Nov 2021 15:37:38 +0900 Subject: [PATCH 3/4] Finally, remove the `To*` methods as they have no usages --- .../API/Requests/Responses/APIBeatmap.cs | 28 ------------------- .../API/Requests/Responses/APIBeatmapSet.cs | 22 --------------- 2 files changed, 50 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs index 653b011f73..2560502173 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs @@ -81,34 +81,6 @@ namespace osu.Game.Online.API.Requests.Responses public double BPM { get; set; } - public virtual BeatmapInfo ToBeatmapInfo(RulesetStore rulesets) - { - var set = BeatmapSet?.ToBeatmapSet(rulesets); - - return new BeatmapInfo - { - Metadata = set?.Metadata ?? new BeatmapMetadata(), - Ruleset = rulesets.GetRuleset(RulesetID), - StarDifficulty = StarRating, - OnlineBeatmapID = OnlineID, - Version = DifficultyName, - // this is actually an incorrect mapping (Length is calculated as drain length in lazer's import process, see BeatmapManager.calculateLength). - Length = Length, - Status = Status, - MD5Hash = Checksum, - BeatmapSet = set, - MaxCombo = MaxCombo, - BaseDifficulty = new BeatmapDifficulty - { - DrainRate = DrainRate, - CircleSize = CircleSize, - ApproachRate = ApproachRate, - OverallDifficulty = OverallDifficulty, - }, - OnlineInfo = this, - }; - } - #region Implementation of IBeatmapInfo public IBeatmapMetadataInfo Metadata => (BeatmapSet as IBeatmapSetInfo)?.Metadata ?? new BeatmapMetadata(); diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs index c41271ad5c..47536879b2 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs @@ -3,11 +3,9 @@ using System; using System.Collections.Generic; -using System.Linq; using Newtonsoft.Json; using osu.Game.Beatmaps; using osu.Game.Database; -using osu.Game.Rulesets; using osu.Game.Users; #nullable enable @@ -121,26 +119,6 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty(@"beatmaps")] public APIBeatmap[] Beatmaps { get; set; } = Array.Empty(); - public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets) - { - var beatmapSet = new BeatmapSetInfo - { - OnlineBeatmapSetID = OnlineID, - Metadata = metadata, - Status = Status, - }; - - beatmapSet.Beatmaps = Beatmaps.Select(b => - { - var beatmap = b.ToBeatmapInfo(rulesets); - beatmap.BeatmapSet = beatmapSet; - beatmap.Metadata = beatmapSet.Metadata; - return beatmap; - }).ToList(); - - return beatmapSet; - } - private BeatmapMetadata metadata => new BeatmapMetadata { Title = Title, From 9f9ef570ee86edcf32a6af143a2a1f15e1e838e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 Nov 2021 14:40:22 +0900 Subject: [PATCH 4/4] Also propagate `Status` in temporary `BeatmapInfo` usage --- .../Overlays/BeatmapSet/Scores/ScoresContainer.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 3891d68d35..69739b3352 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -66,8 +67,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (value?.Scores.Any() != true) return; + var apiBeatmap = Beatmap.Value; + + Debug.Assert(apiBeatmap != null); + // TODO: temporary. should be removed once `OrderByTotalScore` can accept `IScoreInfo`. - var beatmapInfo = new BeatmapInfo { MaxCombo = Beatmap.Value.MaxCombo }; + var beatmapInfo = new BeatmapInfo + { + MaxCombo = apiBeatmap.MaxCombo, + Status = apiBeatmap.Status + }; scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, beatmapInfo)).ToArray(), loadCancellationSource.Token) .ContinueWith(ordered => Schedule(() => @@ -77,7 +86,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores var topScore = ordered.Result.First(); - scoreTable.DisplayScores(ordered.Result, topScore.BeatmapInfo?.Status.GrantsPerformancePoints() == true); + scoreTable.DisplayScores(ordered.Result, apiBeatmap.Status.GrantsPerformancePoints()); scoreTable.Show(); var userScore = value.UserScore;