WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 9f4fd19

Browse files
authored
Merge pull request #139 from playtron-os/fix/GAMEOS-6059-f2p-license
fix: Add license for F2P games
2 parents 3ab5d35 + 3e4fb27 commit 9f4fd19

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

SteamBus.App/src/Steam.Content/ContentDownloader.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,15 @@ public async Task DownloadAppAsync(uint appId, AppDownloadOptions options, Actio
567567
public async Task<List<RequiredDepot>> GetAppRequiredDepots(uint appId, AppDownloadOptions options, bool forceRefreshDepots = true, bool log = true)
568568
{
569569
if (!session.IsAppOwned(appId))
570-
return [];
570+
{
571+
var granted = await session.RequestFreeAppLicense(appId);
572+
if (!granted)
573+
return [];
574+
if (log)
575+
Console.WriteLine("Successfully obtained free license for app {0}", appId);
576+
}
571577

572-
await this.session.RequestAppInfo(appId);
578+
await this.session.RequestAppInfo(appId, forceRefreshDepots);
573579

574580
var os = options.Os ?? GetSteamOS();
575581
var arch = options.Arch;
@@ -581,6 +587,17 @@ public async Task<List<RequiredDepot>> GetAppRequiredDepots(uint appId, AppDownl
581587
var depotIdsFound = new List<uint>();
582588
var depotIdsExpected = requiredDepots.Select(x => x.DepotId).ToList();
583589
var depots = session.GetSteam3AppSection(appId, EAppInfoSection.Depots);
590+
591+
// If no depots section but we own the app, the cached app info might be public_only
592+
// Force refresh and try again
593+
if (depots == null && session.IsAppOwned(appId) && forceRefreshDepots)
594+
{
595+
if (log)
596+
Console.WriteLine("No depots found for owned app {0}, forcing app info refresh...", appId);
597+
598+
await this.session.RequestAppInfo(appId, true);
599+
depots = session.GetSteam3AppSection(appId, EAppInfoSection.Depots);
600+
}
584601
var disabledDlcIds = depotConfigStore.GetDisabledDlcIds(appId);
585602

586603
// List of dlcs found in depots config but are not owned

SteamBus.App/src/Steam.Session/SteamSession.cs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,29 @@ public async Task RequestAppInfo(uint appId, bool bForce = false)
297297
{
298298
request.AccessToken = token;
299299
}
300+
else
301+
{
302+
// Try to find a package token for this app
303+
foreach (var package in PackageInfo.Values)
304+
{
305+
if (package == null) continue;
306+
var appids = package.KeyValues["appids"].Children;
307+
foreach (var appidKv in appids)
308+
{
309+
if (appidKv.AsUnsignedInteger() == appId)
310+
{
311+
ulong packageToken = PackageTokens.GetValueOrDefault(package.ID);
312+
if (packageToken > 0)
313+
{
314+
Console.WriteLine("Using package token {0} from package {1} for app {2}", packageToken, package.ID, appId);
315+
request.AccessToken = packageToken;
316+
break;
317+
}
318+
}
319+
}
320+
if (request.AccessToken > 0) break;
321+
}
322+
}
300323

301324
var appInfoMultiple = await steamApps.PICSGetProductInfo([request], []);
302325

@@ -378,7 +401,29 @@ public async Task<bool> RequestFreeAppLicense(uint appId)
378401
{
379402
var resultInfo = await steamApps.RequestFreeLicense(appId);
380403

381-
return resultInfo.GrantedApps.Contains(appId);
404+
if (resultInfo.GrantedApps.Contains(appId))
405+
{
406+
Console.WriteLine("Granted free license for app {0}, granted packages: {1}", appId, string.Join(", ", resultInfo.GrantedPackages));
407+
408+
// Fetch package info for the newly granted packages to get the package token
409+
if (resultInfo.GrantedPackages.Count > 0)
410+
{
411+
await RequestPackageInfo(resultInfo.GrantedPackages, true);
412+
413+
// Now request app info with the package token
414+
await RequestAppInfo(appId, true);
415+
416+
// Update ProviderItemMap so IsAppOwned returns true
417+
if (AppInfo.TryGetValue(appId, out var appInfo))
418+
{
419+
ProviderItemMap[appId] = GetProviderItem(appId.ToString(), appInfo);
420+
}
421+
}
422+
423+
return true;
424+
}
425+
426+
return false;
382427
}
383428

384429

0 commit comments

Comments
 (0)