Merge pull request #24139 from peppy/fix-tourney-read-bracket

Fix tournament bracket parsing regression
This commit is contained in:
Dean Herbert 2023-07-06 19:03:12 +09:00 committed by GitHub
commit 001d09057e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,6 @@ 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;
@ -94,7 +93,7 @@ namespace osu.Game.Tournament
Task.Run(readBracket);
}
private void readBracket()
private async Task readBracket()
{
try
{
@ -102,7 +101,7 @@ namespace osu.Game.Tournament
{
using (Stream stream = storage.GetStream(BRACKET_FILENAME, FileAccess.Read, FileMode.Open))
using (var sr = new StreamReader(stream))
ladder = JsonConvert.DeserializeObject<LadderInfo>(sr.ReadToEnd(), new JsonPointConverter());
ladder = JsonConvert.DeserializeObject<LadderInfo>(await sr.ReadToEndAsync().ConfigureAwait(false), new JsonPointConverter());
}
ladder ??= new LadderInfo();
@ -166,8 +165,8 @@ namespace osu.Game.Tournament
}
addedInfo |= addPlayers();
addedInfo |= addRoundBeatmaps();
addedInfo |= addSeedingBeatmaps();
addedInfo |= await addRoundBeatmaps().ConfigureAwait(false);
addedInfo |= await addSeedingBeatmaps().ConfigureAwait(false);
if (addedInfo)
saveChanges();
@ -233,7 +232,7 @@ namespace osu.Game.Tournament
/// <summary>
/// Add missing beatmap info based on beatmap IDs
/// </summary>
private bool addRoundBeatmaps()
private async Task<bool> addRoundBeatmaps()
{
var beatmapsRequiringPopulation = ladder.Rounds
.SelectMany(r => r.Beatmaps)
@ -246,7 +245,7 @@ namespace osu.Game.Tournament
{
var b = beatmapsRequiringPopulation[i];
b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetResultSafely() ?? new APIBeatmap());
b.Beatmap = new TournamentBeatmap(await beatmapCache.GetBeatmapAsync(b.ID).ConfigureAwait(false) ?? new APIBeatmap());
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
}
@ -257,7 +256,7 @@ namespace osu.Game.Tournament
/// <summary>
/// Add missing beatmap info based on beatmap IDs
/// </summary>
private bool addSeedingBeatmaps()
private async Task<bool> addSeedingBeatmaps()
{
var beatmapsRequiringPopulation = ladder.Teams
.SelectMany(r => r.SeedingResults)
@ -271,7 +270,7 @@ namespace osu.Game.Tournament
{
var b = beatmapsRequiringPopulation[i];
b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetResultSafely() ?? new APIBeatmap());
b.Beatmap = new TournamentBeatmap(await beatmapCache.GetBeatmapAsync(b.ID).ConfigureAwait(false) ?? new APIBeatmap());
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
}