Upgraded DepotDownloader project to 2010, and made it support the new BlobLib.

pull/8/head
Ryan Stecker 15 years ago
parent 387a79a94b
commit 84afed2be5

@ -1,6 +1,6 @@
 
Microsoft Visual Studio Solution File, Format Version 10.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2008 # Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DepotDownloader", "DepotDownloader\DepotDownloader.csproj", "{39159C47-ACD3-449F-96CA-4F30C8ED147A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DepotDownloader", "DepotDownloader\DepotDownloader.csproj", "{39159C47-ACD3-449F-96CA-4F30C8ED147A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamKit2", "..\..\SteamKit2\SteamKit2\SteamKit2.csproj", "{BEB5BF07-BB56-402A-97A3-A41C6444C6A5}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamKit2", "..\..\SteamKit2\SteamKit2\SteamKit2.csproj", "{BEB5BF07-BB56-402A-97A3-A41C6444C6A5}"

@ -8,11 +8,41 @@ using System.Net;
namespace DepotDownloader namespace DepotDownloader
{ {
class CDR
{
[BlobField( FieldKey = CDRFields.eFieldApplicationsRecord, Depth = 1, Complex = true )]
public List<App> 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<FileSystem> 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 static class CDRManager
{ {
const string BLOB_FILENAME = "cdr.blob"; const string BLOB_FILENAME = "cdr.blob";
static Blob cdrBlob; static CDR cdrObj;
public static void Update() public static void Update()
@ -54,71 +84,62 @@ namespace DepotDownloader
return; 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<CDR>.Create( new MemoryStream( cdr ) ) )
{ {
Blob appBlob = blobField.GetChildBlob(); reader.Process();
int currentAppID = appBlob[ CDRAppRecordFields.eFieldAppId ].GetInt32Data();
if ( appID != currentAppID )
continue;
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 ) public static string GetDepotName( int depotId )
{ {
Blob appBlob = GetAppBlob( depotId ); App app = GetAppBlob( depotId );
if ( appBlob == null ) if ( app == null )
{ {
return null; return null;
} }
else
{ return app.Name;
return appBlob[ CDRAppRecordFields.eFieldName ].GetStringData();
}
} }
public static int GetLatestDepotVersion( int depotId ) public static int GetLatestDepotVersion( int depotId )
{ {
Blob appBlob = GetAppBlob( depotId ); App app = GetAppBlob( depotId );
if ( appBlob == null ) if ( app == null )
{ {
return -1; return -1;
} else {
return appBlob[ CDRAppRecordFields.eFieldCurrentVersionId ].GetInt32Data();
} }
return app.CurrentVersion;
} }
public static List<int> GetDepotIDsForGameserver( string gameName ) public static List<int> GetDepotIDsForGameserver( string gameName )
{ {
List<int> appIDs = new List<int>(); List<int> appIDs = new List<int>();
Blob serverAppInfoBlob = GetAppBlob( 4 ); App serverAppInfoBlob = GetAppBlob( 4 );
Blob serverAppInfo = serverAppInfoBlob[ CDRAppRecordFields.eFieldFilesystemsRecord ].GetChildBlob();
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) || string mountName = blobField.Name;
mountName.Equals( gameName + "-win32", StringComparison.OrdinalIgnoreCase) ||
mountName.Equals( gameName + "-linux", StringComparison.OrdinalIgnoreCase)) 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 );
} }
} }

@ -222,7 +222,7 @@ namespace DepotDownloader
ClientTGT clientTgt; ClientTGT clientTgt;
byte[] serverTgt; byte[] serverTgt;
Blob accountRecord; AuthBlob accountRecord;
Console.Write( "Logging '{0}' into Steam2... ", username ); Console.Write( "Logging '{0}' into Steam2... ", username );
AuthServerClient.LoginResult result = asClient.Login( username, password, out clientTgt, out serverTgt, out accountRecord ); AuthServerClient.LoginResult result = asClient.Login( username, password, out clientTgt, out serverTgt, out accountRecord );

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -12,6 +12,25 @@
<AssemblyName>DepotDownloader</AssemblyName> <AssemblyName>DepotDownloader</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -21,6 +40,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -29,6 +49,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
@ -58,6 +79,23 @@
<Name>SteamKit2</Name> <Name>SteamKit2</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

Loading…
Cancel
Save