From 56d48ae210d32bdb479d7e8b0558a47113340c0c Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 2 Jun 2018 06:45:55 +0200 Subject: [PATCH] Correct redeem keys changing logic when running out of queue https://steamcommunity.com/groups/ascfarm/discussions/1/1697174779852958220/ --- ArchiSteamFarm/Bot.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 0fd42a029..624783249 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -4283,8 +4283,11 @@ namespace ArchiSteamFarm { string key = keysEnumerator.MoveNext() ? keysEnumerator.Current : null; // Initial key while (!string.IsNullOrEmpty(key)) { + string startingKey = key; + using (IEnumerator botsEnumerator = Bots.Where(bot => (bot.Value != this) && !rateLimitedBots.Contains(bot.Value) && bot.Value.IsConnectedAndLoggedOn && bot.Value.IsOperator(steamID)).OrderBy(bot => bot.Key).Select(bot => bot.Value).GetEnumerator()) { Bot currentBot = this; + while (!string.IsNullOrEmpty(key) && (currentBot != null)) { if (redeemFlags.HasFlag(ERedeemFlags.Validate) && !IsValidCdKey(key)) { key = keysEnumerator.MoveNext() ? keysEnumerator.Current : null; // Next key @@ -4428,11 +4431,11 @@ namespace ArchiSteamFarm { currentBot = botsEnumerator.MoveNext() ? botsEnumerator.Current : null; } } + } - if (currentBot == null) { - // We ran out of bots to try for this key, so change it - key = keysEnumerator.MoveNext() ? keysEnumerator.Current : null; // Next key - } + if (key == startingKey) { + // We ran out of bots to try for this key, so change it to avoid infinite loop + key = keysEnumerator.MoveNext() ? keysEnumerator.Current : null; // Next key } } }