1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +08:00

Use similar method of consuming OnlineID as done in beatmap classes

This commit is contained in:
Dean Herbert 2021-12-10 18:32:32 +09:00
parent c9f6c5c673
commit f7c5a3f506
3 changed files with 11 additions and 9 deletions

View File

@ -147,7 +147,7 @@ namespace osu.Game.Database
modelBuilder.Entity<BeatmapInfo>().HasOne(b => b.BaseDifficulty);
modelBuilder.Entity<ScoreInfo>().HasIndex(b => b.OnlineScoreID).IsUnique();
modelBuilder.Entity<ScoreInfo>().HasIndex(b => b.OnlineID).IsUnique();
}
private class OsuDbLoggerFactory : ILoggerFactory

View File

@ -137,7 +137,14 @@ namespace osu.Game.Scoring
[Column("Beatmap")]
public BeatmapInfo BeatmapInfo { get; set; }
public long? OnlineScoreID { get; set; }
private long? onlineID;
[Column("OnlineScoreID")]
public long? OnlineID
{
get => onlineID;
set => onlineID = value > 0 ? value : null;
}
public DateTimeOffset Date { get; set; }
@ -243,12 +250,7 @@ namespace osu.Game.Scoring
#region Implementation of IHasOnlineID
[NotMapped]
public long OnlineID
{
get => OnlineScoreID ?? -1;
set => OnlineScoreID = value;
}
long IHasOnlineID<long>.OnlineID => OnlineID ?? -1;
#endregion

View File

@ -1031,7 +1031,7 @@ namespace osu.Game.Screens.Play
//
// Until we better define the server-side logic behind this, let's not store the online ID to avoid potential unique constraint
// conflicts across various systems (ie. solo and multiplayer).
long onlineScoreId = score.ScoreInfo.OnlineID;
long? onlineScoreId = score.ScoreInfo.OnlineID;
score.ScoreInfo.OnlineID = -1;
await scoreManager.Import(score.ScoreInfo, replayReader).ConfigureAwait(false);