Added (bad and incomplete) support for specifying a game name instead of a depot id.

pull/8/head
Asher Baker 15 years ago
parent 3a8fbb363c
commit 43632c4095

@ -58,22 +58,71 @@ namespace DepotDownloader
Console.WriteLine( " Done!" );
}
public static int GetLatestDepotVersion( int depotId )
static Blob GetAppBlob( int appID )
{
Blob appsBlob = cdrBlob[ CDRFields.eFieldApplicationsRecord ].GetChildBlob();
foreach ( var blobField in appsBlob.Fields )
{
Blob appBlob = blobField.GetChildBlob();
int appId = appBlob[ CDRAppRecordFields.eFieldAppId ].GetInt32Data();
int currentAppID = appBlob[ CDRAppRecordFields.eFieldAppId ].GetInt32Data();
if ( depotId != appId )
if ( appID != currentAppID )
continue;
return appBlob;
}
return null;
}
public static string GetDepotName( int depotId )
{
Blob appBlob = GetAppBlob( depotId );
if ( appBlob == null )
{
return null;
}
else
{
return appBlob[ CDRAppRecordFields.eFieldName ].GetStringData();
}
}
public static int GetLatestDepotVersion( int depotId )
{
Blob appBlob = GetAppBlob( depotId );
if ( appBlob == null )
{
return -1;
} else {
return appBlob[ CDRAppRecordFields.eFieldCurrentVersionId ].GetInt32Data();
}
}
public static List<int> GetDepotIDsForGameserver( string gameName )
{
List<int> appIDs = new List<int>();
Blob serverAppInfoBlob = GetAppBlob( 4 );
Blob serverAppInfo = serverAppInfoBlob[ CDRAppRecordFields.eFieldFilesystemsRecord ].GetChildBlob();
foreach ( var blobField in serverAppInfo.Fields )
{
Blob filesystemBlob = blobField.GetChildBlob();
string mountName = filesystemBlob[CDRAppFilesystemFields.eFieldMountName].GetStringData();
if ( gameName.Equals( mountName, StringComparison.OrdinalIgnoreCase ) ||
gameName.Equals( mountName + "-win32", StringComparison.OrdinalIgnoreCase ) ||
gameName.Equals( mountName + "-linux", StringComparison.OrdinalIgnoreCase ) )
{
appIDs.Add( filesystemBlob[ CDRAppFilesystemFields.eFieldAppId ].GetInt32Data() );
}
}
return -1;
return appIDs;
}
static byte[] GetCdr()

@ -24,23 +24,30 @@ namespace DepotDownloader
CDRManager.Update();
bool bDebot = true;
bool bGameserver = true;
int depotId = GetIntParameter( args, "-depot" );
if ( depotId == -1 )
int depotId = -1;
string gameName = GetStringParameter( args, "-game" );
if ( gameName == null )
{
depotId = GetIntParameter( args, "-manifest" );
bDebot = false;
depotId = GetIntParameter( args, "-depot" );
bGameserver = false;
if ( depotId == -1 )
{
Console.WriteLine( "Error: -depot or -manifest not specified!" );
return;
depotId = GetIntParameter( args, "-manifest" );
bDebot = false;
if ( depotId == -1 )
{
Console.WriteLine( "Error: -game, -depot or -manifest not specified!" );
return;
}
}
}
int depotVersion = GetIntParameter( args, "-version" );
if ( depotVersion == -1 )
if ( !bGameserver && depotVersion == -1 )
{
int latestVer = CDRManager.GetLatestDepotVersion( depotId );
@ -96,8 +103,29 @@ namespace DepotDownloader
string username = GetStringParameter( args, "-username" );
string password = GetStringParameter( args, "-password" );
ContentDownloader.Download( depotId, depotVersion, cellId, username, password, !bDebot, files );
if ( !bGameserver )
{
ContentDownloader.Download( depotId, depotVersion, cellId, username, password, !bDebot, files );
}
else
{
List<int> depotIDs = CDRManager.GetDepotIDsForGameserver( gameName );
foreach ( int currentDepotId in depotIDs )
{
depotVersion = CDRManager.GetLatestDepotVersion( currentDepotId );
if ( depotVersion == -1 )
{
Console.WriteLine( "Error: Unable to find DepotID {0} in the CDR!", currentDepotId );
return;
}
string depotName = CDRManager.GetDepotName( currentDepotId );
Console.WriteLine( "Downloading \"{0}\" version {1} ...", depotName, depotVersion );
ContentDownloader.Download( currentDepotId, depotVersion, cellId, username, password, false, files );
}
}
}
static int IndexOfParam( string[] args, string param )
@ -140,6 +168,8 @@ namespace DepotDownloader
Console.WriteLine( "\t-depot #\t\t\t- the DepotID to download." );
Console.WriteLine( "\t OR" );
Console.WriteLine( "\t-manifest #\t\t\t- downloads a human readable manifest for the depot." );
Console.WriteLine( "\t OR" );
Console.WriteLine( "\t-game #\t\t\t- the HLDSUpdateTool game server to download." );
Console.WriteLine( "\t-version [# or \"latest\"]\t- the version of the depot to download.\n" );
Console.WriteLine( "Optional Parameters:" );

Loading…
Cancel
Save