1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Merge pull request #10275 from peppy/frame-stability-attach-without-enabling

Allow attaching a replay to a FrameStabilityContainer when FrameStablePlayback is off
This commit is contained in:
Dan Balasescu 2020-09-28 16:33:55 +09:00 committed by GitHub
commit ef195015c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,39 +123,63 @@ namespace osu.Game.Rulesets.UI
try try
{ {
if (!FrameStablePlayback) if (FrameStablePlayback)
return;
if (firstConsumption)
{ {
// On the first update, frame-stability seeking would result in unexpected/unwanted behaviour. if (firstConsumption)
// Instead we perform an initial seek to the proposed time. {
// On the first update, frame-stability seeking would result in unexpected/unwanted behaviour.
// Instead we perform an initial seek to the proposed time.
// process frame (in addition to finally clause) to clear out ElapsedTime // process frame (in addition to finally clause) to clear out ElapsedTime
manualClock.CurrentTime = newProposedTime; manualClock.CurrentTime = newProposedTime;
framedClock.ProcessFrame(); framedClock.ProcessFrame();
firstConsumption = false; firstConsumption = false;
} }
else if (manualClock.CurrentTime < gameplayStartTime) else if (manualClock.CurrentTime < gameplayStartTime)
manualClock.CurrentTime = newProposedTime = Math.Min(gameplayStartTime, newProposedTime); manualClock.CurrentTime = newProposedTime = Math.Min(gameplayStartTime, newProposedTime);
else if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f) else if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f)
{ {
newProposedTime = newProposedTime > manualClock.CurrentTime newProposedTime = newProposedTime > manualClock.CurrentTime
? Math.Min(newProposedTime, manualClock.CurrentTime + sixty_frame_time) ? Math.Min(newProposedTime, manualClock.CurrentTime + sixty_frame_time)
: Math.Max(newProposedTime, manualClock.CurrentTime - sixty_frame_time); : Math.Max(newProposedTime, manualClock.CurrentTime - sixty_frame_time);
}
} }
if (isAttached) if (isAttached)
{ {
double? newTime = ReplayInputHandler.SetFrameFromTime(newProposedTime); double? newTime;
if (newTime == null) if (FrameStablePlayback)
{ {
// we shouldn't execute for this time value. probably waiting on more replay data. // when stability is turned on, we shouldn't execute for time values the replay is unable to satisfy.
validState = false; if ((newTime = ReplayInputHandler.SetFrameFromTime(newProposedTime)) == null)
requireMoreUpdateLoops = true; {
return; // setting invalid state here ensures that gameplay will not continue (ie. our child
// hierarchy won't be updated).
validState = false;
// potentially loop to catch-up playback.
requireMoreUpdateLoops = true;
return;
}
}
else
{
// when stability is disabled, we don't really care about accuracy.
// looping over the replay will allow it to catch up and feed out the required values
// for the current time.
while ((newTime = ReplayInputHandler.SetFrameFromTime(newProposedTime)) != newProposedTime)
{
if (newTime == null)
{
// special case for when the replay actually can't arrive at the required time.
// protects from potential endless loop.
validState = false;
return;
}
}
} }
newProposedTime = newTime.Value; newProposedTime = newTime.Value;