Revert market_fee_app

There are occurances where this is definitely wrong to use
This commit is contained in:
Archi
2023-11-29 20:35:39 +01:00
parent f3cc0b938a
commit 52b9d2d662
2 changed files with 29 additions and 15 deletions

View File

@@ -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<Tag> Tags = ImmutableHashSet<Tag>.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<Tag>? tags = null) {
internal Description(uint appID, ulong classID, ulong instanceID, bool marketable, ICollection<Tag>? 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) {

View File

@@ -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<KeyValue> 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;
}