From 179c1625265e2f8000245f163cdb479b7a66a978 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Mon, 18 Sep 2017 19:18:22 +0200 Subject: [PATCH] Misc --- ArchiSteamFarm/ArchiWebHandler.cs | 14 ++++++++++++-- ArchiSteamFarm/JSON/Steam.cs | 6 ++++++ ArchiSteamFarm/WebBrowser.cs | 2 -- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index fbc2b49c0..787e7d115 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -494,15 +494,25 @@ namespace ArchiSteamFarm { while (true) { Steam.InventoryResponse response = await WebBrowser.UrlGetToJsonResultRetry(request + (startAssetID > 0 ? "&start_assetid=" + startAssetID : "")).ConfigureAwait(false); - if (response?.Success != true) { + if (response == null) { return null; } - if ((response.Assets == null) || (response.Assets.Count == 0) || (response.Descriptions == null) || (response.Descriptions.Count == 0)) { + if (!response.Success) { + Bot.ArchiLogger.LogGenericWarning(!string.IsNullOrEmpty(response.Error) ? string.Format(Strings.WarningFailedWithError, response.Error) : Strings.WarningFailed); + return null; + } + + if (response.TotalInventoryCount == 0) { // Empty inventory return result; } + if ((response.Assets == null) || (response.Assets.Count == 0) || (response.Descriptions == null) || (response.Descriptions.Count == 0)) { + Bot.ArchiLogger.LogNullError(nameof(response.Assets) + " || " + nameof(response.Descriptions)); + return null; + } + Dictionary descriptionMap = new Dictionary(); foreach (Steam.InventoryResponse.Description description in response.Descriptions.Where(description => description != null)) { if (description.ClassID == 0) { diff --git a/ArchiSteamFarm/JSON/Steam.cs b/ArchiSteamFarm/JSON/Steam.cs index bbaa86296..6c5f01dfc 100644 --- a/ArchiSteamFarm/JSON/Steam.cs +++ b/ArchiSteamFarm/JSON/Steam.cs @@ -370,6 +370,12 @@ namespace ArchiSteamFarm.JSON { [JsonProperty(PropertyName = "descriptions", Required = Required.DisallowNull)] internal readonly HashSet Descriptions; + [JsonProperty(PropertyName = "error", Required = Required.DisallowNull)] + internal readonly string Error; + + [JsonProperty(PropertyName = "total_inventory_count", Required = Required.Always)] + internal readonly uint TotalInventoryCount; + internal ulong LastAssetID { get; private set; } internal bool MoreItems { get; private set; } internal bool Success { get; private set; } diff --git a/ArchiSteamFarm/WebBrowser.cs b/ArchiSteamFarm/WebBrowser.cs index 68e9c89db..9c9c1b463 100644 --- a/ArchiSteamFarm/WebBrowser.cs +++ b/ArchiSteamFarm/WebBrowser.cs @@ -143,8 +143,6 @@ namespace ArchiSteamFarm { return default; } - ArchiLogger.LogGenericDebug("JSON: <" + json + ">"); - try { return JsonConvert.DeserializeObject(json); } catch (JsonException e) {