Skip to content

Commit

Permalink
Merge pull request #24037 from cdwcgt/tournament-beatmapcache
Browse files Browse the repository at this point in the history
Use beatmap cache to populate beatmap information in tournament client
  • Loading branch information
peppy authored Jun 26, 2023
2 parents e085a36 + 1b671b8 commit 719ac75
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions osu.Game.Tournament/TournamentGameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
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;
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;
Expand All @@ -35,6 +37,7 @@ public partial class TournamentGameBase : OsuGameBase
private TournamentStorage storage;
private DependencyContainer dependencies;
private FileBasedIPC ipc;
private BeatmapLookupCache beatmapCache;

protected Task BracketLoadTask => bracketLoadTaskCompletionSource.Task;

Expand Down Expand Up @@ -75,6 +78,8 @@ private void load(Storage baseStorage)
Textures.AddTextureSource(new TextureLoaderStore(new StorageBackedResourceStore(storage)));

dependencies.CacheAs(new StableInfo(storage));

beatmapCache = dependencies.Get<BeatmapLookupCache>();
}

protected override void LoadComplete()
Expand Down Expand Up @@ -241,9 +246,7 @@ private bool addRoundBeatmaps()
{
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).GetResultSafely() ?? new APIBeatmap());

updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
}
Expand All @@ -268,9 +271,7 @@ private bool addSeedingBeatmaps()
{
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).GetResultSafely() ?? new APIBeatmap());

updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
}
Expand Down

0 comments on commit 719ac75

Please sign in to comment.