From 709ce6489b426b51ed051c8255947dc9e51597ee Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sun, 6 Mar 2016 14:09:08 +0100 Subject: [PATCH] Add only enabled bots to collection, closes #139 --- ArchiSteamFarm/Bot.cs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 952c9477a..3cb8bb5dc 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -27,7 +27,6 @@ using SteamAuth; using SteamKit2; using SteamKit2.Internal; using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Security.Cryptography; @@ -40,7 +39,7 @@ namespace ArchiSteamFarm { private const ulong ArchiSCFarmGroup = 103582791440160998; private const ushort CallbackSleep = 500; // In miliseconds - internal static readonly ConcurrentDictionary Bots = new ConcurrentDictionary(); + internal static readonly Dictionary Bots = new Dictionary(); private static readonly uint LoginID = MsgClientLogon.ObfuscationMask; // This must be the same for all ASF bots and all ASF processes @@ -111,18 +110,6 @@ namespace ArchiSteamFarm { return; } - bool alreadyExists; - lock (Bots) { - alreadyExists = Bots.ContainsKey(botName); - if (!alreadyExists) { - Bots[botName] = this; - } - } - - if (alreadyExists) { - return; - } - BotName = botName; string botPath = Path.Combine(Program.ConfigDirectory, botName); @@ -176,6 +163,18 @@ namespace ArchiSteamFarm { return; } + bool alreadyExists; + lock (Bots) { + alreadyExists = Bots.ContainsKey(botName); + if (!alreadyExists) { + Bots[botName] = this; + } + } + + if (alreadyExists) { + return; + } + BotDatabase = BotDatabase.Load(botPath + ".db"); SentryFile = botPath + ".bin";