1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-17 08:02:38 +08:00
Files
osu-lazer/osu.Game/Replays/Legacy/LegacyReplayFrame.cs
T
Bartłomiej Dach 12cc8e38da Fix replays being misrecorded if an action is pressed and released in one update frame
Closes https://github.com/ppy/osu/issues/33465 probably.

This reverts the replay frame de-duplication logic to what it was before
https://github.com/ppy/osu/pull/33148#discussion_r2091549388.

I don't have good reproduction steps. I tried to write a test case for
this that isn't just "press and release a key in the same frame",
thinking that maybe there was some loophole in the osu! touch input
mapper that may produce this situation artificially, but I could not in
many configurations. So I have to assume that this just *can happen*
organically.
2025-06-06 09:10:51 +02:00

76 lines
2.2 KiB
C#

// 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.
using MessagePack;
using Newtonsoft.Json;
using osu.Game.Rulesets.Replays;
using osuTK;
namespace osu.Game.Replays.Legacy
{
[MessagePackObject]
public class LegacyReplayFrame : ReplayFrame
{
[JsonIgnore]
[IgnoreMember]
public Vector2 Position => new Vector2(MouseX ?? 0, MouseY ?? 0);
[Key(1)]
public float? MouseX;
[Key(2)]
public float? MouseY;
[JsonIgnore]
[IgnoreMember]
public bool MouseLeft => MouseLeft1 || MouseLeft2;
[JsonIgnore]
[IgnoreMember]
public bool MouseRight => MouseRight1 || MouseRight2;
[JsonIgnore]
[IgnoreMember]
public bool MouseLeft1 => ButtonState.HasFlag(ReplayButtonState.Left1);
[JsonIgnore]
[IgnoreMember]
public bool MouseRight1 => ButtonState.HasFlag(ReplayButtonState.Right1);
[JsonIgnore]
[IgnoreMember]
public bool MouseLeft2 => ButtonState.HasFlag(ReplayButtonState.Left2);
[JsonIgnore]
[IgnoreMember]
public bool MouseRight2 => ButtonState.HasFlag(ReplayButtonState.Right2);
[JsonIgnore]
[IgnoreMember]
public bool Smoke => ButtonState.HasFlag(ReplayButtonState.Smoke);
[Key(3)]
public ReplayButtonState ButtonState;
public LegacyReplayFrame(double time, float? mouseX, float? mouseY, ReplayButtonState buttonState)
: base(time)
{
MouseX = mouseX;
MouseY = mouseY;
ButtonState = buttonState;
}
public override string ToString()
{
return $"{Time}\t({MouseX},{MouseY})\t{MouseLeft}\t{MouseRight}\t{MouseLeft1}\t{MouseRight1}\t{MouseLeft2}\t{MouseRight2}\t{ButtonState}";
}
public override bool IsEquivalentTo(ReplayFrame other)
=> other is LegacyReplayFrame legacyFrame
&& Time == legacyFrame.Time
&& MouseX == legacyFrame.MouseX
&& MouseY == legacyFrame.MouseY
&& ButtonState == legacyFrame.ButtonState;
}
}