From 381174e48248d13c241e0b9623c4a2eb199a8f4f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Jan 2022 14:40:00 +0900 Subject: [PATCH] Give the placeholder ruleset better defaults to allow tests to work again --- osu.Game/Beatmaps/BeatmapInfo.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index e14e945865..224cf60c49 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -51,7 +51,12 @@ public BeatmapInfo(RulesetInfo ruleset, BeatmapDifficulty difficulty, BeatmapMet [UsedImplicitly] public BeatmapInfo() // TODO: consider removing this and migrating all usages to ctor with parameters. { - Ruleset = new RulesetInfo(); + Ruleset = new RulesetInfo + { + OnlineID = 0, + ShortName = @"osu", + Name = @"null placeholder ruleset" + }; Difficulty = new BeatmapDifficulty(); Metadata = new BeatmapMetadata(); } @@ -149,20 +154,17 @@ public bool BackgroundEquals(BeatmapInfo? other) => other != null #region Compatibility properties - private int rulesetID; - [Ignored] [IgnoreMap] public int RulesetID { - // ReSharper disable once ConstantConditionalAccessQualifier - get => Ruleset?.OnlineID ?? rulesetID; + get => Ruleset.OnlineID; set { - if (Ruleset != null) - throw new InvalidOperationException($"Cannot set a {nameof(RulesetID)} when {nameof(Ruleset)} is non-null"); + if (!string.IsNullOrEmpty(Ruleset.InstantiationInfo)) + throw new InvalidOperationException($"Cannot set a {nameof(RulesetID)} when {nameof(Ruleset)} is already set to an actual ruleset."); - rulesetID = value; + Ruleset.OnlineID = value; } }