Add versioning of local scores

For any potential future usage
This commit is contained in:
Dean Herbert 2023-12-21 18:14:24 +09:00
parent 0648201844
commit a4baa0a716
No known key found for this signature in database
5 changed files with 22 additions and 2 deletions

View File

@ -196,6 +196,7 @@ namespace osu.Game.Tests.Scores.IO
User = new APIUser { Username = "Test user" },
BeatmapInfo = beatmap.Beatmaps.First(),
Ruleset = new OsuRuleset().RulesetInfo,
Version = "12345",
Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() },
};
@ -203,6 +204,7 @@ namespace osu.Game.Tests.Scores.IO
Assert.IsTrue(imported.Mods.Any(m => m is OsuModHardRock));
Assert.IsTrue(imported.Mods.Any(m => m is OsuModDoubleTime));
Assert.That(imported.Version, Is.EqualTo(toImport.Version));
}
finally
{

View File

@ -41,6 +41,9 @@ namespace osu.Game.Tests.Visual.Gameplay
private BeatmapSetInfo? importedSet;
[Resolved]
private OsuGameBase osu { get; set; } = null!;
[BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio)
{
@ -153,6 +156,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("results displayed", () => Player.GetChildScreen() is ResultsScreen);
AddUntilStep("score in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
AddUntilStep("score has correct version", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID)!.Version), () => Is.EqualTo(osu.Version));
}
[Test]

View File

@ -90,8 +90,9 @@ namespace osu.Game.Database
/// 36 2023-10-26 Add LegacyOnlineID to ScoreInfo. Move osu_scores_*_high IDs stored in OnlineID to LegacyOnlineID. Reset anomalous OnlineIDs.
/// 38 2023-12-10 Add EndTimeObjectCount and TotalObjectCount to BeatmapInfo.
/// 39 2023-12-19 Migrate any EndTimeObjectCount and TotalObjectCount values of 0 to -1 to better identify non-calculated values.
/// 40 2023-12-21 Add ScoreInfo.Version to keep track of which build scores were set on.
/// </summary>
private const int schema_version = 39;
private const int schema_version = 40;
/// <summary>
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.

View File

@ -46,6 +46,12 @@ namespace osu.Game.Scoring
/// </remarks>
public BeatmapInfo? BeatmapInfo { get; set; }
/// <summary>
/// The version of the client this score was set using.
/// Sourced from <see cref="OsuGameBase.Version"/> at the point of score submission.
/// </summary>
public string Version { get; set; } = string.Empty;
/// <summary>
/// The <see cref="osu.Game.Beatmaps.BeatmapInfo.Hash"/> at the point in time when the score was set.
/// </summary>

View File

@ -109,6 +109,9 @@ namespace osu.Game.Screens.Play
[Resolved]
private MusicController musicController { get; set; }
[Resolved]
private OsuGameBase game { get; set; }
public GameplayState GameplayState { get; private set; }
private Ruleset ruleset;
@ -1155,7 +1158,11 @@ namespace osu.Game.Screens.Play
/// <returns>The <see cref="Scoring.Score"/>.</returns>
protected virtual Score CreateScore(IBeatmap beatmap) => new Score
{
ScoreInfo = new ScoreInfo { User = api.LocalUser.Value },
ScoreInfo = new ScoreInfo
{
User = api.LocalUser.Value,
Version = game.Version,
},
};
/// <summary>