From 8094b502cb104dad68cb7b1df77e7c1841307e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 23 Dec 2021 19:27:27 +0100 Subject: [PATCH] Remove test-specific logic from `RulesetConfigCache` --- osu.Game/Rulesets/RulesetConfigCache.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/RulesetConfigCache.cs b/osu.Game/Rulesets/RulesetConfigCache.cs index 3d7560a99a..dee13e74a5 100644 --- a/osu.Game/Rulesets/RulesetConfigCache.cs +++ b/osu.Game/Rulesets/RulesetConfigCache.cs @@ -1,10 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using osu.Framework.Graphics; using osu.Game.Configuration; using osu.Game.Database; +using osu.Game.Extensions; using osu.Game.Rulesets.Configuration; namespace osu.Game.Rulesets @@ -40,10 +42,11 @@ namespace osu.Game.Rulesets public IRulesetConfigManager GetConfigFor(Ruleset ruleset) { + if (!IsLoaded) + throw new InvalidOperationException($@"Cannot retrieve {nameof(IRulesetConfigManager)} before {nameof(RulesetConfigCache)} has loaded"); + 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); + throw new InvalidOperationException($@"Attempted to retrieve {nameof(IRulesetConfigManager)} for an unavailable ruleset {ruleset.GetDisplayString()}"); return config; }