1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

Stop replay playback when frames are starved

This commit is contained in:
Dean Herbert 2020-10-27 14:57:23 +09:00
parent 9bac8f3792
commit c1e7cd6e47
2 changed files with 24 additions and 9 deletions

View File

@ -43,6 +43,8 @@ namespace osu.Game.Tests.Visual.Gameplay
private OsuFramedReplayInputHandler replayHandler =>
(OsuFramedReplayInputHandler)Stack.ChildrenOfType<OsuInputManager>().First().ReplayInputHandler;
private Player player => Stack.CurrentScreen as Player;
[Test]
public void TestBasicSpectatingFlow()
{
@ -53,6 +55,9 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("wait for player", () => Stack.CurrentScreen is Player);
AddAssert("ensure frames arrived", () => replayHandler.HasFrames);
AddUntilStep("wait for frame starvation", () => replayHandler.NextFrame == null);
AddAssert("game is paused", () => !player.ChildrenOfType<GameplayClockContainer>().First().GameplayClock.IsRunning);
}
[Test]
@ -127,14 +132,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public readonly User StreamingUser = new User { Id = 1234, Username = "Test user" };
public void StartPlay()
{
((ISpectatorClient)this).UserBeganPlaying((int)StreamingUser.Id, new SpectatorState
{
BeatmapID = beatmaps.GetAllUsableBeatmapSets().First().Beatmaps.First(b => b.RulesetID == 0).OnlineBeatmapID,
RulesetID = 0,
});
}
public void StartPlay() => sendState();
public void EndPlay()
{
@ -153,6 +151,23 @@ namespace osu.Game.Tests.Visual.Gameplay
new LegacyReplayFrame(0, 0, 0, ReplayButtonState.Left1)
}));
}
public override void WatchUser(int userId)
{
// usually the server would do this.
sendState();
base.WatchUser(userId);
}
private void sendState()
{
((ISpectatorClient)this).UserBeganPlaying((int)StreamingUser.Id, new SpectatorState
{
BeatmapID = beatmaps.GetAllUsableBeatmapSets().First().Beatmaps.First(b => b.RulesetID == 0).OnlineBeatmapID,
RulesetID = 0,
});
}
}
}
}

View File

@ -227,7 +227,7 @@ namespace osu.Game.Online.Spectator
connection.SendAsync(nameof(ISpectatorServer.EndPlaySession), currentState);
}
public void WatchUser(int userId)
public virtual void WatchUser(int userId)
{
if (watchingUsers.Contains(userId))
return;