Fix regressing issues when attempting to exit Player after an unsuccessful beatmap load

This commit is contained in:
Dean Herbert 2022-03-09 17:50:05 +09:00
parent 1ee0be5e39
commit 2eb3365f46
3 changed files with 21 additions and 14 deletions

View File

@ -12,6 +12,9 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset(); protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
/// <summary>
/// This test also covers the scenario of exiting Player after an unsuccessful beatmap load.
/// </summary>
[Test] [Test]
public void TestUnknownModDoesntEnterGameplay() public void TestUnknownModDoesntEnterGameplay()
{ {

View File

@ -994,24 +994,27 @@ namespace osu.Game.Screens.Play
public override bool OnExiting(IScreen next) public override bool OnExiting(IScreen next)
{ {
if (!GameplayState.HasPassed && !GameplayState.HasFailed)
GameplayState.HasQuit = true;
screenSuspension?.RemoveAndDisposeImmediately(); screenSuspension?.RemoveAndDisposeImmediately();
failAnimationLayer?.RemoveFilters(); failAnimationLayer?.RemoveFilters();
// 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 (LoadedBeatmapSuccessfully)
if (prepareScoreForDisplayTask == null)
{ {
Score.ScoreInfo.Passed = false; if (!GameplayState.HasPassed && !GameplayState.HasFailed)
// potentially should be ScoreRank.F instead? this is the best alternative for now. GameplayState.HasQuit = true;
Score.ScoreInfo.Rank = ScoreRank.D;
}
// EndPlaying() is typically called from ReplayRecorder.Dispose(). Disposal is currently asynchronous. // if arriving here and the results screen preparation task hasn't run, it's safe to say the user has not completed the beatmap.
// To resolve test failures, forcefully end playing synchronously when this screen exits. if (prepareScoreForDisplayTask == null)
// Todo: Replace this with a more permanent solution once osu-framework has a synchronous cleanup method. {
spectatorClient.EndPlaying(GameplayState); Score.ScoreInfo.Passed = false;
// potentially should be ScoreRank.F instead? this is the best alternative for now.
Score.ScoreInfo.Rank = ScoreRank.D;
}
// EndPlaying() is typically called from ReplayRecorder.Dispose(). Disposal is currently asynchronous.
// To resolve test failures, forcefully end playing synchronously when this screen exits.
// Todo: Replace this with a more permanent solution once osu-framework has a synchronous cleanup method.
spectatorClient.EndPlaying(GameplayState);
}
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track. // GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
// as we are no longer the current screen, we cannot guarantee the track is still usable. // as we are no longer the current screen, we cannot guarantee the track is still usable.

View File

@ -119,7 +119,8 @@ namespace osu.Game.Screens.Play
{ {
bool exiting = base.OnExiting(next); bool exiting = base.OnExiting(next);
submitScore(Score.DeepClone()); if (LoadedBeatmapSuccessfully)
submitScore(Score.DeepClone());
return exiting; return exiting;
} }