mirror of https://github.com/ppy/osu
Add safeties to avoid `MultiplayerPlayer` crashing when beatmap can't be loaded
This commit is contained in:
parent
aa4c6b9341
commit
fcec714b4f
|
@ -57,6 +57,9 @@ public MultiplayerPlayer(PlaylistItem playlistItem, int[] userIds)
|
|||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
if (!LoadedBeatmapSuccessfully)
|
||||
return;
|
||||
|
||||
// todo: this should be implemented via a custom HUD implementation, and correctly masked to the main content area.
|
||||
LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(ScoreProcessor, userIds), HUDOverlay.Add);
|
||||
|
||||
|
@ -67,6 +70,9 @@ protected override void LoadAsyncComplete()
|
|||
{
|
||||
base.LoadAsyncComplete();
|
||||
|
||||
if (!LoadedBeatmapSuccessfully)
|
||||
return;
|
||||
|
||||
if (!ValidForResume)
|
||||
return; // token retrieval may have failed.
|
||||
|
||||
|
@ -96,6 +102,9 @@ protected override void LoadComplete()
|
|||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (!LoadedBeatmapSuccessfully)
|
||||
return;
|
||||
|
||||
((IBindable<bool>)leaderboard.Expanded).BindTo(HUDOverlay.ShowHud);
|
||||
}
|
||||
|
||||
|
@ -118,6 +127,10 @@ private void failAndBail(string message = null)
|
|||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (!LoadedBeatmapSuccessfully)
|
||||
return;
|
||||
|
||||
adjustLeaderboardPosition();
|
||||
}
|
||||
|
||||
|
|
|
@ -962,7 +962,7 @@ public override bool OnExiting(IScreen next)
|
|||
screenSuspension?.Expire();
|
||||
|
||||
// if arriving here and the results screen preparation task hasn't run, it's safe to say the user has not completed the beatmap.
|
||||
if (prepareScoreForDisplayTask == null)
|
||||
if (Score != null && prepareScoreForDisplayTask == null)
|
||||
{
|
||||
Score.ScoreInfo.Passed = false;
|
||||
// potentially should be ScoreRank.F instead? this is the best alternative for now.
|
||||
|
|
Loading…
Reference in New Issue