From 77719159d0f38b0e4279018c22abb9800c43e1a0 Mon Sep 17 00:00:00 2001 From: Nick Blakely Date: Mon, 5 Sep 2022 14:40:36 -0700 Subject: [PATCH] Fix config defaulting logic. --- Giants.Launcher/Config.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Giants.Launcher/Config.cs b/Giants.Launcher/Config.cs index c9fd725..4a28690 100644 --- a/Giants.Launcher/Config.cs +++ b/Giants.Launcher/Config.cs @@ -39,13 +39,22 @@ if (this.userConfig.ContainsKey(section)) { dynamic sectionObject = this.userConfig[section]; - if (sectionObject != null) + if (sectionObject != null && sectionObject.ContainsKey(key)) { - return sectionObject.ContainsKey(key) ? (string)sectionObject[key] : ""; + return (string)sectionObject[key]; } } - return this.defaultConfig[section][key]; + if (this.defaultConfig.ContainsKey(section)) + { + dynamic sectionObject = this.defaultConfig[section]; + if (sectionObject != null && sectionObject.ContainsKey(key)) + { + return (string)sectionObject[key]; + } + } + + return string.Empty; } // TODO: other accessors unimplemented as we only need master server host name for now