1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 15:23:14 +08:00

Fix nullref in case of successfull request but no backgrounds available

This commit is contained in:
Max Hübner 2020-10-30 17:57:29 +01:00
parent 0b46c19b23
commit 51a58269ad

View File

@ -32,7 +32,7 @@ namespace osu.Game.Graphics.Backgrounds
request.Success += response =>
{
cachedResponse.Value = response;
current = RNG.Next(0, cachedResponse.Value.Backgrounds.Count);
current = RNG.Next(0, response.Backgrounds?.Count ?? 0);
};
api.PerformAsync(request);
@ -41,7 +41,7 @@ namespace osu.Game.Graphics.Backgrounds
public SeasonalBackground LoadBackground()
{
var backgrounds = cachedResponse.Value.Backgrounds;
if (!backgrounds.Any()) return null;
if (backgrounds == null || !backgrounds.Any()) return null;
current = (current + 1) % backgrounds.Count;
string url = backgrounds[current].Url;