Skip to content

Commit

Permalink
Merge pull request #24219 from peppy/fix-mania-everything
Browse files Browse the repository at this point in the history
Fix osu!mania scores failing to convert to new standardised score due to cast failure
  • Loading branch information
peppy authored Jul 16, 2023
2 parents 1868826 + eb81eac commit cf70f5e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 6 additions & 4 deletions osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ManiaScoreProcessor()
}

protected override IEnumerable<HitObject> EnumerateHitObjects(IBeatmap beatmap)
=> base.EnumerateHitObjects(beatmap).OrderBy(ho => (ManiaHitObject)ho, JudgementOrderComparer.DEFAULT);
=> base.EnumerateHitObjects(beatmap).OrderBy(ho => ho, JudgementOrderComparer.DEFAULT);

protected override double ComputeTotalScore(double comboProgress, double accuracyProgress, double bonusPortion)
{
Expand All @@ -34,11 +34,11 @@ protected override double ComputeTotalScore(double comboProgress, double accurac
protected override double GetComboScoreChange(JudgementResult result)
=> Judgement.ToNumericResult(result.Type) * Math.Min(Math.Max(0.5, Math.Log(result.ComboAfterJudgement, combo_base)), Math.Log(400, combo_base));

private class JudgementOrderComparer : IComparer<ManiaHitObject>
private class JudgementOrderComparer : IComparer<HitObject>
{
public static readonly JudgementOrderComparer DEFAULT = new JudgementOrderComparer();

public int Compare(ManiaHitObject? x, ManiaHitObject? y)
public int Compare(HitObject? x, HitObject? y)
{
if (ReferenceEquals(x, y)) return 0;
if (ReferenceEquals(x, null)) return -1;
Expand All @@ -52,7 +52,9 @@ public int Compare(ManiaHitObject? x, ManiaHitObject? y)
if (x is Note && y is not Note) return -1;
if (x is not Note && y is Note) return 1;

return x.Column.CompareTo(y.Column);
return x is ManiaHitObject maniaX && y is ManiaHitObject maniaY
? maniaX.Column.CompareTo(maniaY.Column)
: 0;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions osu.Game/Database/StandardisedScoreMigrationTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public static bool ShouldMigrateToNewStandardised(ScoreInfo score)
if (score.IsLegacyScore)
return false;

if (score.TotalScoreVersion > 30000002)
return false;

// Recalculate the old-style standardised score to see if this was an old lazer score.
bool oldScoreMatchesExpectations = GetOldStandardised(score) == score.TotalScore;
// Some older scores don't have correct statistics populated, so let's give them benefit of doubt.
Expand Down
7 changes: 7 additions & 0 deletions osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public Score Parse(Stream stream)

scoreInfo.IsLegacyScore = version < LegacyScoreEncoder.FIRST_LAZER_VERSION;

// TotalScoreVersion gets initialised to LATEST_VERSION.
// In the case where the incoming score has either an osu!stable or old lazer version, we need
// to mark it with the correct version increment to trigger reprocessing to new standardised scoring.
//
// See StandardisedScoreMigrationTools.ShouldMigrateToNewStandardised().
scoreInfo.TotalScoreVersion = version < 30000002 ? 30000001 : LegacyScoreEncoder.LATEST_VERSION;

string beatmapHash = sr.ReadString();

workingBeatmap = GetBeatmap(beatmapHash);
Expand Down

0 comments on commit cf70f5e

Please sign in to comment.