mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Add extra bulltetproofing to AH's PlayGames()
We don't want to ever have duplicates there, even if userspace supplies them (which should never happen)
This commit is contained in:
@@ -1226,7 +1226,7 @@ namespace ArchiSteamFarm.Steam {
|
||||
gameName = string.Format(CultureInfo.CurrentCulture, BotConfig.CustomGamePlayedWhileFarming!, game.AppID, game.GameName);
|
||||
}
|
||||
|
||||
await ArchiHandler.PlayGames(game.PlayableAppID.ToEnumerable(), gameName).ConfigureAwait(false);
|
||||
await ArchiHandler.PlayGames(new HashSet<uint>(1) { game.PlayableAppID }, gameName).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
internal async Task IdleGames(IReadOnlyCollection<Game> games) {
|
||||
@@ -1240,7 +1240,7 @@ namespace ArchiSteamFarm.Steam {
|
||||
gameName = string.Format(CultureInfo.CurrentCulture, BotConfig.CustomGamePlayedWhileFarming!, string.Join(", ", games.Select(game => game.AppID)), string.Join(", ", games.Select(game => game.GameName)));
|
||||
}
|
||||
|
||||
await ArchiHandler.PlayGames(games.Select(game => game.PlayableAppID), gameName).ConfigureAwait(false);
|
||||
await ArchiHandler.PlayGames(games.Select(game => game.PlayableAppID).ToHashSet(), gameName).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
internal async Task ImportKeysToRedeem(string filePath) {
|
||||
|
||||
@@ -471,7 +471,7 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
return response.Result == EResult.OK;
|
||||
}
|
||||
|
||||
internal async Task PlayGames(IEnumerable<uint> gameIDs, string? gameName = null) {
|
||||
internal async Task PlayGames(IReadOnlyCollection<uint> gameIDs, string? gameName = null) {
|
||||
if (gameIDs == null) {
|
||||
throw new ArgumentNullException(nameof(gameIDs));
|
||||
}
|
||||
@@ -512,11 +512,17 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
maxGamesCount++;
|
||||
}
|
||||
|
||||
foreach (uint gameID in gameIDs.Where(gameID => gameID != 0)) {
|
||||
request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = new GameID(gameID) });
|
||||
if (gameIDs.Count > 0) {
|
||||
#pragma warning disable CA1508 // False positive, not every IReadOnlyCollection is ISet
|
||||
IEnumerable<uint> uniqueValidGameIDs = (gameIDs as ISet<uint> ?? gameIDs.Distinct()).Where(gameID => gameID > 0);
|
||||
#pragma warning restore CA1508 // False positive, not every IReadOnlyCollection is ISet
|
||||
|
||||
if (request.Body.games_played.Count >= maxGamesCount) {
|
||||
break;
|
||||
foreach (uint gameID in uniqueValidGameIDs) {
|
||||
request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = new GameID(gameID) });
|
||||
|
||||
if (request.Body.games_played.Count >= maxGamesCount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace ArchiSteamFarm.Steam.Interaction {
|
||||
// We add extra delay because OnFarmingStopped() also executes PlayGames()
|
||||
// Despite of proper order on our end, Steam network might not respect it
|
||||
await Task.Delay(Bot.CallbackSleep).ConfigureAwait(false);
|
||||
await Bot.ArchiHandler.PlayGames(Enumerable.Empty<uint>(), Bot.BotConfig.CustomGamePlayedWhileIdle).ConfigureAwait(false);
|
||||
await Bot.ArchiHandler.PlayGames(Array.Empty<uint>(), Bot.BotConfig.CustomGamePlayedWhileIdle).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (resumeInSeconds > 0) {
|
||||
|
||||
Reference in New Issue
Block a user