Skip to content

Commit 9b3ab2f

Browse files
bdachpeppy
authored andcommitted
Apply migration to new standardised score on normal reimport too
1 parent 5a45476 commit 9b3ab2f

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

osu.Game/Database/RealmAccess.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -949,12 +949,7 @@ void convertOnlineIDs<T>() where T : RealmObject
949949
{
950950
try
951951
{
952-
// Recalculate the old-style standardised score to see if this was an old lazer score.
953-
bool oldScoreMatchesExpectations = StandardisedScoreMigrationTools.GetOldStandardised(score) == score.TotalScore;
954-
// Some older scores don't have correct statistics populated, so let's give them benefit of doubt.
955-
bool scoreIsVeryOld = score.Date < new DateTime(2023, 1, 1, 0, 0, 0);
956-
957-
if (oldScoreMatchesExpectations || scoreIsVeryOld)
952+
if (StandardisedScoreMigrationTools.ShouldMigrateToNewStandardised(score))
958953
{
959954
try
960955
{

osu.Game/Database/StandardisedScoreMigrationTools.cs

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
22
// See the LICENCE file in the repository root for full licence text.
33

4+
using System;
45
using System.Collections.Generic;
56
using System.Linq;
67
using osu.Game.Beatmaps;
@@ -13,6 +14,19 @@ namespace osu.Game.Database
1314
{
1415
public static class StandardisedScoreMigrationTools
1516
{
17+
public static bool ShouldMigrateToNewStandardised(ScoreInfo score)
18+
{
19+
if (score.IsLegacyScore)
20+
return false;
21+
22+
// Recalculate the old-style standardised score to see if this was an old lazer score.
23+
bool oldScoreMatchesExpectations = GetOldStandardised(score) == score.TotalScore;
24+
// Some older scores don't have correct statistics populated, so let's give them benefit of doubt.
25+
bool scoreIsVeryOld = score.Date < new DateTime(2023, 1, 1, 0, 0, 0);
26+
27+
return oldScoreMatchesExpectations || scoreIsVeryOld;
28+
}
29+
1630
public static long GetNewStandardised(ScoreInfo score)
1731
{
1832
int maxJudgementIndex = 0;

osu.Game/Scoring/ScoreImporter.cs

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ protected override void Populate(ScoreInfo model, ArchiveReader? archive, Realm
8383

8484
if (string.IsNullOrEmpty(model.MaximumStatisticsJson))
8585
model.MaximumStatisticsJson = JsonConvert.SerializeObject(model.MaximumStatistics);
86+
87+
// for pre-ScoreV2 lazer scores, apply a best-effort conversion of total score to ScoreV2.
88+
// this requires: max combo, statistics, max statistics (where available), and mods to already be populated on the score.
89+
if (StandardisedScoreMigrationTools.ShouldMigrateToNewStandardised(model))
90+
model.TotalScore = StandardisedScoreMigrationTools.GetNewStandardised(model);
8691
}
8792

8893
/// <summary>

0 commit comments

Comments
 (0)