Skip to content

Commit

Permalink
Improve AllowCraftUnmarketableBoosters accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Jun 15, 2024
1 parent 82e880a commit d224c7d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
13 changes: 5 additions & 8 deletions BoosterManager/Data/MarketableApps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal static async Task<bool> Update() {
|| marketableOverrideResponse == null || marketableOverrideResponse.Content == null
|| unmarketableOverrideResponse == null || unmarketableOverrideResponse.Content == null
) {
ASF.ArchiLogger.LogGenericDebug("Failed to fetch marketable apps data");
ASF.ArchiLogger.LogGenericDebug(Strings.MarketableAppDataFetchFailed);

return false;
}
Expand All @@ -58,7 +58,7 @@ internal static async Task<bool> Update() {
UnmarketableOverrides = unmarketableOverrideResponse.Content;
LastUpdate = DateTime.Now;

// We're good to stop here, but let's try to replace the cached data that may be up to 1 hour old with fresh data from Steam
// We're good to stop here, but let's try to update the cached data that may be up to 1 hour old with fresh data from Steam
await UpdateFromSteam().ConfigureAwait(false);

return true;
Expand Down Expand Up @@ -114,12 +114,9 @@ private static async Task UpdateFromSteam() {

LastSteamUpdate = DateTime.Now;

if (AppIDs.Count - newerAppIDs.Count > 1000) {
// Bad data from Steam, ignore it
return;
}

AppIDs = newerAppIDs.Union(MarketableOverrides).Except(UnmarketableOverrides).ToHashSet();
// Steam's ISteamApps/GetAppList API is unreliable (more details: https://github.com/Citrinate/Steam-MarketableApps/blob/main/update.py)
// Due to this, we should only add apps from this API to our existing list of AppIDs, and should never remove apps just because they don't appear in this API's response
AppIDs.UnionWith(newerAppIDs.Except(UnmarketableOverrides));
}
}
}
4 changes: 4 additions & 0 deletions BoosterManager/Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,8 @@
<value>No boosters will be crafted. This bot either can't craft the requested boosters, or the requested boosters are unmarketable. The following boosters are unmarketable: {0}</value>
<comment>{0} will be replaced by a list of appIDs</comment>
</data>
<data name="MarketableAppDataFetchFailed" xml:space="preserve">
<value>Failed to fetch marketable apps data</value>
<comment/>
</data>
</root>
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ Command | Alias |
"AllowCraftUnmarketableBoosters": false,
```

> [!NOTE]
> The plugin cannot immediately detect when a game's boosters switch from being marketable to unmarketable. It will usually take ~4 hours to detect this change.
---

### GamesToBooster
Expand Down

0 comments on commit d224c7d

Please sign in to comment.