From d83bf029239bf54c4ef290b210c8d8dc232b206f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 14 Jun 2023 17:50:46 +0900 Subject: [PATCH 1/2] Fix thing --- osu.Game/Database/RealmAccess.cs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/osu.Game/Database/RealmAccess.cs b/osu.Game/Database/RealmAccess.cs index 68a4679656..b2bbbf3155 100644 --- a/osu.Game/Database/RealmAccess.cs +++ b/osu.Game/Database/RealmAccess.cs @@ -945,22 +945,26 @@ namespace osu.Game.Database foreach (var score in scores) { - // Recalculate the old-style standardised score to see if this was an old lazer score. - 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 { - try - { - long calculatedNew = StandardisedScoreMigrationTools.GetNewStandardised(score); - score.TotalScore = calculatedNew; - } - catch + // Recalculate the old-style standardised score to see if this was an old lazer score. + 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 + { + long calculatedNew = StandardisedScoreMigrationTools.GetNewStandardised(score); + score.TotalScore = calculatedNew; + } + catch + { + } } } + catch { } } break; From 51b5a0863f97b0d3e777fbcae5490e10848e0d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 15 Jun 2023 21:48:57 +0200 Subject: [PATCH 2/2] Apply migration to new standardised score on normal reimport too --- osu.Game/Database/RealmAccess.cs | 7 +------ .../Database/StandardisedScoreMigrationTools.cs | 14 ++++++++++++++ osu.Game/Scoring/ScoreImporter.cs | 5 +++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/osu.Game/Database/RealmAccess.cs b/osu.Game/Database/RealmAccess.cs index b2bbbf3155..48eb2826f5 100644 --- a/osu.Game/Database/RealmAccess.cs +++ b/osu.Game/Database/RealmAccess.cs @@ -947,12 +947,7 @@ namespace osu.Game.Database { try { - // Recalculate the old-style standardised score to see if this was an old lazer score. - 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) + if (StandardisedScoreMigrationTools.ShouldMigrateToNewStandardised(score)) { try { diff --git a/osu.Game/Database/StandardisedScoreMigrationTools.cs b/osu.Game/Database/StandardisedScoreMigrationTools.cs index af91bee9e4..66e64f3f7a 100644 --- a/osu.Game/Database/StandardisedScoreMigrationTools.cs +++ b/osu.Game/Database/StandardisedScoreMigrationTools.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps; @@ -13,6 +14,19 @@ namespace osu.Game.Database { 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) { int maxJudgementIndex = 0; diff --git a/osu.Game/Scoring/ScoreImporter.cs b/osu.Game/Scoring/ScoreImporter.cs index 1c24cfbc85..16658a598a 100644 --- a/osu.Game/Scoring/ScoreImporter.cs +++ b/osu.Game/Scoring/ScoreImporter.cs @@ -83,6 +83,11 @@ namespace osu.Game.Scoring if (string.IsNullOrEmpty(model.MaximumStatisticsJson)) 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); } ///