From 84afed2be577ee4008653ecbbfe4dd6912cd8629 Mon Sep 17 00:00:00 2001 From: Ryan Stecker Date: Mon, 20 Jun 2011 04:26:36 -0500 Subject: [PATCH] Upgraded DepotDownloader project to 2010, and made it support the new BlobLib. --- DepotDownloader.sln | 4 +- DepotDownloader/CDRManager.cs | 91 ++++++++++++++++---------- DepotDownloader/ContentDownloader.cs | 2 +- DepotDownloader/DepotDownloader.csproj | 40 ++++++++++- 4 files changed, 98 insertions(+), 39 deletions(-) diff --git a/DepotDownloader.sln b/DepotDownloader.sln index af710988..c37f33f3 100644 --- a/DepotDownloader.sln +++ b/DepotDownloader.sln @@ -1,6 +1,6 @@  -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DepotDownloader", "DepotDownloader\DepotDownloader.csproj", "{39159C47-ACD3-449F-96CA-4F30C8ED147A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamKit2", "..\..\SteamKit2\SteamKit2\SteamKit2.csproj", "{BEB5BF07-BB56-402A-97A3-A41C6444C6A5}" diff --git a/DepotDownloader/CDRManager.cs b/DepotDownloader/CDRManager.cs index 46a8923a..c97c73c9 100644 --- a/DepotDownloader/CDRManager.cs +++ b/DepotDownloader/CDRManager.cs @@ -8,11 +8,41 @@ using System.Net; namespace DepotDownloader { + class CDR + { + [BlobField( FieldKey = CDRFields.eFieldApplicationsRecord, Depth = 1, Complex = true )] + public List Apps { get; set; } + } + + class App + { + [BlobField( FieldKey = CDRAppRecordFields.eFieldName, Depth = 1 )] + public string Name { get; set; } + + [BlobField( FieldKey = CDRAppRecordFields.eFieldAppId, Depth = 1 )] + public int AppID { get; set; } + + [BlobField( FieldKey = CDRAppRecordFields.eFieldCurrentVersionId, Depth = 1 )] + public int CurrentVersion { get; set; } + + [BlobField( FieldKey = CDRAppRecordFields.eFieldFilesystemsRecord, Complex = true, Depth = 1 )] + public List FileSystems { get; set; } + } + + class FileSystem + { + [BlobField( FieldKey = CDRAppFilesystemFields.eFieldAppId )] + public int AppID { get; set; } + + [BlobField( FieldKey = CDRAppFilesystemFields.eFieldMountName )] + public string Name { get; set; } + } + static class CDRManager { const string BLOB_FILENAME = "cdr.blob"; - static Blob cdrBlob; + static CDR cdrObj; public static void Update() @@ -54,71 +84,62 @@ namespace DepotDownloader return; } - cdrBlob = new Blob( cdr ); - Console.WriteLine( " Done!" ); - } - - static Blob GetAppBlob( int appID ) - { - Blob appsBlob = cdrBlob[ CDRFields.eFieldApplicationsRecord ].GetChildBlob(); - foreach ( var blobField in appsBlob.Fields ) + using ( var reader = BlobTypedReader.Create( new MemoryStream( cdr ) ) ) { - Blob appBlob = blobField.GetChildBlob(); - int currentAppID = appBlob[ CDRAppRecordFields.eFieldAppId ].GetInt32Data(); - - if ( appID != currentAppID ) - continue; + reader.Process(); - return appBlob; + cdrObj = reader.Target; } - return null; + Console.WriteLine( " Done!" ); + } + + static App GetAppBlob( int appID ) + { + return cdrObj.Apps.Find( ( app ) => app.AppID == appID ); } public static string GetDepotName( int depotId ) { - Blob appBlob = GetAppBlob( depotId ); + App app = GetAppBlob( depotId ); - if ( appBlob == null ) + if ( app == null ) { return null; } - else - { - return appBlob[ CDRAppRecordFields.eFieldName ].GetStringData(); - } + + return app.Name; } public static int GetLatestDepotVersion( int depotId ) { - Blob appBlob = GetAppBlob( depotId ); + App app = GetAppBlob( depotId ); - if ( appBlob == null ) + if ( app == null ) { return -1; - } else { - return appBlob[ CDRAppRecordFields.eFieldCurrentVersionId ].GetInt32Data(); } + + return app.CurrentVersion; } public static List GetDepotIDsForGameserver( string gameName ) { List appIDs = new List(); - Blob serverAppInfoBlob = GetAppBlob( 4 ); - Blob serverAppInfo = serverAppInfoBlob[ CDRAppRecordFields.eFieldFilesystemsRecord ].GetChildBlob(); + App serverAppInfoBlob = GetAppBlob( 4 ); - foreach ( var blobField in serverAppInfo.Fields ) + foreach ( var blobField in serverAppInfoBlob.FileSystems ) { - Blob filesystemBlob = blobField.GetChildBlob(); - string mountName = filesystemBlob[CDRAppFilesystemFields.eFieldMountName].GetStringData(); - if ( mountName.Equals( gameName, StringComparison.OrdinalIgnoreCase) || - mountName.Equals( gameName + "-win32", StringComparison.OrdinalIgnoreCase) || - mountName.Equals( gameName + "-linux", StringComparison.OrdinalIgnoreCase)) + string mountName = blobField.Name; + + if ( mountName.Equals( gameName, StringComparison.OrdinalIgnoreCase ) || + mountName.Equals( gameName + "-win32", StringComparison.OrdinalIgnoreCase ) || + mountName.Equals( gameName + "-linux", StringComparison.OrdinalIgnoreCase ) ) { - appIDs.Add( filesystemBlob[ CDRAppFilesystemFields.eFieldAppId ].GetInt32Data() ); + appIDs.Add( blobField.AppID ); } } diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index 2ca3b8be..9edf0430 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -222,7 +222,7 @@ namespace DepotDownloader ClientTGT clientTgt; byte[] serverTgt; - Blob accountRecord; + AuthBlob accountRecord; Console.Write( "Logging '{0}' into Steam2... ", username ); AuthServerClient.LoginResult result = asClient.Login( username, password, out clientTgt, out serverTgt, out accountRecord ); diff --git a/DepotDownloader/DepotDownloader.csproj b/DepotDownloader/DepotDownloader.csproj index f3cd963b..032edeaf 100644 --- a/DepotDownloader/DepotDownloader.csproj +++ b/DepotDownloader/DepotDownloader.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -12,6 +12,25 @@ DepotDownloader v3.5 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true true @@ -21,6 +40,7 @@ DEBUG;TRACE prompt 4 + AllRules.ruleset pdbonly @@ -29,6 +49,7 @@ TRACE prompt 4 + AllRules.ruleset @@ -58,6 +79,23 @@ SteamKit2 + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + +