From 57cd50c45ee2d45f2ba9fb6804cce7acdc219066 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 25 Jan 2018 17:39:10 +0900 Subject: [PATCH] Reorder the way input is handled for replays Fixes https://github.com/ppy/osu/issues/1625 . --- .../Objects/Drawables/DrawableHitObject.cs | 2 ++ osu.Game/Rulesets/UI/RulesetInputManager.cs | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 2db02724ed..e4f8124bce 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -71,6 +71,8 @@ namespace osu.Game.Rulesets.Objects.Drawables public override bool HandleKeyboardInput => Interactive; public override bool HandleMouseInput => Interactive; + public override bool MaskingAffectsInput => false; + public override bool RemoveWhenNotAlive => false; public override bool RemoveCompletedTransforms => false; protected override bool RequiresChildrenUpdate => true; diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index 223586a959..e32b38a013 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -136,9 +136,20 @@ namespace osu.Game.Rulesets.UI int loops = 0; while (validState && requireMoreUpdateLoops && loops++ < max_catch_up_updates_per_frame) + { if (!base.UpdateSubTree()) return false; + if (isAttached) + { + // When handling replay input, we need to consider the possibility of fast-forwarding, which may cause the clock to be updated + // to a point very far into the future, then playing a frame at that time. In such a case, lifetime MUST be updated before + // input is handled. This is why base.Update is not called from the derived Update when handling replay input, and is instead + // called manually at the correct time here. + base.Update(); + } + } + return true; } @@ -173,8 +184,11 @@ namespace osu.Game.Rulesets.UI // to ensure that the its time is valid for our children before input is processed Clock.ProcessFrame(); - // Process input - base.Update(); + if (!isAttached) + { + // For non-replay input handling, this provides equivalent input ordering as if Update was not overridden + base.Update(); + } } #endregion