Fix crash on gameplay startup if beatmap has no background

This commit is contained in:
Dean Herbert 2021-11-04 17:24:40 +09:00
parent c820d445ad
commit b80c02b757
1 changed files with 6 additions and 2 deletions

View File

@ -77,10 +77,14 @@ public bool ReplacesBackground
{
get
{
string backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile.ToLowerInvariant();
string backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile;
if (string.IsNullOrEmpty(backgroundPath))
return false;
// Importantly, do this after the NullOrEmpty because EF may have stored the non-nullable value as null to the database, bypassing compile-time constraints.
backgroundPath = backgroundPath.ToLowerInvariant();
return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);
}
}
@ -93,7 +97,7 @@ public Drawable CreateSpriteFromResourcePath(string path, TextureStore textureSt
Drawable drawable = null;
string storyboardPath = BeatmapInfo.BeatmapSet?.Files.Find(f => f.Filename.Equals(path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
if (storyboardPath != null)
if (!string.IsNullOrEmpty(storyboardPath))
drawable = new Sprite { Texture = textureStore.Get(storyboardPath) };
// if the texture isn't available locally in the beatmap, some storyboards choose to source from the underlying skin lookup hierarchy.
else if (UseSkinSprites)