1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00

Move preconditions to realm migration step to simplify marker version logic

This commit is contained in:
Dean Herbert 2023-07-04 17:53:53 +09:00
parent 1629024111
commit a0c3fa9c13
3 changed files with 8 additions and 24 deletions

View File

@ -14,7 +14,6 @@ using osu.Framework.Graphics;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets;
@ -199,23 +198,9 @@ namespace osu.Game
private void convertLegacyTotalScoreToStandardised()
{
HashSet<Guid> scoreIds = new HashSet<Guid>();
Logger.Log("Querying for scores that need total score conversion...");
realmAccess.Run(r =>
{
foreach (var score in r.All<ScoreInfo>().Where(s => s.IsLegacyScore))
{
if (!score.Ruleset.IsLegacyRuleset())
continue;
if (score.Version >= 30000003)
continue;
scoreIds.Add(score.ID);
}
});
HashSet<Guid> scoreIds = realmAccess.Run(r => new HashSet<Guid>(r.All<ScoreInfo>().Where(s => s.Version == 30000002).Select(s => s.ID)));
Logger.Log($"Found {scoreIds.Count} scores which require total score conversion.");

View File

@ -970,16 +970,15 @@ namespace osu.Game.Database
case 31:
{
var scores = migration.NewRealm.All<ScoreInfo>();
foreach (var score in scores)
foreach (var score in migration.NewRealm.All<ScoreInfo>())
{
if (score.IsLegacyScore)
if (score.IsLegacyScore && score.Ruleset.IsLegacyRuleset())
{
score.LegacyTotalScore = score.TotalScore;
// Scores with this version will trigger the update process in BackgroundBeatmapProcessor.
// Scores with this version will trigger the score upgrade process in BackgroundBeatmapProcessor.
score.Version = 30000002;
// Set a sane default while background processing runs.
score.LegacyTotalScore = score.TotalScore;
}
else
score.Version = LegacyScoreEncoder.LATEST_VERSION;

View File

@ -28,7 +28,7 @@ namespace osu.Game.Scoring.Legacy
/// <remarks>
/// <list type="bullet">
/// <item><description>30000001: Appends <see cref="LegacyReplaySoloScoreInfo"/> to the end of scores.</description></item>
/// <item><description>30000002: Score stored to replay calculated using the Score V2 algorithm.</description></item>
/// <item><description>30000002: Score stored to replay calculated using the Score V2 algorithm. Legacy scores on this version are candidate to Score V1 -> V2 conversion.</description></item>
/// <item><description>30000003: First version after converting legacy total score to standardised.</description></item>
/// </list>
/// </remarks>