1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 10:52:55 +08:00

Change check order around to ensure re-fetches which return no results don't nullref

This commit is contained in:
Dean Herbert 2021-05-31 18:24:42 +09:00
parent d4cb70735d
commit 675fe37446

View File

@ -283,16 +283,16 @@ namespace osu.Game.Beatmaps
/// <returns>A <see cref="WorkingBeatmap"/> instance correlating to the provided <see cref="BeatmapInfo"/>.</returns>
public virtual WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo)
{
if (beatmapInfo?.BeatmapSet == null)
return DefaultBeatmap;
// if there are no files, presume the full beatmap info has not yet been fetched from the database.
if (beatmapInfo.BeatmapSet.Files.Count == 0)
if (beatmapInfo?.BeatmapSet?.Files.Count == 0)
{
int lookupId = beatmapInfo.ID;
beatmapInfo = QueryBeatmap(b => b.ID == lookupId);
}
if (beatmapInfo?.BeatmapSet == null)
return DefaultBeatmap;
lock (workingCache)
{
var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == beatmapInfo.ID);