This commit is contained in:
JustArchi
2017-09-18 19:18:22 +02:00
parent 15df745680
commit 179c162526
3 changed files with 18 additions and 4 deletions

View File

@@ -494,15 +494,25 @@ namespace ArchiSteamFarm {
while (true) {
Steam.InventoryResponse response = await WebBrowser.UrlGetToJsonResultRetry<Steam.InventoryResponse>(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<ulong, (uint AppID, Steam.Asset.EType Type, bool Tradable)> descriptionMap = new Dictionary<ulong, (uint AppID, Steam.Asset.EType Type, bool Tradable)>();
foreach (Steam.InventoryResponse.Description description in response.Descriptions.Where(description => description != null)) {
if (description.ClassID == 0) {

View File

@@ -370,6 +370,12 @@ namespace ArchiSteamFarm.JSON {
[JsonProperty(PropertyName = "descriptions", Required = Required.DisallowNull)]
internal readonly HashSet<Description> 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; }

View File

@@ -143,8 +143,6 @@ namespace ArchiSteamFarm {
return default;
}
ArchiLogger.LogGenericDebug("JSON: <" + json + ">");
try {
return JsonConvert.DeserializeObject<T>(json);
} catch (JsonException e) {