Blob Refactor

--HG--
extra : rebase_source : 98e0b6385cc654ff137fa216c4b403be5d36fa26
pull/8/head
Ryan Kistner 13 years ago
parent 5602f4f79e
commit 80f0dcf56c

@ -1,79 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using SteamKit2;
using System.Net;
using System.Security.Cryptography;
using SteamKit2;
using SteamKit2.Blob;
namespace DepotDownloader
{
class CDR
{
[BlobField( FieldKey = CDRFields.eFieldApplicationsRecord, Depth = 1, Complex = true )]
public List<App> Apps { get; set; }
[BlobField(1)]
public List<App> Apps;
[BlobField( FieldKey = CDRFields.eFieldSubscriptionsRecord, Depth = 1, Complex = true )]
public List<Sub> Subs { get; set; }
[BlobField(2)]
public List<Sub> Subs;
}
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.eFieldVersionsRecord, Complex = true, Depth = 1 )]
public List<AppVersion> Versions { get; private set; }
[BlobField( FieldKey = CDRAppRecordFields.eFieldFilesystemsRecord, Complex = true, Depth = 1 )]
public List<FileSystem> FileSystems { get; private set; }
[BlobField( FieldKey = CDRAppRecordFields.eFieldUserDefinedRecord, Depth = 1 )]
public Dictionary<string, string> UserDefined { get; private set; }
[BlobField( FieldKey = CDRAppRecordFields.eFieldBetaVersionId, Depth = 1 )]
public int BetaVersion { get; set; }
[BlobField(2)]
public string Name;
[BlobField(1)]
public int AppID;
[BlobField(11)]
public int CurrentVersion;
[BlobField(10)]
public List<AppVersion> Versions;
[BlobField(12)]
public List<FileSystem> FileSystems;
[BlobField(14)]
public Dictionary<string, string> UserDefined;
[BlobField(16)]
public int BetaVersion;
}
class Sub
{
[BlobField( FieldKey = CDRSubRecordFields.eFieldSubId, Depth = 1 )]
public int SubID { get; set; }
[BlobField( FieldKey = CDRSubRecordFields.eFieldAppIdsRecord, Depth = 1 )]
public List<int> AppIDs { get; private set; }
[BlobField(1)]
public int SubID;
[BlobField(6)]
public List<int> AppIDs;
}
class AppVersion
{
[BlobField( FieldKey = CDRAppVersionFields.eFieldVersionId )]
public uint VersionID { get; set; }
[BlobField(2)]
public uint VersionID;
[BlobField( FieldKey = CDRAppVersionFields.eFieldDepotEncryptionKey )]
public string DepotEncryptionKey { get; set; }
[BlobField(5)]
public string DepotEncryptionKey;
[BlobField( FieldKey = CDRAppVersionFields.eFieldIsEncryptionKeyAvailable )]
public bool IsEncryptionKeyAvailable { get; set; }
[BlobField(6)]
public bool IsEncryptionKeyAvailable;
}
class FileSystem
{
[BlobField( FieldKey = CDRAppFilesystemFields.eFieldAppId )]
public int AppID { get; set; }
[BlobField(1)]
public int AppID;
[BlobField( FieldKey = CDRAppFilesystemFields.eFieldMountName )]
public string Name { get; set; }
[BlobField(2)]
public string Name;
[BlobField( FieldKey = CDRAppFilesystemFields.eFieldPlatform )]
public string Platform { get; set; }
[BlobField(4)]
public string Platform;
}
static class CDRManager
@ -82,7 +79,6 @@ namespace DepotDownloader
static CDR cdrObj;
public static void Update()
{
Console.Write( "Updating CDR..." );
@ -122,12 +118,9 @@ namespace DepotDownloader
return;
}
using ( var reader = BlobTypedReader<CDR>.Create( new MemoryStream( cdr ) ) )
using(BlobReader reader = BlobReader.CreateFrom(new MemoryStream(cdr)))
{
reader.Process();
cdrObj = reader.Target;
cdrObj = (CDR)BlobTypedReader.Deserialize(reader, typeof(CDR));
}
Console.WriteLine( " Done!" );
@ -135,12 +128,12 @@ namespace DepotDownloader
static App GetAppBlob( int appID )
{
return cdrObj.Apps.Find( ( app ) => app.AppID == appID );
return cdrObj.Apps.Find( app => app.AppID == appID );
}
static Sub GetSubBlob( int subID )
{
return cdrObj.Subs.Find( ( sub ) => sub.SubID == subID );
return cdrObj.Subs.Find( sub => sub.SubID == subID );
}
public static string GetDepotName( int depotId )
@ -232,7 +225,7 @@ namespace DepotDownloader
platformStr = "windows";
else if ( Util.IsMacOSX() )
platformStr = "macos";
foreach ( var blobField in appInfoBlob.FileSystems )
{
string depotPlatform = blobField.Platform;
@ -288,6 +281,7 @@ namespace DepotDownloader
}
}
}
}
// For HL1 server installs, this is hardcoded in hldsupdatetool

@ -1,15 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using SteamKit2;
using System.Net;
using System.IO;
using System.IO.Compression;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using SteamKit2;
namespace DepotDownloader
{

@ -43,6 +43,7 @@
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>x86</PlatformTarget>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -52,7 +53,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Classless.Hasher, Version=0.9.4179.24334, Culture=neutral, PublicKeyToken=25b6bb7f72693b18, processorArchitecture=MSIL">

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace DepotDownloader

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SteamKit2;
using System.IO;
using System.Text.RegularExpressions;
using SteamKit2.Blob;
using SteamKit2;
namespace DepotDownloader
{
@ -24,17 +21,7 @@ namespace DepotDownloader
ServerCache.Build();
CDRManager.Update();
if ( HasParameter( args, "-dumpcdr-xml" ) )
{
BlobXmlReader bxr;
using ( bxr = BlobXmlReader.Create( "cdr.blob", "cdrdump.xml" ) )
{
bxr.Process();
}
return;
}
return;
if (HasParameter( args, "-list" ) )
{

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using SteamKit2;

@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SteamKit2;
using System.Threading;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using SteamKit2;
namespace DepotDownloader
{

@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using Classless.Hasher;
namespace DepotDownloader

Loading…
Cancel
Save