From 52b9d2d662fc457c5ddf07280b473b1bec5b9adf Mon Sep 17 00:00:00 2001 From: Archi Date: Wed, 29 Nov 2023 20:35:39 +0100 Subject: [PATCH] Revert market_fee_app There are occurances where this is definitely wrong to use --- .../Steam/Data/InventoryResponse.cs | 34 +++++++++++++++---- .../Steam/Integration/ArchiWebHandler.cs | 10 +----- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ArchiSteamFarm/Steam/Data/InventoryResponse.cs b/ArchiSteamFarm/Steam/Data/InventoryResponse.cs index 40534e281..60930bb68 100644 --- a/ArchiSteamFarm/Steam/Data/InventoryResponse.cs +++ b/ArchiSteamFarm/Steam/Data/InventoryResponse.cs @@ -95,9 +95,6 @@ internal sealed class InventoryResponse : OptionalResultResponse { [JsonProperty("appid", Required = Required.Always)] internal readonly uint AppID; - [JsonProperty("market_fee_app", Required = Required.Always)] - internal readonly uint RealAppID; - [JsonProperty("tags", Required = Required.DisallowNull)] internal readonly ImmutableHashSet Tags = ImmutableHashSet.Empty; @@ -127,6 +124,33 @@ internal sealed class InventoryResponse : OptionalResultResponse { } } + internal uint RealAppID { + get { + foreach (Tag tag in Tags) { + switch (tag.Identifier) { + case "Game": + if (string.IsNullOrEmpty(tag.Value) || (tag.Value.Length <= 4) || !tag.Value.StartsWith("app_", StringComparison.Ordinal)) { + ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(tag.Value), tag.Value)); + + break; + } + + string appIDText = tag.Value[4..]; + + if (!uint.TryParse(appIDText, out uint appID) || (appID == 0)) { + ASF.ArchiLogger.LogNullError(appID); + + break; + } + + return appID; + } + } + + return 0; + } + } + internal Asset.EType Type { get { Asset.EType type = Asset.EType.Unknown; @@ -252,16 +276,14 @@ internal sealed class InventoryResponse : OptionalResultResponse { } // Constructed from trades being received/sent - internal Description(uint appID, ulong classID, ulong instanceID, bool marketable, uint realAppID, ICollection? tags = null) { + internal Description(uint appID, ulong classID, ulong instanceID, bool marketable, ICollection? tags = null) { ArgumentOutOfRangeException.ThrowIfZero(appID); ArgumentOutOfRangeException.ThrowIfZero(classID); - ArgumentOutOfRangeException.ThrowIfZero(realAppID); AppID = appID; ClassID = classID; InstanceID = instanceID; Marketable = marketable; - RealAppID = realAppID; Tradable = true; if (tags?.Count > 0) { diff --git a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs index fd8e915fb..263b98349 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs @@ -558,14 +558,6 @@ public sealed class ArchiWebHandler : IDisposable { continue; } - uint realAppID = description["market_fee_app"].AsUnsignedInteger(); - - if (realAppID == 0) { - Bot.ArchiLogger.LogNullError(realAppID); - - return null; - } - bool marketable = description["marketable"].AsBoolean(); List tags = description["tags"].Children; @@ -597,7 +589,7 @@ public sealed class ArchiWebHandler : IDisposable { } } - InventoryResponse.Description parsedDescription = new(appID, classID, instanceID, marketable, realAppID, parsedTags); + InventoryResponse.Description parsedDescription = new(appID, classID, instanceID, marketable, parsedTags); descriptions[key] = parsedDescription; }