1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 12:22:56 +08:00

Allow FrameStabilityContainer to handle waiting-for-data state better (and pause outwards)

This commit is contained in:
Dean Herbert 2020-10-27 16:28:50 +09:00
parent 3ec3321a3d
commit 9e6b0a42ec
2 changed files with 27 additions and 4 deletions

View File

@ -124,20 +124,42 @@ namespace osu.Game.Rulesets.Replays
if (HasFrames)
{
var next = NextFrame;
// check if the next frame is valid for the current playback direction.
// validity is if the next frame is equal or "earlier"
var compare = time.CompareTo(NextFrame?.Time);
var compare = time.CompareTo(next?.Time);
if (compare == 0 || compare == currentDirection)
if (next != null && (compare == 0 || compare == currentDirection))
{
if (advanceFrame())
return CurrentTime = CurrentFrame.Time;
}
else
{
// if we didn't change frames, we need to ensure we are allowed to run frames in between, else return null.
// this is the case where the frame can't be advanced (in the replay).
// even so, we may be able to move the clock forward due to being at the end of the replay or
// in a section where replay accuracy doesn't matter.
// important section is always respected to block the update loop.
if (inImportantSection)
return null;
if (next == null)
{
// in the case we have no more frames and haven't received the full replay, block.
if (!replay.HasReceivedAllFrames)
return null;
// else allow play to end.
}
else if (next.Time.CompareTo(time) != currentDirection)
{
// in the case we have more frames, block if the next frame's time is less than the current time.
return null;
}
// if we didn't change frames, we need to ensure we are allowed to run frames in between, else return null.
}
}

View File

@ -96,6 +96,7 @@ namespace osu.Game.Rulesets.UI
public override bool UpdateSubTree()
{
requireMoreUpdateLoops = true;
validState = !frameStableClock.IsPaused.Value;
int loops = 0;
@ -191,7 +192,7 @@ namespace osu.Game.Rulesets.UI
finally
{
if (newProposedTime != manualClock.CurrentTime)
direction = newProposedTime > manualClock.CurrentTime ? 1 : -1;
direction = newProposedTime >= manualClock.CurrentTime ? 1 : -1;
manualClock.CurrentTime = newProposedTime;
manualClock.Rate = Math.Abs(parentGameplayClock.Rate) * direction;