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; 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) if (steam3 == null || steam3.AppInfo == null)
{ {
manifest_id = 0; manifest_id = 0;
return false; return false;
} }
string appkey = appId.ToString();
string depotkey = depotId.ToString();
foreach (var app in steam3.AppInfo) foreach (var app in steam3.AppInfo)
{ {
KeyValue depots; 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 // 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(c => c.Name == "manifests").First().Children
.Where(d => d.Name == "Public").First(); .Where(d => d.Name == "Public").First();
@ -155,7 +158,7 @@ namespace DepotDownloader
return false; 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 ) ) if ( !CreateDirectories( depotId, depotVersion, ref installDir ) )
{ {
@ -168,7 +171,7 @@ namespace DepotDownloader
if (username != null) if (username != null)
{ {
// ServerCache.BuildAuthServers( username ); // ServerCache.BuildAuthServers( username );
credentials = GetCredentials((uint)depotId, username, password); credentials = GetCredentials((uint)depotId, (uint)appId, username, password);
} }
if (!AccountHasAccess(depotId)) if (!AccountHasAccess(depotId))
@ -183,7 +186,7 @@ namespace DepotDownloader
} }
ulong steam3_manifest; ulong steam3_manifest;
if ( DepotHasSteam3Manifest( depotId, out steam3_manifest ) ) if ( DepotHasSteam3Manifest( depotId, appId, out steam3_manifest ) )
{ {
DownloadSteam3( credentials, depotId, depotVersion, cellId, steam3_manifest, installDir ); DownloadSteam3( credentials, depotId, depotVersion, cellId, steam3_manifest, installDir );
} }
@ -264,6 +267,14 @@ namespace DepotDownloader
foreach (var file in depotManifest.Files) foreach (var file in depotManifest.Files)
{ {
string download_path = Path.Combine(installDir, file.FileName); 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); string dir_path = Path.GetDirectoryName(download_path);
int top = Console.CursorTop; int top = Console.CursorTop;
@ -294,6 +305,7 @@ namespace DepotDownloader
} }
Console.CursorTop = top_post; 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( steam3 = new Steam3Session(
@ -477,7 +489,8 @@ namespace DepotDownloader
Password = password, Password = password,
}, },
depotId depotId,
appId
); );
var steam3Credentials = steam3.WaitForCredentials(); var steam3Credentials = steam3.WaitForCredentials();

@ -147,7 +147,7 @@ namespace DepotDownloader
if ( !bGameserver && !bApp ) 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 else
{ {
@ -170,7 +170,12 @@ namespace DepotDownloader
string depotName = CDRManager.GetDepotName( currentDepotId ); string depotName = CDRManager.GetDepotName( currentDepotId );
Console.WriteLine( "Downloading \"{0}\" version {1} ...", depotName, depotVersion ); 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 byte[] DepotKey { get; private set; }
public ReadOnlyCollection<SteamApps.AppInfoCallback.AppInfo> AppInfo { get; private set; } public ReadOnlyCollection<SteamApps.AppInfoCallback.AppInfo> AppInfo { get; private set; }
SteamClient steamClient; SteamClient steamClient;
@ -44,6 +45,7 @@ namespace DepotDownloader
// input // input
uint depotId; uint depotId;
uint appId; // base
SteamUser.LogOnDetails logonDetails; SteamUser.LogOnDetails logonDetails;
// output // output
@ -52,9 +54,10 @@ namespace DepotDownloader
static readonly TimeSpan STEAM3_TIMEOUT = TimeSpan.FromSeconds( 30 ); 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.depotId = depotId;
this.appId = appId;
this.logonDetails = details; this.logonDetails = details;
this.credentials = new Credentials(); this.credentials = new Credentials();
@ -146,7 +149,7 @@ namespace DepotDownloader
Console.WriteLine( "Got Steam2 Ticket!" ); Console.WriteLine( "Got Steam2 Ticket!" );
credentials.Steam2Ticket = msg.Steam2Ticket; credentials.Steam2Ticket = msg.Steam2Ticket;
steamApps.GetAppInfo( depotId ); steamApps.GetAppInfo( appId );
steamApps.GetAppOwnershipTicket( depotId ); steamApps.GetAppOwnershipTicket( depotId );
steamApps.GetDepotDecryptionKey( depotId ); steamApps.GetDepotDecryptionKey( depotId );
} }

Loading…
Cancel
Save