From 0ab50f1cc9af44d2accd2d0bf8d720f614cb5dd4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 4 Nov 2021 13:45:59 +0900 Subject: [PATCH] Add inline comment explaining why we are manually populating `beatmap.BeatmapSet` --- osu.Game/Online/Multiplayer/MultiplayerClient.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index b80253684e..6c4747ea54 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -645,12 +645,19 @@ namespace osu.Game.Online.Multiplayer RoomUpdated?.Invoke(); - GetOnlineBeatmapSet(settings.BeatmapID, cancellationToken).ContinueWith(set => Schedule(() => + GetOnlineBeatmapSet(settings.BeatmapID, cancellationToken).ContinueWith(task => Schedule(() => { if (cancellationToken.IsCancellationRequested) return; - updatePlaylist(settings, set.Result); + APIBeatmapSet beatmapSet = task.Result; + + // The incoming response is deserialised without circular reference handling currently. + // Because we require using metadata from this instance, populate the nested beatmaps' sets manually here. + foreach (var b in beatmapSet.Beatmaps) + b.BeatmapSet = beatmapSet; + + updatePlaylist(settings, beatmapSet); }), TaskContinuationOptions.OnlyOnRanToCompletion); }, cancellationToken); @@ -664,7 +671,6 @@ namespace osu.Game.Online.Multiplayer var beatmap = beatmapSet.Beatmaps.Single(b => b.OnlineID == settings.BeatmapID); beatmap.Checksum = settings.BeatmapChecksum; - beatmap.BeatmapSet = beatmapSet; var ruleset = Rulesets.GetRuleset(settings.RulesetID).CreateInstance(); var mods = settings.RequiredMods.Select(m => m.ToMod(ruleset));