diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 00c6451aa..ebeb46b3e 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -137,9 +137,11 @@ namespace ArchiSteamFarm { BotName = botName; SentryFile = botPath + ".bin"; - BotConfig = BotConfig.Load(botPath + ".json"); + string botConfigFile = botPath + ".json"; + + BotConfig = BotConfig.Load(botConfigFile); if (BotConfig == null) { - Logging.LogGenericError("Your bot config is invalid, refusing to start this bot instance!", botName); + Logging.LogGenericError("Your bot config is invalid, please verify content of " + botConfigFile + " and try again!", botName); return; } @@ -148,9 +150,11 @@ namespace ArchiSteamFarm { return; } - BotDatabase = BotDatabase.Load(botPath + ".db"); + string botDatabaseFile = botPath + ".db"; + + BotDatabase = BotDatabase.Load(botDatabaseFile); if (BotDatabase == null) { - Logging.LogGenericError("Bot database could not be loaded, refusing to create this bot instance! In order to recreate it, remove " + BotDatabase + " and try again!", botName); + Logging.LogGenericError("Bot database could not be loaded, refusing to create this bot instance! In order to recreate it, remove " + botDatabaseFile + " and try again!", botName); return; } diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index d21c90b81..a55c243b4 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -147,6 +147,11 @@ namespace ArchiSteamFarm { return null; } + if (botConfig == null) { + Logging.LogNullError(nameof(botConfig)); + return null; + } + // Support encrypted passwords if ((botConfig.PasswordFormat != CryptoHelper.ECryptoMethod.PlainText) && !string.IsNullOrEmpty(botConfig.SteamPassword)) { // In worst case password will result in null, which will have to be corrected by user during runtime diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 30d39a8d9..5fa89f388 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -65,8 +65,8 @@ namespace ArchiSteamFarm { internal const string LogFile = "log.txt"; private const string GithubReleaseURL = "https://api.github.com/repos/" + SharedInfo.GithubRepo + "/releases"; // GitHub API is HTTPS only - private const string GlobalConfigFile = ASF + ".json"; - private const string GlobalDatabaseFile = ASF + ".db"; + private const string GlobalConfigFileName = ASF + ".json"; + private const string GlobalDatabaseFileName = ASF + ".db"; internal static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version; @@ -378,16 +378,20 @@ namespace ArchiSteamFarm { } private static void InitServices() { - GlobalConfig = GlobalConfig.Load(Path.Combine(ConfigDirectory, GlobalConfigFile)); + string globalConfigFile = Path.Combine(ConfigDirectory, GlobalConfigFileName); + + GlobalConfig = GlobalConfig.Load(globalConfigFile); if (GlobalConfig == null) { - Logging.LogGenericError("Global config could not be loaded, please make sure that " + GlobalConfigFile + " exists and is valid!"); + Logging.LogGenericError("Global config could not be loaded, please make sure that " + globalConfigFile + " exists and is valid!"); Thread.Sleep(5000); Exit(1); } - GlobalDatabase = GlobalDatabase.Load(Path.Combine(ConfigDirectory, GlobalDatabaseFile)); + string globalDatabaseFile = Path.Combine(ConfigDirectory, GlobalDatabaseFileName); + + GlobalDatabase = GlobalDatabase.Load(globalDatabaseFile); if (GlobalDatabase == null) { - Logging.LogGenericError("Global database could not be loaded, if issue persists, please remove " + GlobalDatabaseFile + " in order to recreate database!"); + Logging.LogGenericError("Global database could not be loaded, if issue persists, please remove " + globalDatabaseFile + " in order to recreate database!"); Thread.Sleep(5000); Exit(1); }