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();
/// <summary>
/// This test also covers the scenario of exiting Player after an unsuccessful beatmap load.
/// </summary>
[Test]
public void TestUnknownModDoesntEnterGameplay()
{

View File

@ -994,12 +994,14 @@ namespace osu.Game.Screens.Play
public override bool OnExiting(IScreen next)
{
if (!GameplayState.HasPassed && !GameplayState.HasFailed)
GameplayState.HasQuit = true;
screenSuspension?.RemoveAndDisposeImmediately();
failAnimationLayer?.RemoveFilters();
if (LoadedBeatmapSuccessfully)
{
if (!GameplayState.HasPassed && !GameplayState.HasFailed)
GameplayState.HasQuit = true;
// 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)
{
@ -1012,6 +1014,7 @@ namespace osu.Game.Screens.Play
// 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.
// as we are no longer the current screen, we cannot guarantee the track is still usable.

View File

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