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

Merge pull request #31723 from peppy/fix-unstable-rate-incrementatl

Fix incremental unstable rate calculation not matching expectations
This commit is contained in:
Dan Balasescu 2025-01-29 23:54:59 +09:00 committed by GitHub
commit 007bf87a6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -36,6 +36,10 @@ namespace osu.Game.Tests.NonVisual.Ranking
.Select(t => new HitEvent(t - 5, 1.0, HitResult.Great, new HitObject(), null, null))
.ToList();
// Add some red herrings
events.Insert(4, new HitEvent(200, 1.0, HitResult.Meh, new HitObject { HitWindows = HitWindows.Empty }, null, null));
events.Insert(8, new HitEvent(-100, 1.0, HitResult.Miss, new HitObject(), null, null));
HitEventExtensions.UnstableRateCalculationResult result = null;
for (int i = 0; i < events.Count; i++)
@ -57,6 +61,10 @@ namespace osu.Game.Tests.NonVisual.Ranking
.Select(t => new HitEvent(t - 5, 1.0, HitResult.Great, new HitObject(), null, null))
.ToList();
// Add some red herrings
events.Insert(4, new HitEvent(200, 1.0, HitResult.Meh, new HitObject { HitWindows = HitWindows.Empty }, null, null));
events.Insert(8, new HitEvent(-100, 1.0, HitResult.Miss, new HitObject(), null, null));
HitEventExtensions.UnstableRateCalculationResult result = null;
for (int i = 0; i < events.Count; i++)

View File

@ -28,11 +28,12 @@ namespace osu.Game.Rulesets.Scoring
result ??= new UnstableRateCalculationResult();
// Handle rewinding in the simplest way possible.
if (hitEvents.Count < result.EventCount + 1)
if (hitEvents.Count < result.LastProcessedIndex + 1)
result = new UnstableRateCalculationResult();
for (int i = result.EventCount; i < hitEvents.Count; i++)
for (int i = result.LastProcessedIndex + 1; i < hitEvents.Count; i++)
{
result.LastProcessedIndex = i;
HitEvent e = hitEvents[i];
if (!AffectsUnstableRate(e))
@ -84,6 +85,11 @@ namespace osu.Game.Rulesets.Scoring
/// </remarks>
public class UnstableRateCalculationResult
{
/// <summary>
/// The last result index processed. For internal incremental calculation use.
/// </summary>
public int LastProcessedIndex = -1;
/// <summary>
/// Total events processed. For internal incremental calculation use.
/// </summary>