From 7fe65144c11c27d8eeac8f58647d21a23ef1cad4 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sun, 18 Dec 2016 16:03:32 +0100 Subject: [PATCH] Code cleanup --- ArchiSteamFarm/ArchiHandler.cs | 12 ++++++++++-- ArchiSteamFarm/Bot.cs | 16 ++++++++++++++-- ArchiSteamFarm/FodyWeavers.xml | 1 + ArchiSteamFarm/JSON/Steam.cs | 5 ++++- ArchiSteamFarm/Statistics.cs | 6 +++--- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/ArchiSteamFarm/ArchiHandler.cs b/ArchiSteamFarm/ArchiHandler.cs index 3fee457cd..5c9843ec2 100644 --- a/ArchiSteamFarm/ArchiHandler.cs +++ b/ArchiSteamFarm/ArchiHandler.cs @@ -169,11 +169,19 @@ namespace ArchiSteamFarm { ClientMsgProtobuf request = new ClientMsgProtobuf(EMsg.ClientGamesPlayed); if (!string.IsNullOrEmpty(gameName)) { - request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_extra_info = gameName, game_id = new GameID { AppType = GameID.GameType.Shortcut, ModID = uint.MaxValue } }); + request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { + game_extra_info = gameName, + game_id = new GameID { + AppType = GameID.GameType.Shortcut, + ModID = uint.MaxValue + } + }); } foreach (uint gameID in gameIDs.Where(gameID => gameID != 0)) { - request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = new GameID(gameID) }); + request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { + game_id = new GameID(gameID) + }); } Client.Send(request); diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index e3e78cf4f..899c61c8b 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -286,7 +286,9 @@ namespace ArchiSteamFarm { } internal static string GetAPIStatus() { - var response = new { Bots }; + var response = new { + Bots + }; try { return JsonConvert.SerializeObject(response); @@ -1342,7 +1344,17 @@ namespace ArchiSteamFarm { } // Inform the steam servers that we're accepting this sentry file - SteamUser.SendMachineAuthResponse(new SteamUser.MachineAuthDetails { JobID = callback.JobID, FileName = callback.FileName, BytesWritten = callback.BytesToWrite, FileSize = fileSize, Offset = callback.Offset, Result = EResult.OK, LastError = 0, OneTimePassword = callback.OneTimePassword, SentryFileHash = sentryHash }); + SteamUser.SendMachineAuthResponse(new SteamUser.MachineAuthDetails { + JobID = callback.JobID, + FileName = callback.FileName, + BytesWritten = callback.BytesToWrite, + FileSize = fileSize, + Offset = callback.Offset, + Result = EResult.OK, + LastError = 0, + OneTimePassword = callback.OneTimePassword, + SentryFileHash = sentryHash + }); } private void OnNotifications(ArchiHandler.NotificationsCallback callback) { diff --git a/ArchiSteamFarm/FodyWeavers.xml b/ArchiSteamFarm/FodyWeavers.xml index 5df39cbf9..c4626742c 100644 --- a/ArchiSteamFarm/FodyWeavers.xml +++ b/ArchiSteamFarm/FodyWeavers.xml @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/ArchiSteamFarm/JSON/Steam.cs b/ArchiSteamFarm/JSON/Steam.cs index b17a8c66e..bd880476e 100644 --- a/ArchiSteamFarm/JSON/Steam.cs +++ b/ArchiSteamFarm/JSON/Steam.cs @@ -440,7 +440,10 @@ namespace ArchiSteamFarm.JSON { foreach (Item item in ItemsToReceive) { Dictionary itemsPerType; if (!itemsToReceivePerGame.TryGetValue(item.RealAppID, out itemsPerType)) { - itemsPerType = new Dictionary { [item.Type] = item.Amount }; + itemsPerType = new Dictionary { + { item.Type, item.Amount } + }; + itemsToReceivePerGame[item.RealAppID] = itemsPerType; } else { uint amount; diff --git a/ArchiSteamFarm/Statistics.cs b/ArchiSteamFarm/Statistics.cs index d8a15a078..db73d1518 100644 --- a/ArchiSteamFarm/Statistics.cs +++ b/ArchiSteamFarm/Statistics.cs @@ -36,15 +36,15 @@ namespace ArchiSteamFarm { private readonly Bot Bot; private readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1); + private bool HasAutomatedTrading => Bot.HasMobileAuthenticator && Bot.HasValidApiKey; + private bool SteamTradeMatcher => Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.SteamTradeMatcher); + private string LastAvatarHash; private DateTime LastHeartBeat = DateTime.MinValue; private bool? LastMatchEverything; private string LastNickname; private bool ShouldSendHeartBeats; - private bool HasAutomatedTrading => Bot.HasMobileAuthenticator && Bot.HasValidApiKey; - private bool SteamTradeMatcher => Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.SteamTradeMatcher); - internal Statistics(Bot bot) { if (bot == null) { throw new ArgumentNullException(nameof(bot));