mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Revert "Ensure invariant of monotone time"
This reverts commit 5d1ccc2601
.
This commit is contained in:
parent
c7b1c75379
commit
5bc11ed358
@ -51,11 +51,6 @@ namespace osu.Game.Rulesets.UI
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IPooledHitObjectProvider pooledObjectProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="HitObject"/> is updated.
|
||||
/// </summary>
|
||||
public event Action<HitObject> HitObjectUpdated;
|
||||
|
||||
public HitObjectContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
@ -113,7 +108,6 @@ namespace osu.Game.Rulesets.UI
|
||||
drawable.OnNewResult += onNewResult;
|
||||
|
||||
bindStartTime(drawable);
|
||||
bindUpdated(drawable);
|
||||
AddInternal(drawable);
|
||||
}
|
||||
|
||||
@ -122,7 +116,7 @@ namespace osu.Game.Rulesets.UI
|
||||
drawable.OnNewResult -= onNewResult;
|
||||
|
||||
unbindStartTime(drawable);
|
||||
unbindUpdated(drawable);
|
||||
|
||||
RemoveInternal(drawable, false);
|
||||
}
|
||||
|
||||
@ -182,27 +176,6 @@ namespace osu.Game.Rulesets.UI
|
||||
startTimeMap.Clear();
|
||||
}
|
||||
|
||||
private void bindUpdated(DrawableHitObject hitObject)
|
||||
{
|
||||
hitObject.DefaultsApplied += onDefaultsApplied;
|
||||
}
|
||||
|
||||
private void unbindUpdated(DrawableHitObject hitObject)
|
||||
{
|
||||
hitObject.DefaultsApplied += onDefaultsApplied;
|
||||
}
|
||||
|
||||
private void unbindAllUpdated()
|
||||
{
|
||||
foreach (var h in AliveObjects)
|
||||
unbindUpdated(h);
|
||||
}
|
||||
|
||||
private void onDefaultsApplied(DrawableHitObject obj)
|
||||
{
|
||||
HitObjectUpdated?.Invoke(obj.HitObject);
|
||||
}
|
||||
|
||||
protected override int Compare(Drawable x, Drawable y)
|
||||
{
|
||||
if (!(x is DrawableHitObject xObj) || !(y is DrawableHitObject yObj))
|
||||
@ -219,7 +192,6 @@ namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
unbindAllStartTimes();
|
||||
unbindAllUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
private readonly HitObjectEntryManager entryManager = new HitObjectEntryManager();
|
||||
|
||||
private readonly LinkedList<HitObjectLifetimeEntry> judgedEntries;
|
||||
private readonly Stack<HitObjectLifetimeEntry> judgedEntries;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Playfield"/>.
|
||||
@ -125,13 +125,12 @@ namespace osu.Game.Rulesets.UI
|
||||
h.NewResult += onNewResult;
|
||||
h.HitObjectUsageBegan += o => HitObjectUsageBegan?.Invoke(o);
|
||||
h.HitObjectUsageFinished += o => HitObjectUsageFinished?.Invoke(o);
|
||||
h.HitObjectUpdated += onHitObjectUpdated;
|
||||
}));
|
||||
|
||||
entryManager.OnEntryAdded += onEntryAdded;
|
||||
entryManager.OnEntryRemoved += onEntryRemoved;
|
||||
|
||||
judgedEntries = new LinkedList<HitObjectLifetimeEntry>();
|
||||
judgedEntries = new Stack<HitObjectLifetimeEntry>();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -271,16 +270,15 @@ namespace osu.Game.Rulesets.UI
|
||||
}
|
||||
|
||||
// When rewinding, revert future judgements in the reverse order.
|
||||
while (judgedEntries.Last is not null)
|
||||
while (judgedEntries.Count > 0)
|
||||
{
|
||||
var result = judgedEntries.Last.Value.Result;
|
||||
var result = judgedEntries.Peek().Result;
|
||||
Debug.Assert(result?.RawTime != null);
|
||||
|
||||
if (Time.Current >= result.RawTime.Value)
|
||||
break;
|
||||
|
||||
revertResult(judgedEntries.Last.Value);
|
||||
judgedEntries.RemoveLast();
|
||||
revertResult(judgedEntries.Pop());
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,31 +471,10 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
#endregion
|
||||
|
||||
private void onHitObjectUpdated(HitObject _)
|
||||
{
|
||||
// The time of judged entries may have changed, so we need to re-sort the list to preserve the invariant of monotone time.
|
||||
// Insertion sort on linked-list is O(n) for nearly-sorted lists, which is the case here.
|
||||
var current = judgedEntries.First;
|
||||
|
||||
while (current?.Next is not null)
|
||||
{
|
||||
var next = current.Next;
|
||||
|
||||
if (current.Value.Result?.RawTime > next.Value.Result?.RawTime)
|
||||
{
|
||||
judgedEntries.Remove(next);
|
||||
judgedEntries.AddBefore(current, next);
|
||||
current = next.Previous;
|
||||
}
|
||||
else
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
|
||||
private void onNewResult(DrawableHitObject drawable, JudgementResult result)
|
||||
{
|
||||
Debug.Assert(result != null && drawable.Entry?.Result == result && result.RawTime != null);
|
||||
judgedEntries.AddLast(drawable.Entry.AsNonNull());
|
||||
judgedEntries.Push(drawable.Entry.AsNonNull());
|
||||
|
||||
NewResult?.Invoke(drawable, result);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user