From 14e26d2a850e8e366c25ed0e39456024cca39e42 Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Sun, 25 Jun 2023 22:42:02 +0900 Subject: [PATCH 1/2] use BeatmapCache for populate beatmap information --- osu.Game.Tournament/TournamentGameBase.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index 634cc87a9f..2067295eb6 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -15,6 +15,7 @@ using osu.Framework.Input; using osu.Framework.IO.Stores; using osu.Framework.Logging; using osu.Framework.Platform; +using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Online; using osu.Game.Online.API.Requests; @@ -35,6 +36,7 @@ namespace osu.Game.Tournament private TournamentStorage storage; private DependencyContainer dependencies; private FileBasedIPC ipc; + private BeatmapLookupCache beatmapCache; protected Task BracketLoadTask => bracketLoadTaskCompletionSource.Task; @@ -75,6 +77,8 @@ namespace osu.Game.Tournament Textures.AddTextureSource(new TextureLoaderStore(new StorageBackedResourceStore(storage))); dependencies.CacheAs(new StableInfo(storage)); + + beatmapCache = dependencies.Get(); } protected override void LoadComplete() @@ -241,9 +245,7 @@ namespace osu.Game.Tournament { var b = beatmapsRequiringPopulation[i]; - var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID }); - API.Perform(req); - b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap()); + b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetAwaiter().GetResult() ?? new APIBeatmap()); updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); } @@ -268,9 +270,7 @@ namespace osu.Game.Tournament { var b = beatmapsRequiringPopulation[i]; - var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID }); - API.Perform(req); - b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap()); + b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetAwaiter().GetResult() ?? new APIBeatmap()); updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); } From 1b671b8c6e3296d373d168f643745af660a81399 Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Mon, 26 Jun 2023 00:45:59 +0900 Subject: [PATCH 2/2] Use `GetResultSafely()` --- osu.Game.Tournament/TournamentGameBase.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index 2067295eb6..7d0571dde0 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json; using osu.Framework.Allocation; +using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; using osu.Framework.Input; @@ -245,7 +246,7 @@ namespace osu.Game.Tournament { var b = beatmapsRequiringPopulation[i]; - b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetAwaiter().GetResult() ?? new APIBeatmap()); + b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetResultSafely() ?? new APIBeatmap()); updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); } @@ -270,7 +271,7 @@ namespace osu.Game.Tournament { var b = beatmapsRequiringPopulation[i]; - b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetAwaiter().GetResult() ?? new APIBeatmap()); + b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetResultSafely() ?? new APIBeatmap()); updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); }