mirror of https://github.com/ppy/osu
Fix crash on gameplay startup if beatmap has no background
This commit is contained in:
parent
c820d445ad
commit
b80c02b757
|
@ -77,10 +77,14 @@ public bool ReplacesBackground
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
string backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile.ToLowerInvariant();
|
string backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(backgroundPath))
|
if (string.IsNullOrEmpty(backgroundPath))
|
||||||
return false;
|
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);
|
return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +97,7 @@ public Drawable CreateSpriteFromResourcePath(string path, TextureStore textureSt
|
||||||
Drawable drawable = null;
|
Drawable drawable = null;
|
||||||
string storyboardPath = BeatmapInfo.BeatmapSet?.Files.Find(f => f.Filename.Equals(path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
|
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) };
|
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.
|
// if the texture isn't available locally in the beatmap, some storyboards choose to source from the underlying skin lookup hierarchy.
|
||||||
else if (UseSkinSprites)
|
else if (UseSkinSprites)
|
||||||
|
|
Loading…
Reference in New Issue