From b3d793a505d919902710673de4e1947e228e43f8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Oct 2020 18:28:49 +0900 Subject: [PATCH] Fix gameplay proceeding when no frames have been received yet --- .../Visual/Gameplay/TestSceneSpectator.cs | 15 +++++++++++++++ .../Rulesets/Replays/FramedReplayInputHandler.cs | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs index 98bd90b3b5..14b0ca4d33 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs @@ -56,6 +56,9 @@ namespace osu.Game.Tests.Visual.Gameplay public void TestBasicSpectatingFlow() { loadSpectatingScreen(); + + AddAssert("screen hasn't changed", () => Stack.CurrentScreen is Spectator); + AddStep("start play", () => testSpectatorStreamingClient.StartPlay()); sendFrames(); @@ -73,6 +76,18 @@ namespace osu.Game.Tests.Visual.Gameplay AddAssert("game is paused", () => player.ChildrenOfType().First().IsPaused.Value); } + [Test] + public void TestPlayStartsWithNoFrames() + { + loadSpectatingScreen(); + + AddStep("start play", () => testSpectatorStreamingClient.StartPlay()); + + AddUntilStep("wait for player", () => Stack.CurrentScreen is Player); + + AddUntilStep("game is paused", () => player.ChildrenOfType().First().IsPaused.Value); + } + [Test] public void TestSpectatingDuringGameplay() { diff --git a/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs b/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs index ddf85b7300..d7be809d34 100644 --- a/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs +++ b/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs @@ -162,6 +162,12 @@ namespace osu.Game.Rulesets.Replays // if we didn't change frames, we need to ensure we are allowed to run frames in between, else return null. } } + else + { + // if we never received frames and are expecting to, block. + if (!replay.HasReceivedAllFrames) + return null; + } return CurrentTime = time; }