From 744084b41870cb5238263dab0a10743d241034a9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Jan 2022 13:51:30 +0900 Subject: [PATCH] Initialise all parameters is paramaterless constructor for now for added safety --- osu.Game/Beatmaps/BeatmapInfo.cs | 9 +++++--- osu.Game/Scoring/ScoreInfo.cs | 39 +++++++++++++++++--------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index b9dd59cfe4..e14e945865 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -31,11 +31,11 @@ namespace osu.Game.Beatmaps public string DifficultyName { get; set; } = string.Empty; - public RulesetInfo Ruleset { get; set; } = null!; + public RulesetInfo Ruleset { get; set; } - public BeatmapDifficulty Difficulty { get; set; } = new BeatmapDifficulty(); + public BeatmapDifficulty Difficulty { get; set; } - public BeatmapMetadata Metadata { get; set; } = new BeatmapMetadata(); + public BeatmapMetadata Metadata { get; set; } [IgnoreMap] [Backlink(nameof(ScoreInfo.BeatmapInfo))] @@ -51,6 +51,9 @@ namespace osu.Game.Beatmaps [UsedImplicitly] public BeatmapInfo() // TODO: consider removing this and migrating all usages to ctor with parameters. { + Ruleset = new RulesetInfo(); + Difficulty = new BeatmapDifficulty(); + Metadata = new BeatmapMetadata(); } public BeatmapSetInfo? BeatmapSet { get; set; } diff --git a/osu.Game/Scoring/ScoreInfo.cs b/osu.Game/Scoring/ScoreInfo.cs index b168726283..fd0f14266a 100644 --- a/osu.Game/Scoring/ScoreInfo.cs +++ b/osu.Game/Scoring/ScoreInfo.cs @@ -32,19 +32,33 @@ namespace osu.Game.Scoring [PrimaryKey] public Guid ID { get; set; } = Guid.NewGuid(); + public BeatmapInfo BeatmapInfo { get; set; } + + public RulesetInfo Ruleset { get; set; } + public IList Files { get; } = null!; public string Hash { get; set; } = string.Empty; public bool DeletePending { get; set; } - public bool Equals(ScoreInfo other) => other.ID == ID; + public long TotalScore { get; set; } + + public int MaxCombo { get; set; } + + public double Accuracy { get; set; } + + public bool HasReplay { get; set; } + + public DateTimeOffset Date { get; set; } + + public double? PP { get; set; } [Indexed] public long OnlineID { get; set; } = -1; [MapTo("User")] - public RealmUser RealmUser { get; set; } = new RealmUser(); + public RealmUser RealmUser { get; set; } [MapTo("Mods")] public string ModsJson { get; set; } = string.Empty; @@ -62,6 +76,9 @@ namespace osu.Game.Scoring [UsedImplicitly] public ScoreInfo() // TODO: consider removing this and migrating all usages to ctor with parameters. { + Ruleset = new RulesetInfo(); + RealmUser = new RealmUser(); + BeatmapInfo = new BeatmapInfo(); } // TODO: this is a bit temporary to account for the fact that this class is used to ferry API user data to certain UI components. @@ -88,22 +105,6 @@ namespace osu.Game.Scoring } } - public long TotalScore { get; set; } - - public int MaxCombo { get; set; } - - public double Accuracy { get; set; } - - public bool HasReplay { get; set; } - - public DateTimeOffset Date { get; set; } - - public double? PP { get; set; } - - public BeatmapInfo BeatmapInfo { get; set; } = null!; - - public RulesetInfo Ruleset { get; set; } = null!; - public ScoreRank Rank { get => (ScoreRank)RankInt; @@ -275,6 +276,8 @@ namespace osu.Game.Scoring #endregion + public bool Equals(ScoreInfo other) => other.ID == ID; + public override string ToString() => this.GetDisplayTitle(); } }