mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 20:13:20 +08:00
Merge pull request #23930 from bdach/fix-old-lazer-score-reimport
Fix reimporting old lazer scores undoing standardised score recalculation
This commit is contained in:
commit
f5eb629709
@ -945,22 +945,21 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
foreach (var score in scores)
|
foreach (var score in scores)
|
||||||
{
|
{
|
||||||
// Recalculate the old-style standardised score to see if this was an old lazer score.
|
try
|
||||||
bool oldScoreMatchesExpectations = StandardisedScoreMigrationTools.GetOldStandardised(score) == score.TotalScore;
|
|
||||||
// Some older scores don't have correct statistics populated, so let's give them benefit of doubt.
|
|
||||||
bool scoreIsVeryOld = score.Date < new DateTime(2023, 1, 1, 0, 0, 0);
|
|
||||||
|
|
||||||
if (oldScoreMatchesExpectations || scoreIsVeryOld)
|
|
||||||
{
|
{
|
||||||
try
|
if (StandardisedScoreMigrationTools.ShouldMigrateToNewStandardised(score))
|
||||||
{
|
|
||||||
long calculatedNew = StandardisedScoreMigrationTools.GetNewStandardised(score);
|
|
||||||
score.TotalScore = calculatedNew;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
long calculatedNew = StandardisedScoreMigrationTools.GetNewStandardised(score);
|
||||||
|
score.TotalScore = calculatedNew;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -13,6 +14,19 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
public static class StandardisedScoreMigrationTools
|
public static class StandardisedScoreMigrationTools
|
||||||
{
|
{
|
||||||
|
public static bool ShouldMigrateToNewStandardised(ScoreInfo score)
|
||||||
|
{
|
||||||
|
if (score.IsLegacyScore)
|
||||||
|
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.
|
||||||
|
bool scoreIsVeryOld = score.Date < new DateTime(2023, 1, 1, 0, 0, 0);
|
||||||
|
|
||||||
|
return oldScoreMatchesExpectations || scoreIsVeryOld;
|
||||||
|
}
|
||||||
|
|
||||||
public static long GetNewStandardised(ScoreInfo score)
|
public static long GetNewStandardised(ScoreInfo score)
|
||||||
{
|
{
|
||||||
int maxJudgementIndex = 0;
|
int maxJudgementIndex = 0;
|
||||||
|
@ -83,6 +83,11 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(model.MaximumStatisticsJson))
|
if (string.IsNullOrEmpty(model.MaximumStatisticsJson))
|
||||||
model.MaximumStatisticsJson = JsonConvert.SerializeObject(model.MaximumStatistics);
|
model.MaximumStatisticsJson = JsonConvert.SerializeObject(model.MaximumStatistics);
|
||||||
|
|
||||||
|
// for pre-ScoreV2 lazer scores, apply a best-effort conversion of total score to ScoreV2.
|
||||||
|
// this requires: max combo, statistics, max statistics (where available), and mods to already be populated on the score.
|
||||||
|
if (StandardisedScoreMigrationTools.ShouldMigrateToNewStandardised(model))
|
||||||
|
model.TotalScore = StandardisedScoreMigrationTools.GetNewStandardised(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user