From ee22c24370f57b066d73d37e2d04a1c970a19ab4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 23 Nov 2021 12:52:17 +0900 Subject: [PATCH 1/2] Update `RulesetConfigCache` to cache via `ShortName` instead of `ID` --- osu.Game/Rulesets/RulesetConfigCache.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Rulesets/RulesetConfigCache.cs b/osu.Game/Rulesets/RulesetConfigCache.cs index aeac052673..5a082300b4 100644 --- a/osu.Game/Rulesets/RulesetConfigCache.cs +++ b/osu.Game/Rulesets/RulesetConfigCache.cs @@ -19,7 +19,7 @@ public class RulesetConfigCache : Component private readonly RealmContextFactory realmFactory; private readonly RulesetStore rulesets; - private readonly Dictionary configCache = new Dictionary(); + private readonly Dictionary configCache = new Dictionary(); public RulesetConfigCache(RealmContextFactory realmFactory, RulesetStore rulesets) { @@ -36,10 +36,10 @@ protected override void LoadComplete() // let's keep things simple for now and just retrieve all the required configs at startup.. foreach (var ruleset in rulesets.AvailableRulesets) { - if (ruleset.ID == null) + if (string.IsNullOrEmpty(ruleset.ShortName)) continue; - configCache[ruleset.ID.Value] = ruleset.CreateInstance().CreateConfig(settingsStore); + configCache[ruleset.ShortName] = ruleset.CreateInstance().CreateConfig(settingsStore); } } @@ -51,10 +51,10 @@ protected override void LoadComplete() /// If doesn't have a valid . public IRulesetConfigManager GetConfigFor(Ruleset ruleset) { - if (ruleset.RulesetInfo.ID == null) + if (string.IsNullOrEmpty(ruleset.ShortName)) return null; - if (!configCache.TryGetValue(ruleset.RulesetInfo.ID.Value, out var config)) + if (!configCache.TryGetValue(ruleset.RulesetInfo.ShortName, out var config)) // any ruleset request which wasn't initialised on startup should not be stored to realm. // this should only be used by tests. return ruleset.CreateConfig(null); From 0aedbbe165a67c1436e53b6a0b144bcd3d215d70 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 24 Nov 2021 14:04:55 +0900 Subject: [PATCH 2/2] Fix incorrect fallback logic causing test failure --- osu.Game/Rulesets/RulesetConfigCache.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Rulesets/RulesetConfigCache.cs b/osu.Game/Rulesets/RulesetConfigCache.cs index 5a082300b4..262340b4ee 100644 --- a/osu.Game/Rulesets/RulesetConfigCache.cs +++ b/osu.Game/Rulesets/RulesetConfigCache.cs @@ -51,9 +51,6 @@ protected override void LoadComplete() /// If doesn't have a valid . public IRulesetConfigManager GetConfigFor(Ruleset ruleset) { - if (string.IsNullOrEmpty(ruleset.ShortName)) - return null; - if (!configCache.TryGetValue(ruleset.RulesetInfo.ShortName, out var config)) // any ruleset request which wasn't initialised on startup should not be stored to realm. // this should only be used by tests.