mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 12:02:54 +08:00
Fix intro screen hitting null reference if intro beatmap is unavailable
This commit is contained in:
parent
7dba3c3551
commit
e8dcbaf29a
@ -284,11 +284,12 @@ namespace osu.Game.Overlays
|
||||
|
||||
queuedDirection = TrackChangeDirection.Next;
|
||||
|
||||
var playable = BeatmapSets.SkipWhile(i => i.ID != current.BeatmapSetInfo.ID).ElementAtOrDefault(1) ?? BeatmapSets.FirstOrDefault();
|
||||
var playableSet = BeatmapSets.SkipWhile(i => i.ID != current.BeatmapSetInfo.ID).ElementAtOrDefault(1) ?? BeatmapSets.FirstOrDefault();
|
||||
var playableBeatmap = playableSet?.Beatmaps?.FirstOrDefault();
|
||||
|
||||
if (playable != null)
|
||||
if (playableBeatmap != null)
|
||||
{
|
||||
changeBeatmap(beatmaps.GetWorkingBeatmap(playable.Beatmaps.First()));
|
||||
changeBeatmap(beatmaps.GetWorkingBeatmap(playableBeatmap));
|
||||
restartTrack();
|
||||
return true;
|
||||
}
|
||||
|
@ -141,24 +141,13 @@ namespace osu.Game.Screens.Menu
|
||||
if (s.Beatmaps.Count == 0)
|
||||
return;
|
||||
|
||||
initialBeatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps[0].ToLive(realmContextFactory));
|
||||
initialBeatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps.First());
|
||||
});
|
||||
|
||||
return UsingThemedIntro = initialBeatmap != null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// TODO: This is temporary to get the setInfo on the update thread, to make things work "better" without using ILive everywhere.
|
||||
var setInfo = beatmaps.QueryBeatmapSets(b => b.Hash == BeatmapHash).FirstOrDefault();
|
||||
|
||||
if (setInfo?.Value.Beatmaps.Count > 0)
|
||||
initialBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Value.Beatmaps.First());
|
||||
}
|
||||
|
||||
public override void OnResuming(IScreen last)
|
||||
{
|
||||
this.FadeIn(300);
|
||||
@ -222,7 +211,10 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
if (!resuming)
|
||||
{
|
||||
beatmap.Value = initialBeatmap;
|
||||
// generally this can never be null
|
||||
// an exception is running ruleset tests, where the osu! ruleset may not be prsent (causing importing the intro to fail).
|
||||
if (initialBeatmap != null)
|
||||
beatmap.Value = initialBeatmap;
|
||||
Track = beatmap.Value.Track;
|
||||
|
||||
// ensure the track starts at maximum volume
|
||||
|
Loading…
Reference in New Issue
Block a user