Added support for Steam3 license list in AccountHasAccess.

Ignore contenttype when depots are present.
pull/8/head
azuisleet 14 years ago
parent 6c545644e0
commit 0374a529b9

@ -142,14 +142,28 @@ namespace DepotDownloader
return false;
}
static bool AccountHasAccess( int depotId )
static bool AccountHasAccess( int depotId, bool appId=false )
{
if ( steam3 == null || steam3.Licenses == null )
return CDRManager.SubHasDepot( 0, depotId );
foreach ( var license in steam3.Licenses )
{
// TODO: support PackageInfoRequest/Response, this is a steam2 dependency
steam3.RequestPackageInfo(license.PackageID);
SteamApps.PackageInfoCallback.Package package;
if (steam3.PackageInfo.TryGetValue((uint)license.PackageID, out package) && package.Status == SteamApps.PackageInfoCallback.Package.PackageStatus.OK)
{
KeyValue root = package.Data[license.PackageID.ToString()];
KeyValue subset = (appId == true ? root["appids"] : root["depotids"]);
foreach (var child in subset.Children)
{
if (child.AsInteger() == depotId)
return true;
}
}
if ( CDRManager.SubHasDepot( ( int )license.PackageID, depotId ) )
return true;
}
@ -210,10 +224,12 @@ namespace DepotDownloader
int contenttype = config[appId.ToString()]["contenttype"].AsInteger(0);
// EContentDownloadSourceType?
if (contenttype == 3)
return DownloadSource.Steam3;
if (contenttype != 3)
{
Console.WriteLine("Warning: App {0} does not advertise contenttype as steam3, but has steam3 depots", appId);
}
return DownloadSource.Steam2;
return DownloadSource.Steam3;
}
@ -329,7 +345,7 @@ namespace DepotDownloader
if(steam3 != null)
steam3.RequestAppInfo((uint)appId);
if (!AccountHasAccess(appId))
if (!AccountHasAccess(appId, true))
{
string contentName = GetAppOrDepotName(-1, appId);
Console.WriteLine("App {0} ({1}) is not available from this account.", appId, contentName);
@ -401,7 +417,7 @@ namespace DepotDownloader
string contentName = GetAppOrDepotName(depotId, appId);
if (!AccountHasAccess(depotId))
if (!AccountHasAccess(depotId, false))
{
Console.WriteLine("Depot {0} ({1}) is not available from this account.", depotId, contentName);

@ -32,6 +32,7 @@ namespace DepotDownloader
public Dictionary<uint, byte[]> AppTickets { get; private set; }
public Dictionary<uint, byte[]> DepotKeys { get; private set; }
public Dictionary<uint, SteamApps.AppInfoCallback.App> AppInfo { get; private set; }
public Dictionary<uint, SteamApps.PackageInfoCallback.Package> PackageInfo { get; private set; }
public Dictionary<uint, bool> AppInfoOverridesCDR { get; private set; }
public SteamClient steamClient;
@ -51,6 +52,8 @@ namespace DepotDownloader
// output
Credentials credentials;
JobCallback<SteamApps.PackageInfoCallback> packageInfoCallback;
static readonly TimeSpan STEAM3_TIMEOUT = TimeSpan.FromSeconds( 30 );
@ -65,6 +68,7 @@ namespace DepotDownloader
this.AppTickets = new Dictionary<uint, byte[]>();
this.DepotKeys = new Dictionary<uint, byte[]>();
this.AppInfo = new Dictionary<uint, SteamApps.AppInfoCallback.App>();
this.PackageInfo = new Dictionary<uint, SteamApps.PackageInfoCallback.Package>();
this.AppInfoOverridesCDR = new Dictionary<uint, bool>();
this.steamClient = new SteamClient();
@ -117,6 +121,9 @@ namespace DepotDownloader
Console.WriteLine("Got AppInfo for {0}: {1}", app.AppID, app.Status);
AppInfo.Add(app.AppID, app);
if (app.Status == SteamApps.AppInfoCallback.App.AppInfoStatus.Unknown)
continue;
KeyValue depots;
if (app.Sections.TryGetValue(EAppInfoSection.Depots, out depots))
{
@ -138,6 +145,33 @@ namespace DepotDownloader
}
}
public void RequestPackageInfo(uint packageId)
{
if (PackageInfo.ContainsKey(packageId))
return;
if (packageInfoCallback != null)
{
do
{
WaitForCallbacks();
}
while (!packageInfoCallback.Completed && !bAborted);
if (PackageInfo.ContainsKey(packageId))
return;
}
using (var singlePackageInfoCallback = new JobCallback<SteamApps.PackageInfoCallback>(PackageInfoCallback, callbacks, steamApps.GetPackageInfo(packageId)))
{
do
{
WaitForCallbacks();
}
while (!singlePackageInfoCallback.Completed && !bAborted);
}
}
public void RequestAppTicket(uint appId)
{
if (AppTickets.ContainsKey(appId) || bAborted)
@ -291,8 +325,23 @@ namespace DepotDownloader
Console.WriteLine("Got {0} licenses for account!", licenseList.LicenseList.Count);
Licenses = licenseList.LicenseList;
List<uint> licenseQuery = new List<uint>();
foreach (var license in Licenses)
{
licenseQuery.Add(license.PackageID);
}
packageInfoCallback = new JobCallback<SteamApps.PackageInfoCallback>(PackageInfoCallback, callbacks, steamApps.GetPackageInfo(licenseQuery));
}
private void PackageInfoCallback(SteamApps.PackageInfoCallback packageInfo, ulong jobid)
{
foreach (var package in packageInfo.Packages)
{
PackageInfo[package.PackageID] = package;
}
}
private void UpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback machineAuth, ulong jobId)
{

Loading…
Cancel
Save