mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Merge pull request #9281 from peppy/fix-gameplay-elapsed-time
Fix gameplay clock not correctly reporting elapsed time
This commit is contained in:
commit
ac414a5db8
25
osu.Game.Tests/Gameplay/TestSceneGameplayClockContainer.cs
Normal file
25
osu.Game.Tests/Gameplay/TestSceneGameplayClockContainer.cs
Normal file
@ -0,0 +1,25 @@
|
||||
// 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 System;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
public class TestSceneGameplayClockContainer : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestStartThenElapsedTime()
|
||||
{
|
||||
GameplayClockContainer gcc = null;
|
||||
|
||||
AddStep("create container", () => Add(gcc = new GameplayClockContainer(CreateWorkingBeatmap(new OsuRuleset().RulesetInfo), Array.Empty<Mod>(), 0)));
|
||||
AddStep("start track", () => gcc.Start());
|
||||
AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -251,8 +251,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private class HardwareCorrectionOffsetClock : FramedOffsetClock
|
||||
{
|
||||
// we always want to apply the same real-time offset, so it should be adjusted by the playback rate to achieve this.
|
||||
public override double CurrentTime => SourceTime + Offset * Rate;
|
||||
// we always want to apply the same real-time offset, so it should be adjusted by the difference in playback rate (from realtime) to achieve this.
|
||||
// base implementation already adds offset at 1.0 rate, so we only add the difference from that here.
|
||||
public override double CurrentTime => base.CurrentTime + Offset * (Rate - 1);
|
||||
|
||||
public HardwareCorrectionOffsetClock(IClock source, bool processSource = true)
|
||||
: base(source, processSource)
|
||||
|
Loading…
Reference in New Issue
Block a user