Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use beatmap cache to populate beatmap information in tournament client #24037

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions osu.Game.Tournament/TournamentGameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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 +36,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 +77,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 +245,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).GetAwaiter().GetResult() ?? new APIBeatmap());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this GetAwaiter().GetResult() stuff an attempt to bypass the fact that .Result is banned? If yes, then did you try calling .GetResultSafely() which is a framework extension for this express purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this should be my oversight, sorry

already fix


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

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