mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:07:52 +08:00
Make ruleset id non-nullable
This commit is contained in:
parent
80ecf81be3
commit
dcfe9c67e3
@ -13,7 +13,8 @@ namespace osu.Game.Configuration
|
||||
[PrimaryKey]
|
||||
public Guid ID { get; set; } = Guid.NewGuid();
|
||||
|
||||
public int? RulesetID { get; set; }
|
||||
[Indexed]
|
||||
public int RulesetID { get; set; }
|
||||
|
||||
public int? Variant { get; set; }
|
||||
|
||||
|
@ -458,11 +458,13 @@ namespace osu.Game
|
||||
{
|
||||
foreach (var dkb in existingSettings)
|
||||
{
|
||||
if (dkb.RulesetID == null) continue;
|
||||
|
||||
usage.Realm.Add(new RealmRulesetSetting
|
||||
{
|
||||
ValueString = dkb.StringValue,
|
||||
Key = dkb.Key,
|
||||
RulesetID = dkb.RulesetID,
|
||||
RulesetID = dkb.RulesetID.Value,
|
||||
Variant = dkb.Variant
|
||||
});
|
||||
}
|
||||
|
@ -20,12 +20,17 @@ namespace osu.Game.Rulesets.Configuration
|
||||
|
||||
private List<RealmRulesetSetting> databasedSettings = new List<RealmRulesetSetting>();
|
||||
|
||||
private readonly RulesetInfo ruleset;
|
||||
private readonly int rulesetId;
|
||||
|
||||
protected RulesetConfigManager(SettingsStore store, RulesetInfo ruleset, int? variant = null)
|
||||
{
|
||||
realmFactory = store?.Realm;
|
||||
this.ruleset = ruleset;
|
||||
|
||||
if (realmFactory != null && !ruleset.ID.HasValue)
|
||||
throw new InvalidOperationException("Attempted to add databased settings for a non-databased ruleset");
|
||||
|
||||
rulesetId = ruleset.ID ?? -1;
|
||||
|
||||
this.variant = variant;
|
||||
|
||||
Load();
|
||||
@ -35,12 +40,10 @@ namespace osu.Game.Rulesets.Configuration
|
||||
|
||||
protected override void PerformLoad()
|
||||
{
|
||||
var rulesetID = ruleset?.ID;
|
||||
|
||||
if (realmFactory != null)
|
||||
{
|
||||
// As long as RulesetConfigCache exists, there is no need to subscribe to realm events.
|
||||
databasedSettings = realmFactory.Context.All<RealmRulesetSetting>().Where(b => b.RulesetID == rulesetID && b.Variant == variant).ToList();
|
||||
databasedSettings = realmFactory.Context.All<RealmRulesetSetting>().Where(b => b.RulesetID == rulesetId && b.Variant == variant).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +69,7 @@ namespace osu.Game.Rulesets.Configuration
|
||||
{
|
||||
Key = lookup.ToString(),
|
||||
Value = bindable.Value,
|
||||
RulesetID = ruleset?.ID,
|
||||
RulesetID = rulesetId,
|
||||
Variant = variant,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user