Slight refactor to support steam3 depots in an app

pull/8/head
azuisleet 14 years ago
parent f258ac8903
commit 1024dde88d

@ -123,25 +123,28 @@ namespace DepotDownloader
return false;
}
static bool DepotHasSteam3Manifest( int depotId, out ulong manifest_id )
static bool DepotHasSteam3Manifest( int depotId, int appId, out ulong manifest_id )
{
if (steam3 == null || steam3.AppInfo == null)
{
manifest_id = 0;
return false;
}
string appkey = appId.ToString();
string depotkey = depotId.ToString();
foreach (var app in steam3.AppInfo)
{
KeyValue depots;
if (app.AppID == depotId && app.Sections.TryGetValue((int)EAppInfoSection.AppInfoSectionDepots, out depots))
if (app.AppID == appId && app.Sections.TryGetValue((int)EAppInfoSection.AppInfoSectionDepots, out depots))
{
string key = depotId.ToString();
// check depots for app
foreach (var kv in depots[key].Children)
foreach (var depotkv in depots[appkey].Children)
{
var node = kv.Children
if(depotkv.Name != depotkey)
continue;
var node = depotkv.Children
.Where(c => c.Name == "manifests").First().Children
.Where(d => d.Name == "Public").First();
@ -155,7 +158,7 @@ namespace DepotDownloader
return false;
}
public static void Download( int depotId, int depotVersion, int cellId, string username, string password, bool onlyManifest, bool gameServer, bool exclude, string installDir, string[] fileList )
public static void Download( int depotId, int appId, int depotVersion, int cellId, string username, string password, bool onlyManifest, bool gameServer, bool exclude, string installDir, string[] fileList )
{
if ( !CreateDirectories( depotId, depotVersion, ref installDir ) )
{
@ -168,7 +171,7 @@ namespace DepotDownloader
if (username != null)
{
// ServerCache.BuildAuthServers( username );
credentials = GetCredentials((uint)depotId, username, password);
credentials = GetCredentials((uint)depotId, (uint)appId, username, password);
}
if (!AccountHasAccess(depotId))
@ -183,7 +186,7 @@ namespace DepotDownloader
}
ulong steam3_manifest;
if ( DepotHasSteam3Manifest( depotId, out steam3_manifest ) )
if ( DepotHasSteam3Manifest( depotId, appId, out steam3_manifest ) )
{
DownloadSteam3( credentials, depotId, depotVersion, cellId, steam3_manifest, installDir );
}
@ -264,6 +267,14 @@ namespace DepotDownloader
foreach (var file in depotManifest.Files)
{
string download_path = Path.Combine(installDir, file.FileName);
if (file.TotalSize == 0) // directory
{
if (!Directory.Exists(download_path))
Directory.CreateDirectory(download_path);
continue;
}
string dir_path = Path.GetDirectoryName(download_path);
int top = Console.CursorTop;
@ -294,6 +305,7 @@ namespace DepotDownloader
}
Console.CursorTop = top_post;
Console.CursorLeft = 0;
}
}
@ -467,7 +479,7 @@ namespace DepotDownloader
}
static ContentServerClient.Credentials GetCredentials( uint depotId, string username, string password )
static ContentServerClient.Credentials GetCredentials( uint depotId, uint appId, string username, string password )
{
steam3 = new Steam3Session(
@ -477,7 +489,8 @@ namespace DepotDownloader
Password = password,
},
depotId
depotId,
appId
);
var steam3Credentials = steam3.WaitForCredentials();

@ -147,7 +147,7 @@ namespace DepotDownloader
if ( !bGameserver && !bApp )
{
ContentDownloader.Download( depotId, depotVersion, cellId, username, password, !bDebot, false, false, installDir, files );
ContentDownloader.Download( depotId, depotId, depotVersion, cellId, username, password, !bDebot, false, false, installDir, files );
}
else
{
@ -170,7 +170,12 @@ namespace DepotDownloader
string depotName = CDRManager.GetDepotName( currentDepotId );
Console.WriteLine( "Downloading \"{0}\" version {1} ...", depotName, depotVersion );
ContentDownloader.Download( currentDepotId, depotVersion, cellId, username, password, false, bGameserver, !bNoExclude, installDir, files );
int sourceId = depotId;
if (bGameserver)
sourceId = currentDepotId;
ContentDownloader.Download( currentDepotId, sourceId, depotVersion, cellId, username, password, false, bGameserver, !bNoExclude, installDir, files );
}
}
}

@ -28,6 +28,7 @@ namespace DepotDownloader
}
public byte[] DepotKey { get; private set; }
public ReadOnlyCollection<SteamApps.AppInfoCallback.AppInfo> AppInfo { get; private set; }
SteamClient steamClient;
@ -44,6 +45,7 @@ namespace DepotDownloader
// input
uint depotId;
uint appId; // base
SteamUser.LogOnDetails logonDetails;
// output
@ -52,9 +54,10 @@ namespace DepotDownloader
static readonly TimeSpan STEAM3_TIMEOUT = TimeSpan.FromSeconds( 30 );
public Steam3Session( SteamUser.LogOnDetails details, uint depotId )
public Steam3Session( SteamUser.LogOnDetails details, uint depotId, uint appId )
{
this.depotId = depotId;
this.appId = appId;
this.logonDetails = details;
this.credentials = new Credentials();
@ -146,7 +149,7 @@ namespace DepotDownloader
Console.WriteLine( "Got Steam2 Ticket!" );
credentials.Steam2Ticket = msg.Steam2Ticket;
steamApps.GetAppInfo( depotId );
steamApps.GetAppInfo( appId );
steamApps.GetAppOwnershipTicket( depotId );
steamApps.GetDepotDecryptionKey( depotId );
}

Loading…
Cancel
Save