From 0ded9698b20c6bbae5e8604a5fdb39d47414b294 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 2 Jul 2022 00:16:26 +0200 Subject: [PATCH] Fix custom game name not being displayed at all In original change I totally forgot custom game ACTUALLY must be the first on the list, otherwise it never works properly. So use exactly the same logic, but with custom name being first (if possible to fit) --- .../Steam/Integration/ArchiHandler.cs | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs index 7ad084d69..eaba2a351 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs @@ -519,23 +519,7 @@ public sealed class ArchiHandler : ClientMsgHandler { // This ensures that custom name will in fact display properly (if it's not omitted due to MaxGamesPlayedConcurrently, that is) Client.Send(request); await Task.Delay(Bot.CallbackSleep).ConfigureAwait(false); - } - if (gameIDs.Count > 0) { -#pragma warning disable CA1508 // False positive, not every IReadOnlyCollection is ISet - IEnumerable uniqueValidGameIDs = (gameIDs as ISet ?? gameIDs.Distinct()).Where(static gameID => gameID > 0); -#pragma warning restore CA1508 // False positive, not every IReadOnlyCollection is ISet - - foreach (uint gameID in uniqueValidGameIDs) { - if (request.Body.games_played.Count >= MaxGamesPlayedConcurrently) { - throw new ArgumentOutOfRangeException(nameof(gameIDs)); - } - - request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = new GameID(gameID) }); - } - } - - if (!string.IsNullOrEmpty(gameName)) { request.Body.games_played.Add( new CMsgClientGamesPlayed.GamePlayed { game_extra_info = gameName, @@ -547,6 +531,27 @@ public sealed class ArchiHandler : ClientMsgHandler { ); } + if (gameIDs.Count > 0) { +#pragma warning disable CA1508 // False positive, not every IReadOnlyCollection is ISet + IEnumerable uniqueValidGameIDs = (gameIDs as ISet ?? gameIDs.Distinct()).Where(static gameID => gameID > 0); +#pragma warning restore CA1508 // False positive, not every IReadOnlyCollection is ISet + + foreach (uint gameID in uniqueValidGameIDs) { + if (request.Body.games_played.Count >= MaxGamesPlayedConcurrently) { + if (string.IsNullOrEmpty(gameName)) { + throw new ArgumentOutOfRangeException(nameof(gameIDs)); + } + + // Make extra space by ditching custom gameName + gameName = null; + + request.Body.games_played.RemoveAt(0); + } + + request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = new GameID(gameID) }); + } + } + Client.Send(request); }