Modify default logic of handling keys

I'm not yet sure if I want to keep it, but for now the logic is changed to start distributing/forwarding key from the bot that got it, and not from start of the collection
This commit is contained in:
JustArchi
2016-07-17 04:19:56 +02:00
parent 08c41fe80b
commit 84271488e6

View File

@@ -927,6 +927,8 @@ namespace ArchiSteamFarm {
using (IEnumerator<Bot> iterator = Bots.Values.GetEnumerator()) {
string key = reader.ReadLine();
Bot currentBot = this;
bool startHandling = false;
while (!string.IsNullOrEmpty(key) && (currentBot != null)) {
if (validate && !IsValidCdKey(key)) {
key = reader.ReadLine(); // Next key
@@ -969,8 +971,18 @@ namespace ArchiSteamFarm {
break; // Next bot, without changing key
}
bool alreadyHandled = false;
foreach (Bot bot in Bots.Values.Where(bot => (bot != this) && bot.SteamClient.IsConnected)) {
bool startInnerHandling = false;
bool alreadyInnerHandled = false;
foreach (Bot bot in Bots.Values) {
if (bot == this) {
startInnerHandling = true;
continue;
}
if (!startInnerHandling || !bot.SteamClient.IsConnected) {
continue;
}
ArchiHandler.PurchaseResponseCallback otherResult = await bot.ArchiHandler.RedeemKey(key).ConfigureAwait(false);
if (otherResult == null) {
response.Append(Environment.NewLine + "<" + bot.BotName + "> Key: " + key + " | Status: Timeout!");
@@ -981,13 +993,13 @@ namespace ArchiSteamFarm {
case ArchiHandler.PurchaseResponseCallback.EPurchaseResult.DuplicatedKey:
case ArchiHandler.PurchaseResponseCallback.EPurchaseResult.InvalidKey:
case ArchiHandler.PurchaseResponseCallback.EPurchaseResult.OK:
alreadyHandled = true; // This key is already handled, as we either redeemed it or we're sure it's dupe/invalid
alreadyInnerHandled = true; // This key is already handled, as we either redeemed it or we're sure it's dupe/invalid
break;
}
response.Append(Environment.NewLine + "<" + bot.BotName + "> Key: " + key + " | Status: " + otherResult.PurchaseResult + " | Items: " + string.Join("", otherResult.Items));
if (alreadyHandled) {
if (alreadyInnerHandled) {
break;
}
}
@@ -1004,7 +1016,10 @@ namespace ArchiSteamFarm {
do {
currentBot = iterator.MoveNext() ? iterator.Current : null;
} while ((currentBot == this) || ((currentBot != null) && !currentBot.SteamClient.IsConnected));
if (currentBot == this) {
startHandling = true;
}
} while (!startHandling || (currentBot == this) || ((currentBot != null) && !currentBot.SteamClient.IsConnected));
}
}