From 9637975bdb067804c83f998a698655d147607b70 Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Tue, 8 Dec 2020 09:20:37 +0100 Subject: [PATCH] alterNERDtive-base: fixed config change handling --- plugins/VoiceAttack-base/base.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/VoiceAttack-base/base.cs b/plugins/VoiceAttack-base/base.cs index d82f022..55f79d5 100644 --- a/plugins/VoiceAttack-base/base.cs +++ b/plugins/VoiceAttack-base/base.cs @@ -260,14 +260,16 @@ namespace alterNERDtive string name = match.Groups["name"].Value; Log.Debug($"Configuration has changed, '{id}.{name}': '{from}' → '{to}'"); + Configuration.Option o = Config.GetOption(id, name); // When loaded from profile but not explicitly set, will be null. // Then load default. // Same applies to resetting a saved option (= saving null to the profile). - _ = to ?? Config.ApplyDefault(id, name); - + if (to == null) + { + _ = to ?? Config.ApplyDefault(id, name); + } // When not null, check if there’s a constraint on valid values. - Configuration.Option o = Config.GetOption(id, name); - if (o.ValidValues != null && !o.ValidValues.Contains(to)) + else if (o.ValidValues != null && !o.ValidValues.Contains(to)) { Log.Error($@"Invalid value ""{to}"" for option ""{id}.{option}"", reverting to default …"); Config.ApplyDefault(id, name);