Use already populated beatmap values if available

This commit is contained in:
Dean Herbert 2018-11-17 15:18:22 +09:00
parent 5659ba6ef8
commit aebece3d89
1 changed files with 13 additions and 5 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Logging;
using osu.Framework.Platform.Windows;
@ -25,9 +26,8 @@ public class FileBasedIPC : MatchIPCInfo
private int lastBeatmapId;
[BackgroundDependencyLoader]
private void load()
private void load(LadderInfo ladder)
{
StableStorage stable;
try
@ -58,10 +58,18 @@ private void load()
if (lastBeatmapId != beatmapId)
{
lastBeatmapId = beatmapId;
var existing = ladder.CurrentMatch.Value?.Grouping.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId && b.BeatmapInfo != null);
if (existing != null)
Beatmap.Value = existing.BeatmapInfo;
else
{
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = beatmapId });
req.Success += b => Beatmap.Value = b.ToBeatmap(Rulesets);
API.Queue(req);
}
}
Mods.Value = (LegacyMods)mods;
ChatChannel.Value = sr.ReadLine();