From 12488dafd35df8694017921ada589a9c0e4994b0 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Mon, 28 Mar 2016 13:11:02 +0200 Subject: [PATCH] Misc --- ArchiSteamFarm/BotConfig.cs | 6 +++--- ArchiSteamFarm/GlobalConfig.cs | 4 ++++ ConfigGenerator/ASFConfig.cs | 8 ++++---- ConfigGenerator/BotConfig.cs | 5 ++++- ConfigGenerator/GlobalConfig.cs | 4 ++++ 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index bf037759a..1343d8ded 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -99,14 +99,14 @@ namespace ArchiSteamFarm { internal HashSet GamesPlayedWhileIdle { get; private set; } = new HashSet() { 0 }; - internal static BotConfig Load(string path) { - if (string.IsNullOrEmpty(path) || !File.Exists(path)) { + internal static BotConfig Load(string filePath) { + if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) { return null; } BotConfig botConfig; try { - botConfig = JsonConvert.DeserializeObject(File.ReadAllText(path)); + botConfig = JsonConvert.DeserializeObject(File.ReadAllText(filePath)); } catch (Exception e) { Logging.LogGenericException(e); return null; diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index 2d2cc29c9..fc5d2a11a 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -117,6 +117,10 @@ namespace ArchiSteamFarm { return null; } + if (globalConfig == null) { + return null; + } + // SK2 supports only TCP and UDP steam protocols // Ensure that user can't screw this up switch (globalConfig.SteamProtocol) { diff --git a/ConfigGenerator/ASFConfig.cs b/ConfigGenerator/ASFConfig.cs index ab974cc9b..edf8e1c14 100644 --- a/ConfigGenerator/ASFConfig.cs +++ b/ConfigGenerator/ASFConfig.cs @@ -54,9 +54,9 @@ namespace ConfigGenerator { internal virtual void Remove() { string queryPath = Path.GetFileNameWithoutExtension(FilePath); lock (FilePath) { - foreach (var configFile in Directory.EnumerateFiles(Program.ConfigDirectory, queryPath + ".*")) { + foreach (string botFile in Directory.EnumerateFiles(Program.ConfigDirectory, queryPath + ".*")) { try { - File.Delete(configFile); + File.Delete(botFile); } catch (Exception e) { Logging.LogGenericException(e); } @@ -72,9 +72,9 @@ namespace ConfigGenerator { string queryPath = Path.GetFileNameWithoutExtension(FilePath); lock (FilePath) { - foreach (var file in Directory.EnumerateFiles(Program.ConfigDirectory, queryPath + ".*")) { + foreach (string botFile in Directory.EnumerateFiles(Program.ConfigDirectory, queryPath + ".*")) { try { - File.Move(file, Path.Combine(Program.ConfigDirectory, botName + Path.GetExtension(file))); + File.Move(botFile, Path.Combine(Program.ConfigDirectory, botName + Path.GetExtension(botFile))); } catch (Exception e) { Logging.LogGenericException(e); } diff --git a/ConfigGenerator/BotConfig.cs b/ConfigGenerator/BotConfig.cs index 59bf9fa17..379f9c5c2 100644 --- a/ConfigGenerator/BotConfig.cs +++ b/ConfigGenerator/BotConfig.cs @@ -98,7 +98,6 @@ namespace ConfigGenerator { [JsonProperty(Required = Required.DisallowNull)] public List GamesPlayedWhileIdle { get; set; } = new List(); - internal static BotConfig Load(string filePath) { if (string.IsNullOrEmpty(filePath)) { return null; @@ -116,6 +115,10 @@ namespace ConfigGenerator { return new BotConfig(filePath); } + if (botConfig == null) { + return new BotConfig(filePath); + } + botConfig.FilePath = filePath; return botConfig; diff --git a/ConfigGenerator/GlobalConfig.cs b/ConfigGenerator/GlobalConfig.cs index 39d717ca7..0f008c1ce 100644 --- a/ConfigGenerator/GlobalConfig.cs +++ b/ConfigGenerator/GlobalConfig.cs @@ -120,6 +120,10 @@ namespace ConfigGenerator { return new GlobalConfig(filePath); } + if (globalConfig == null) { + return new GlobalConfig(filePath); + } + globalConfig.FilePath = filePath; // SK2 supports only TCP and UDP steam protocols