From ad2df8d8dfdfc775098ae07725adaa03a00f47b0 Mon Sep 17 00:00:00 2001 From: Michael Manis Date: Sun, 21 Jan 2018 20:09:44 -0500 Subject: [PATCH] Fixed tilde-key crash at end of beatmap. --- osu.Game/Screens/Play/Player.cs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 8d26d63d41..d50f463c2c 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -88,6 +88,9 @@ namespace osu.Game.Screens.Play private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true; + private bool allowRestart = true; + private bool exited = false; + [BackgroundDependencyLoader] private void load(AudioManager audio, OsuConfigManager config, APIAccess api) { @@ -208,10 +211,12 @@ namespace osu.Game.Screens.Play new HotkeyRetryOverlay { Action = () => { - //we want to hide the hitrenderer immediately (looks better). - //we may be able to remove this once the mouse cursor trail is improved. - RulesetContainer?.Hide(); - Restart(); + if (allowRestart) { + //we want to hide the hitrenderer immediately (looks better). + //we may be able to remove this once the mouse cursor trail is improved. + RulesetContainer?.Hide(); + Restart(); + } }, } }; @@ -266,6 +271,7 @@ namespace osu.Game.Screens.Play public void Restart() { + exited = true; sampleRestart?.Play(); ValidForResume = false; RestartRequested?.Invoke(); @@ -288,6 +294,11 @@ namespace osu.Game.Screens.Play { onCompletionEvent = Schedule(delegate { + // This is here to mimic OsuStable behavior. It could be placed outside the delay timer, + // which would remove the need for the check on Push() below, and would make it impossible + // to quick-restart after hitting the last note. + allowRestart = false; + var score = new Score { Beatmap = Beatmap.Value.BeatmapInfo, @@ -295,7 +306,7 @@ namespace osu.Game.Screens.Play }; scoreProcessor.PopulateScore(score); score.User = RulesetContainer.Replay?.User ?? api.LocalUser.Value; - Push(new Results(score)); + if (!exited) Push(new Results(score)); }); } }