mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 11:12:54 +08:00
Give last bundled replay frame the frame header
This commit is contained in:
parent
62603e78fd
commit
4727aeda01
@ -218,6 +218,22 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("last received frame has time = 1000", () => spectatorClient.LastReceivedUserFrames.First().Value.Time == 1000);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFinalFrameInBundleHasHeader()
|
||||
{
|
||||
FrameDataBundle lastBundle = null;
|
||||
|
||||
AddStep("bind to client", () => spectatorClient.OnNewFrames += (_, bundle) => lastBundle = bundle);
|
||||
|
||||
start(-1234);
|
||||
sendFrames();
|
||||
finish();
|
||||
|
||||
AddUntilStep("bundle received", () => lastBundle != null);
|
||||
AddAssert("first frame does not have header", () => lastBundle.Frames[0].Header == null);
|
||||
AddAssert("last frame has header", () => lastBundle.Frames[^1].Header != null);
|
||||
}
|
||||
|
||||
private OsuFramedReplayInputHandler replayHandler =>
|
||||
(OsuFramedReplayInputHandler)Stack.ChildrenOfType<OsuInputManager>().First().ReplayInputHandler;
|
||||
|
||||
|
@ -129,6 +129,9 @@ namespace osu.Game.Online.Spectator
|
||||
|
||||
Task ISpectatorClient.UserSentFrames(int userId, FrameDataBundle data)
|
||||
{
|
||||
if (data.Frames.Count > 0)
|
||||
data.Frames[^1].Header = data.Header;
|
||||
|
||||
Schedule(() => OnNewFrames?.Invoke(userId, data));
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
@ -1,16 +1,29 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using MessagePack;
|
||||
using osu.Game.Online.Spectator;
|
||||
|
||||
namespace osu.Game.Rulesets.Replays
|
||||
{
|
||||
[MessagePackObject]
|
||||
public class ReplayFrame
|
||||
{
|
||||
/// <summary>
|
||||
/// The time at which this <see cref="ReplayFrame"/> takes place.
|
||||
/// </summary>
|
||||
[Key(0)]
|
||||
public double Time;
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="FrameHeader"/> containing the state of a play after this <see cref="ReplayFrame"/> takes place.
|
||||
/// May be omitted where exact per-frame accuracy is not required.
|
||||
/// </summary>
|
||||
[IgnoreMember]
|
||||
public FrameHeader? Header;
|
||||
|
||||
public ReplayFrame()
|
||||
{
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
var convertedFrame = (ReplayFrame)convertibleFrame;
|
||||
convertedFrame.Time = frame.Time;
|
||||
convertedFrame.Header = frame.Header;
|
||||
|
||||
score.Replay.Frames.Add(convertedFrame);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user