Blob Refactor

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

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

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

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

@ -1,11 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using SteamKit2;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using SteamKit2.Blob; using SteamKit2;
namespace DepotDownloader namespace DepotDownloader
{ {
@ -24,17 +21,7 @@ namespace DepotDownloader
ServerCache.Build(); ServerCache.Build();
CDRManager.Update(); 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" ) ) if (HasParameter( args, "-list" ) )
{ {

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

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

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

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

Loading…
Cancel
Save