diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index bfac09c11..8276ca3fa 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -305,6 +305,48 @@ namespace ArchiSteamFarm { } } + internal async Task> GetUnreleasedAppIDs(HashSet appIDs) { + if ((appIDs == null) || (appIDs.Count == 0)) { + ArchiLogger.LogNullError(nameof(appIDs)); + return null; + } + + AsyncJobMultiple.ResultSet productInfo; + + try { + productInfo = await SteamApps.PICSGetProductInfo(appIDs, Enumerable.Empty()); + } catch (Exception e) { + ArchiLogger.LogGenericException(e); + return null; + } + + HashSet result = new HashSet(); + foreach (KeyValuePair app in productInfo.Results.SelectMany(productResult => productResult.Apps)) { + if (!appIDs.Contains(app.Key)) { + continue; + } + + string releaseState = app.Value.KeyValues["common"]["ReleaseState"].Value; + if (string.IsNullOrEmpty(releaseState)) { + continue; + } + + switch (releaseState) { + case "released": + break; + case "prerelease": + case "preloadonly": + result.Add(app.Key); + break; + default: + ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(releaseState), releaseState)); + break; + } + } + + return result; + } + internal static async Task InitializeCMs(uint cellID, IServerListProvider serverListProvider) { if (serverListProvider == null) { Program.ArchiLogger.LogNullError(nameof(serverListProvider)); diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 685896408..2c3f51db4 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -178,6 +178,20 @@ namespace ArchiSteamFarm { return; } + // Remove from our list all games that were not released yet + HashSet appIDs = new HashSet(GamesToFarm.Select(game => game.AppID)); + + HashSet unreleasedAppIDs = await Bot.GetUnreleasedAppIDs(appIDs).ConfigureAwait(false); + if ((unreleasedAppIDs != null) && (unreleasedAppIDs.Count > 0)) { + if (GamesToFarm.RemoveWhere(game => unreleasedAppIDs.Contains(game.AppID)) > 0) { + if (GamesToFarm.Count == 0) { + Bot.ArchiLogger.LogGenericInfo(Strings.NothingToIdle); + await Bot.OnFarmingFinished(false).ConfigureAwait(false); + return; + } + } + } + Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.GamesToIdle, GamesToFarm.Count, GamesToFarm.Sum(game => game.CardsRemaining), TimeRemaining.ToHumanReadable())); // This is the last moment for final check if we can farm diff --git a/ArchiSteamFarm/ConcurrentHashSet.cs b/ArchiSteamFarm/ConcurrentHashSet.cs index 0a65026a9..a6ec3d626 100644 --- a/ArchiSteamFarm/ConcurrentHashSet.cs +++ b/ArchiSteamFarm/ConcurrentHashSet.cs @@ -114,6 +114,16 @@ namespace ArchiSteamFarm { } } + internal int RemoveWhere(Predicate match) { + Lock.EnterWriteLock(); + + try { + return HashSet.RemoveWhere(match); + } finally { + Lock.ExitWriteLock(); + } + } + internal bool ReplaceIfNeededWith(ICollection items) { Lock.EnterUpgradeableReadLock(); diff --git a/ArchiSteamFarm/Localization/Strings.Designer.cs b/ArchiSteamFarm/Localization/Strings.Designer.cs index 73cdd912b..7ea88f345 100644 --- a/ArchiSteamFarm/Localization/Strings.Designer.cs +++ b/ArchiSteamFarm/Localization/Strings.Designer.cs @@ -1413,15 +1413,6 @@ namespace ArchiSteamFarm.Localization { } } - /// - /// Looks up a localized string similar to Received unknown confirmation type, please report this: {0}. - /// - internal static string WarningMobileAuthenticatorUnknownConfirmationType { - get { - return ResourceManager.GetString("WarningMobileAuthenticatorUnknownConfirmationType", resourceCulture); - } - } - /// /// Looks up a localized string similar to Please review our privacy policy section on the wiki if you're concerned about what ASF is in fact doing!. /// @@ -1458,6 +1449,15 @@ namespace ArchiSteamFarm.Localization { } } + /// + /// Looks up a localized string similar to Received unknown value for {0}, please report this: {1}. + /// + internal static string WarningUnknownValuePleaseReport { + get { + return ResourceManager.GetString("WarningUnknownValuePleaseReport", resourceCulture); + } + } + /// /// Looks up a localized string similar to Ignoring WCF command because --client wasn't specified: {0}. /// diff --git a/ArchiSteamFarm/Localization/Strings.resx b/ArchiSteamFarm/Localization/Strings.resx index 495ee9fd3..2c1975394 100644 --- a/ArchiSteamFarm/Localization/Strings.resx +++ b/ArchiSteamFarm/Localization/Strings.resx @@ -334,9 +334,9 @@ StackTrace: <{0}> Please enter your WCF host: {0} will be replaced by bot's name. Please note that this translation should end with space - - Received unknown confirmation type, please report this: {0} - {0} will be replaced by unknown confirmation type + + Received unknown value for {0}, please report this: {1} + {0} will be replaced by object's name, {1} will be replaced by value for that object Playing more than {0} games concurrently is not possible, only first {0} entries from {1} will be used! diff --git a/ArchiSteamFarm/MobileAuthenticator.cs b/ArchiSteamFarm/MobileAuthenticator.cs index bfa9ef3fb..7fdad2a73 100644 --- a/ArchiSteamFarm/MobileAuthenticator.cs +++ b/ArchiSteamFarm/MobileAuthenticator.cs @@ -175,7 +175,7 @@ namespace ArchiSteamFarm { } else if (description.StartsWith("Trade with ", StringComparison.Ordinal)) { type = Steam.ConfirmationDetails.EType.Trade; } else { - Bot.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningMobileAuthenticatorUnknownConfirmationType, description)); + Bot.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(description), description)); type = Steam.ConfirmationDetails.EType.Other; }