Skip to content

Commit

Permalink
Fix tradableOnly/marketableOnly not working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Mar 17, 2024
1 parent 5723ee7 commit 1c01d8f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
16 changes: 15 additions & 1 deletion ArchiSteamFarm/Steam/Integration/ArchiHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,21 @@ public async IAsyncEnumerable<Asset> GetMyInventoryAsync(uint appID = Asset.Stea
}

foreach (CEcon_Asset? asset in response.assets) {
if (!descriptions.TryGetValue((asset.classid, asset.instanceid), out InventoryDescription? description) || !assetIDs.Add(asset.assetid)) {
if (!assetIDs.Add(asset.assetid)) {
continue;
}

(ulong ClassID, ulong InstanceID) key = (asset.classid, asset.instanceid);

if (!descriptions.TryGetValue(key, out InventoryDescription? description)) {
// Best effort only
description = new InventoryDescription(appID, asset.classid, asset.instanceid);

descriptions.Add(key, description);
}

// Extra bulletproofing against Steam showing us middle finger
if ((tradableOnly && !description.Tradable) || (marketableOnly && !description.Marketable)) {
continue;
}

Expand Down
11 changes: 10 additions & 1 deletion ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,19 @@ public async IAsyncEnumerable<Asset> GetInventoryAsync(ulong steamID = 0, uint a
}

foreach (Asset asset in response.Content.Assets) {
if (!descriptions.TryGetValue((asset.ClassID, asset.InstanceID), out InventoryDescription? description) || !assetIDs.Add(asset.AssetID)) {
if (!assetIDs.Add(asset.AssetID)) {
continue;
}

(ulong ClassID, ulong InstanceID) key = (asset.ClassID, asset.InstanceID);

if (!descriptions.TryGetValue(key, out InventoryDescription? description)) {
// Best effort only
description = new InventoryDescription(appID, asset.ClassID, asset.InstanceID);

descriptions.Add(key, description);
}

asset.Description = description;

yield return asset;
Expand Down

0 comments on commit 1c01d8f

Please sign in to comment.