From 63574f993443c66c1136699f97f12ae667245db4 Mon Sep 17 00:00:00 2001 From: erri120 Date: Sat, 26 Oct 2019 21:43:06 +0200 Subject: [PATCH 01/10] Added Ceras NuGet Package --- VirtualFileSystem.Test/App.config | 9 +++++++++ VirtualFileSystem/VirtualFileSystem.csproj | 1 + VirtualFileSystem/app.config | 11 +++++++++++ Wabbajack.Common/Wabbajack.Common.csproj | 10 ++++++++++ Wabbajack.Common/app.config | 11 +++++++++++ Wabbajack.Common/packages.config | 3 +++ Wabbajack.Lib/Wabbajack.Lib.csproj | 6 ++++++ Wabbajack.Lib/app.config | 4 ++++ Wabbajack.Lib/packages.config | 2 ++ Wabbajack.Test/app.config | 4 ++++ Wabbajack.WebAutomation.Test/App.config | 4 ++++ Wabbajack.WebAutomation/app.config | 4 ++++ Wabbajack/App.config | 4 ++++ 13 files changed, 73 insertions(+) create mode 100644 VirtualFileSystem/app.config create mode 100644 Wabbajack.Common/app.config diff --git a/VirtualFileSystem.Test/App.config b/VirtualFileSystem.Test/App.config index d1d97acc..656cce25 100644 --- a/VirtualFileSystem.Test/App.config +++ b/VirtualFileSystem.Test/App.config @@ -4,4 +4,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/VirtualFileSystem/VirtualFileSystem.csproj b/VirtualFileSystem/VirtualFileSystem.csproj index 957155e6..4da1e448 100644 --- a/VirtualFileSystem/VirtualFileSystem.csproj +++ b/VirtualFileSystem/VirtualFileSystem.csproj @@ -88,6 +88,7 @@ + diff --git a/VirtualFileSystem/app.config b/VirtualFileSystem/app.config new file mode 100644 index 00000000..64d479d3 --- /dev/null +++ b/VirtualFileSystem/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Wabbajack.Common/Wabbajack.Common.csproj b/Wabbajack.Common/Wabbajack.Common.csproj index bb6957b4..09d7263b 100644 --- a/Wabbajack.Common/Wabbajack.Common.csproj +++ b/Wabbajack.Common/Wabbajack.Common.csproj @@ -53,6 +53,9 @@ ..\packages\AlphaFS.2.2.6\lib\net452\AlphaFS.dll + + ..\packages\Ceras.4.1.7\lib\net47\Ceras.dll + ..\packages\erri120.OMODFramework.1.0.0\lib\net472\erri120.OMODFramework.dll @@ -78,10 +81,16 @@ ..\packages\SevenZip.19.0.0\lib\net20\SevenZip.dll + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -109,6 +118,7 @@ + diff --git a/Wabbajack.Common/app.config b/Wabbajack.Common/app.config new file mode 100644 index 00000000..f6e7dca8 --- /dev/null +++ b/Wabbajack.Common/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Wabbajack.Common/packages.config b/Wabbajack.Common/packages.config index 0d61318f..6af70a58 100644 --- a/Wabbajack.Common/packages.config +++ b/Wabbajack.Common/packages.config @@ -1,6 +1,7 @@  + @@ -9,6 +10,8 @@ + + \ No newline at end of file diff --git a/Wabbajack.Lib/Wabbajack.Lib.csproj b/Wabbajack.Lib/Wabbajack.Lib.csproj index 611d5c6c..e2e1d780 100644 --- a/Wabbajack.Lib/Wabbajack.Lib.csproj +++ b/Wabbajack.Lib/Wabbajack.Lib.csproj @@ -34,6 +34,9 @@ ..\packages\AlphaFS.2.2.6\lib\net452\AlphaFS.dll + + ..\packages\Ceras.4.1.7\lib\net47\Ceras.dll + ..\packages\CommonMark.NET.0.15.1\lib\net45\CommonMark.dll @@ -70,6 +73,9 @@ ..\packages\Splat.Drawing.9.1.1\lib\net461\Splat.Drawing.dll + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + diff --git a/Wabbajack.Lib/app.config b/Wabbajack.Lib/app.config index e936cc13..f26196dc 100644 --- a/Wabbajack.Lib/app.config +++ b/Wabbajack.Lib/app.config @@ -6,6 +6,10 @@ + + + + \ No newline at end of file diff --git a/Wabbajack.Lib/packages.config b/Wabbajack.Lib/packages.config index 64aed6c8..9cbf5759 100644 --- a/Wabbajack.Lib/packages.config +++ b/Wabbajack.Lib/packages.config @@ -1,6 +1,7 @@  + @@ -12,6 +13,7 @@ + diff --git a/Wabbajack.Test/app.config b/Wabbajack.Test/app.config index ec5c75f5..6af99795 100644 --- a/Wabbajack.Test/app.config +++ b/Wabbajack.Test/app.config @@ -10,6 +10,10 @@ + + + + \ No newline at end of file diff --git a/Wabbajack.WebAutomation.Test/App.config b/Wabbajack.WebAutomation.Test/App.config index 1cd0cbc7..9e4120ad 100644 --- a/Wabbajack.WebAutomation.Test/App.config +++ b/Wabbajack.WebAutomation.Test/App.config @@ -9,6 +9,10 @@ + + + + \ No newline at end of file diff --git a/Wabbajack.WebAutomation/app.config b/Wabbajack.WebAutomation/app.config index d8d15744..f360fc98 100644 --- a/Wabbajack.WebAutomation/app.config +++ b/Wabbajack.WebAutomation/app.config @@ -6,6 +6,10 @@ + + + + \ No newline at end of file diff --git a/Wabbajack/App.config b/Wabbajack/App.config index 5905ef43..3200b122 100644 --- a/Wabbajack/App.config +++ b/Wabbajack/App.config @@ -14,6 +14,10 @@ + + + + From 56daeb069a4937deaf818cb69483737d6da1be96 Mon Sep 17 00:00:00 2001 From: erri120 Date: Sat, 26 Oct 2019 21:45:37 +0200 Subject: [PATCH 02/10] Created To/From CERAS functions --- Wabbajack.Common/Utils.cs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index c3127bd8..399aabf4 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -10,6 +10,7 @@ using System.Security.Cryptography; using System.Text; using System.Threading; using System.Threading.Tasks; +using Ceras; using ICSharpCode.SharpZipLib.BZip2; using IniParser; using Newtonsoft.Json; @@ -192,13 +193,21 @@ namespace Wabbajack.Common return new DynamicIniData(new FileIniDataParser().ReadData(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(file))))); } + public static void ToCERAS(this T obj, string filename) + { + var ceras = new CerasSerializer(); + byte[] buffer = null; + ceras.Serialize(obj, ref buffer); + File.WriteAllBytes(filename, buffer); + } + public static void ToJSON(this T obj, string filename) { File.WriteAllText(filename, JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.Auto})); } - + /* public static void ToBSON(this T obj, string filename) { using (var fo = File.OpenWrite(filename)) @@ -209,7 +218,7 @@ namespace Wabbajack.Common {TypeNameHandling = TypeNameHandling.Auto}); serializer.Serialize(br, obj); } - } + }*/ public static ulong ToMilliseconds(this DateTime date) { @@ -221,13 +230,13 @@ namespace Wabbajack.Common return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All}); } - + public static T FromJSON(this string filename) { return JsonConvert.DeserializeObject(File.ReadAllText(filename), new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.Auto}); } - + /* public static T FromBSON(this string filename, bool root_is_array = false) { using (var fo = File.OpenRead(filename)) @@ -237,7 +246,7 @@ namespace Wabbajack.Common {TypeNameHandling = TypeNameHandling.Auto}); return serializer.Deserialize(br); } - } + }*/ public static T FromJSONString(this string data) { @@ -252,6 +261,13 @@ namespace Wabbajack.Common new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); } + public static T FromCERAS(this Stream data) + { + var ceras = new CerasSerializer(); + byte[] bytes = data.ReadAll(); + return ceras.Deserialize(bytes); + } + public static bool FileExists(this string filename) { return File.Exists(filename); From d93fdf9b1fa562082d997e240a784c91d0382b7d Mon Sep 17 00:00:00 2001 From: erri120 Date: Sat, 26 Oct 2019 21:46:52 +0200 Subject: [PATCH 03/10] Building and loading modlist will now use new Ceras functions --- Wabbajack.Lib/Compiler.cs | 3 ++- Wabbajack.Lib/Installer.cs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Wabbajack.Lib/Compiler.cs b/Wabbajack.Lib/Compiler.cs index e517da27..e0de333f 100644 --- a/Wabbajack.Lib/Compiler.cs +++ b/Wabbajack.Lib/Compiler.cs @@ -304,7 +304,8 @@ namespace Wabbajack.Lib { Utils.Log($"Exporting Modlist to : {ModListOutputFile}"); - ModList.ToJSON(Path.Combine(ModListOutputFolder, "modlist.json")); + //ModList.ToJSON(Path.Combine(ModListOutputFolder, "modlist.json")); + ModList.ToCERAS(Path.Combine(ModListOutputFolder, "modlist")); if (File.Exists(ModListOutputFile)) File.Delete(ModListOutputFile); diff --git a/Wabbajack.Lib/Installer.cs b/Wabbajack.Lib/Installer.cs index 508bc218..f9fe1825 100644 --- a/Wabbajack.Lib/Installer.cs +++ b/Wabbajack.Lib/Installer.cs @@ -84,9 +84,10 @@ namespace Wabbajack.Lib using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var ar = new ZipArchive(fs, ZipArchiveMode.Read)) { - var entry = ar.GetEntry("modlist.json"); + var entry = ar.GetEntry("modlist"); using (var e = entry.Open()) - return e.FromJSON(); + //return e.FromJSON(); + return e.FromCERAS(); } } From 843228c09e60446a79187bf6732e0ea31ba68a51 Mon Sep 17 00:00:00 2001 From: erri120 Date: Sat, 26 Oct 2019 21:52:42 +0200 Subject: [PATCH 04/10] Using new Ceras options instead of JSON --- VirtualFileSystem/VirtualFileSystem.cs | 13 ++++----- Wabbajack.Lib/Data.cs | 29 +++++---------------- Wabbajack.Lib/Downloaders/HTTPDownloader.cs | 6 ++--- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/VirtualFileSystem/VirtualFileSystem.cs b/VirtualFileSystem/VirtualFileSystem.cs index 27ba5e64..07c685c1 100644 --- a/VirtualFileSystem/VirtualFileSystem.cs +++ b/VirtualFileSystem/VirtualFileSystem.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; +using Ceras; using Compression.BSA; using ICSharpCode.SharpZipLib.Zip; using Newtonsoft.Json; @@ -505,7 +506,7 @@ namespace VFS } } - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] + [MemberConfig(TargetMember.None)] public class VirtualFile { private string _fullPath; @@ -517,7 +518,7 @@ namespace VFS internal string _stagedPath; - [JsonProperty] + [Include] public string[] Paths { get => _paths; @@ -529,13 +530,13 @@ namespace VFS } } - [JsonProperty] public string Hash { get; set; } + [Include] public string Hash { get; set; } - [JsonProperty] public long Size { get; set; } + [Include] public long Size { get; set; } - [JsonProperty] public ulong LastModified { get; set; } + [Include] public ulong LastModified { get; set; } - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + [Include] public bool? FinishedIndexing { get; set; } diff --git a/Wabbajack.Lib/Data.cs b/Wabbajack.Lib/Data.cs index 4ee9e5d2..cd282f31 100644 --- a/Wabbajack.Lib/Data.cs +++ b/Wabbajack.Lib/Data.cs @@ -1,7 +1,6 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; -using System.Diagnostics; +using Ceras; using Compression.BSA; using VFS; using Wabbajack.Common; @@ -34,7 +33,6 @@ namespace Wabbajack.Lib } } - [Serializable] public class ModList { /// @@ -93,7 +91,6 @@ namespace Wabbajack.Lib public string ReportHTML; } - [Serializable] public class Directive { /// @@ -104,18 +101,15 @@ namespace Wabbajack.Lib public string Hash; } - [Serializable] public class IgnoredDirectly : Directive { public string Reason; } - [Serializable] public class NoMatch : IgnoredDirectly { } - [Serializable] public class InlineFile : Directive { /// @@ -129,13 +123,11 @@ namespace Wabbajack.Lib /// /// File meant to be extracted before the installation /// - [Serializable] public class PropertyFile : InlineFile { public PropertyType Type; } - [Serializable] public class CleanedESM : InlineFile { public string SourceESMHash; @@ -144,12 +136,11 @@ namespace Wabbajack.Lib /// /// A file that has the game and MO2 folders remapped on installation /// - [Serializable] public class RemappedInlineFile : InlineFile { } - [Serializable] + [MemberConfig(TargetMember.All)] public class FromArchive : Directive { private string _fullPath; @@ -159,9 +150,10 @@ namespace Wabbajack.Lib /// public string[] ArchiveHashPath; - [JsonIgnore] [NonSerialized] public VirtualFile FromFile; + [Exclude] + public VirtualFile FromFile; - [JsonIgnore] + [Exclude] public string FullPath { get @@ -172,7 +164,6 @@ namespace Wabbajack.Lib } } - [Serializable] public class CreateBSA : Directive { public string TempID; @@ -181,7 +172,6 @@ namespace Wabbajack.Lib public List FileStates { get; set; } } - [Serializable] public class PatchedFromArchive : FromArchive { /// @@ -190,21 +180,18 @@ namespace Wabbajack.Lib public string PatchID; } - [Serializable] public class SourcePatch { public string RelativePath; public string Hash; } - [Serializable] public class MergedPatch : Directive { public List Sources; public string PatchID; } - [Serializable] public class Archive { /// @@ -225,7 +212,6 @@ namespace Wabbajack.Lib public AbstractDownloadState State { get; set; } } - [Serializable] public class IndexedArchive { public dynamic IniData; @@ -237,7 +223,6 @@ namespace Wabbajack.Lib /// /// A archive entry /// - [Serializable] public class IndexedEntry { /// @@ -256,7 +241,6 @@ namespace Wabbajack.Lib public long Size; } - [Serializable] public class IndexedArchiveEntry : IndexedEntry { public string[] HashPath; @@ -265,7 +249,6 @@ namespace Wabbajack.Lib /// /// Data found inside a BSA file in an archive /// - [Serializable] public class BSAIndexedEntry : IndexedEntry { /// diff --git a/Wabbajack.Lib/Downloaders/HTTPDownloader.cs b/Wabbajack.Lib/Downloaders/HTTPDownloader.cs index 241a35ee..fc86fda3 100644 --- a/Wabbajack.Lib/Downloaders/HTTPDownloader.cs +++ b/Wabbajack.Lib/Downloaders/HTTPDownloader.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; -using Newtonsoft.Json; +using Ceras; using Wabbajack.Common; using Wabbajack.Lib.Validation; using File = Alphaleonis.Win32.Filesystem.File; @@ -48,14 +48,14 @@ namespace Wabbajack.Lib.Downloaders { } + [MemberConfig(TargetMember.All)] public class State : AbstractDownloadState { public string Url { get; set; } - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public List Headers { get; set; } - [JsonIgnore] + [Exclude] public HttpClient Client { get; set; } public override bool IsWhitelisted(ServerWhitelist whitelist) From f115a0c8f5c1480510c4bdad0cc89261ebab501a Mon Sep 17 00:00:00 2001 From: erri120 Date: Sat, 26 Oct 2019 21:53:30 +0200 Subject: [PATCH 05/10] Added Ceras to VFS project --- VirtualFileSystem.Test/App.config | 2 +- VirtualFileSystem/VirtualFileSystem.csproj | 9 +++++++++ VirtualFileSystem/app.config | 2 +- VirtualFileSystem/packages.config | 3 +++ Wabbajack.Test/app.config | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/VirtualFileSystem.Test/App.config b/VirtualFileSystem.Test/App.config index 656cce25..bd059d69 100644 --- a/VirtualFileSystem.Test/App.config +++ b/VirtualFileSystem.Test/App.config @@ -8,7 +8,7 @@ - + diff --git a/VirtualFileSystem/VirtualFileSystem.csproj b/VirtualFileSystem/VirtualFileSystem.csproj index 4da1e448..42627033 100644 --- a/VirtualFileSystem/VirtualFileSystem.csproj +++ b/VirtualFileSystem/VirtualFileSystem.csproj @@ -53,6 +53,9 @@ ..\packages\AlphaFS.2.2.6\lib\net452\AlphaFS.dll + + ..\packages\Ceras.4.1.7\lib\net47\Ceras.dll + ..\packages\SharpZipLib.1.2.0\lib\net45\ICSharpCode.SharpZipLib.dll @@ -60,11 +63,17 @@ ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + diff --git a/VirtualFileSystem/app.config b/VirtualFileSystem/app.config index 64d479d3..f6e7dca8 100644 --- a/VirtualFileSystem/app.config +++ b/VirtualFileSystem/app.config @@ -4,7 +4,7 @@ - + diff --git a/VirtualFileSystem/packages.config b/VirtualFileSystem/packages.config index a49a0ac7..1191c694 100644 --- a/VirtualFileSystem/packages.config +++ b/VirtualFileSystem/packages.config @@ -1,7 +1,10 @@  + + + \ No newline at end of file diff --git a/Wabbajack.Test/app.config b/Wabbajack.Test/app.config index 6af99795..3e3e46ab 100644 --- a/Wabbajack.Test/app.config +++ b/Wabbajack.Test/app.config @@ -12,7 +12,7 @@ - + From 6fd9d49c9e6763624eebab62ccf45c04550ca8ab Mon Sep 17 00:00:00 2001 From: erri120 Date: Sun, 27 Oct 2019 12:02:30 +0100 Subject: [PATCH 06/10] Added BZip2 Compression to modlist info file --- Wabbajack.Common/Utils.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index 399aabf4..47264da7 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -198,7 +198,13 @@ namespace Wabbajack.Common var ceras = new CerasSerializer(); byte[] buffer = null; ceras.Serialize(obj, ref buffer); - File.WriteAllBytes(filename, buffer); + using(var m1 = new MemoryStream(buffer)) + using (var m2 = new MemoryStream()) + { + BZip2.Compress(m1, m2, false, 9); + m2.Seek(0, SeekOrigin.Begin); + File.WriteAllBytes(filename, m2.ToArray()); + } } public static void ToJSON(this T obj, string filename) @@ -265,7 +271,13 @@ namespace Wabbajack.Common { var ceras = new CerasSerializer(); byte[] bytes = data.ReadAll(); - return ceras.Deserialize(bytes); + using (var m1 = new MemoryStream(bytes)) + using (var m2 = new MemoryStream()) + { + BZip2.Decompress(m1, m2, false); + m2.Seek(0, SeekOrigin.Begin); + return ceras.Deserialize(m2.ToArray()); + } } public static bool FileExists(this string filename) From 4c694eafc90394f71e5e2e83e80daef757d731f5 Mon Sep 17 00:00:00 2001 From: erri120 Date: Sun, 27 Oct 2019 13:11:10 +0100 Subject: [PATCH 07/10] Added Compression to Ceras serialization --- Wabbajack.Common/Utils.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index 47264da7..77057c72 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -193,9 +193,9 @@ namespace Wabbajack.Common return new DynamicIniData(new FileIniDataParser().ReadData(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(file))))); } - public static void ToCERAS(this T obj, string filename) + public static void ToCERAS(this T obj, string filename, ref SerializerConfig config) { - var ceras = new CerasSerializer(); + var ceras = new CerasSerializer(config); byte[] buffer = null; ceras.Serialize(obj, ref buffer); using(var m1 = new MemoryStream(buffer)) @@ -207,6 +207,19 @@ namespace Wabbajack.Common } } + public static T FromCERAS(this Stream data, ref SerializerConfig config) + { + var ceras = new CerasSerializer(config); + byte[] bytes = data.ReadAll(); + using (var m1 = new MemoryStream(bytes)) + using (var m2 = new MemoryStream()) + { + BZip2.Decompress(m1, m2, false); + m2.Seek(0, SeekOrigin.Begin); + return ceras.Deserialize(m2.ToArray()); + } + } + public static void ToJSON(this T obj, string filename) { File.WriteAllText(filename, @@ -267,19 +280,6 @@ namespace Wabbajack.Common new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); } - public static T FromCERAS(this Stream data) - { - var ceras = new CerasSerializer(); - byte[] bytes = data.ReadAll(); - using (var m1 = new MemoryStream(bytes)) - using (var m2 = new MemoryStream()) - { - BZip2.Decompress(m1, m2, false); - m2.Seek(0, SeekOrigin.Begin); - return ceras.Deserialize(m2.ToArray()); - } - } - public static bool FileExists(this string filename) { return File.Exists(filename); From df3d6b4179e2f73e88d0beb20ec26008dd5f0fa5 Mon Sep 17 00:00:00 2001 From: erri120 Date: Sun, 27 Oct 2019 13:12:35 +0100 Subject: [PATCH 08/10] Created CerasConfig with KnownTypes --- Wabbajack.Lib/CerasConfig.cs | 27 +++++++++++++++++++++++++++ Wabbajack.Lib/Compiler.cs | 2 +- Wabbajack.Lib/Installer.cs | 2 +- Wabbajack.Lib/Wabbajack.Lib.csproj | 1 + 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Wabbajack.Lib/CerasConfig.cs diff --git a/Wabbajack.Lib/CerasConfig.cs b/Wabbajack.Lib/CerasConfig.cs new file mode 100644 index 00000000..1c2d8b6d --- /dev/null +++ b/Wabbajack.Lib/CerasConfig.cs @@ -0,0 +1,27 @@ +using Ceras; +using Compression.BSA; +using VFS; +using Wabbajack.Common; +using Wabbajack.Lib.Downloaders; + +namespace Wabbajack.Lib +{ + public class CerasConfig + { + public static SerializerConfig Config = new SerializerConfig() + { + KnownTypes = + { + typeof(ModList), typeof(Game), typeof(Directive), typeof(IgnoredDirectly), + typeof(NoMatch), typeof(InlineFile), typeof(PropertyType), typeof(CleanedESM), + typeof(RemappedInlineFile), typeof(FromArchive), typeof(CreateBSA), typeof(PatchedFromArchive), + typeof(SourcePatch), typeof(MergedPatch), typeof(Archive), typeof(IndexedArchive), typeof(IndexedEntry), + typeof(IndexedArchiveEntry), typeof(BSAIndexedEntry), typeof(VirtualFile), + typeof(ArchiveStateObject), typeof(FileStateObject), typeof(IDownloader), + typeof(IUrlDownloader), typeof(AbstractDownloadState), typeof(ManualDownloader), + typeof(DropboxDownloader), typeof(GoogleDriveDownloader), typeof(HTTPDownloader), + typeof(MegaDownloader), typeof(ModDBDownloader), typeof(NexusDownloader) + } + }; + } +} diff --git a/Wabbajack.Lib/Compiler.cs b/Wabbajack.Lib/Compiler.cs index e0de333f..98aeced9 100644 --- a/Wabbajack.Lib/Compiler.cs +++ b/Wabbajack.Lib/Compiler.cs @@ -305,7 +305,7 @@ namespace Wabbajack.Lib Utils.Log($"Exporting Modlist to : {ModListOutputFile}"); //ModList.ToJSON(Path.Combine(ModListOutputFolder, "modlist.json")); - ModList.ToCERAS(Path.Combine(ModListOutputFolder, "modlist")); + ModList.ToCERAS(Path.Combine(ModListOutputFolder, "modlist"), ref CerasConfig.Config); if (File.Exists(ModListOutputFile)) File.Delete(ModListOutputFile); diff --git a/Wabbajack.Lib/Installer.cs b/Wabbajack.Lib/Installer.cs index f9fe1825..f91bb699 100644 --- a/Wabbajack.Lib/Installer.cs +++ b/Wabbajack.Lib/Installer.cs @@ -87,7 +87,7 @@ namespace Wabbajack.Lib var entry = ar.GetEntry("modlist"); using (var e = entry.Open()) //return e.FromJSON(); - return e.FromCERAS(); + return e.FromCERAS(ref CerasConfig.Config); } } diff --git a/Wabbajack.Lib/Wabbajack.Lib.csproj b/Wabbajack.Lib/Wabbajack.Lib.csproj index e2e1d780..8f1e52bc 100644 --- a/Wabbajack.Lib/Wabbajack.Lib.csproj +++ b/Wabbajack.Lib/Wabbajack.Lib.csproj @@ -118,6 +118,7 @@ + From 5128884b74b5357739314ba8844dfd48b29296dd Mon Sep 17 00:00:00 2001 From: erri120 Date: Sun, 27 Oct 2019 14:48:51 +0100 Subject: [PATCH 09/10] Changed KnownTypes --- Wabbajack.Lib/CerasConfig.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Wabbajack.Lib/CerasConfig.cs b/Wabbajack.Lib/CerasConfig.cs index 1c2d8b6d..f71ad003 100644 --- a/Wabbajack.Lib/CerasConfig.cs +++ b/Wabbajack.Lib/CerasConfig.cs @@ -18,9 +18,9 @@ namespace Wabbajack.Lib typeof(SourcePatch), typeof(MergedPatch), typeof(Archive), typeof(IndexedArchive), typeof(IndexedEntry), typeof(IndexedArchiveEntry), typeof(BSAIndexedEntry), typeof(VirtualFile), typeof(ArchiveStateObject), typeof(FileStateObject), typeof(IDownloader), - typeof(IUrlDownloader), typeof(AbstractDownloadState), typeof(ManualDownloader), - typeof(DropboxDownloader), typeof(GoogleDriveDownloader), typeof(HTTPDownloader), - typeof(MegaDownloader), typeof(ModDBDownloader), typeof(NexusDownloader) + typeof(IUrlDownloader), typeof(AbstractDownloadState), typeof(ManualDownloader.State), + typeof(DropboxDownloader), typeof(GoogleDriveDownloader.State), typeof(HTTPDownloader.State), + typeof(MegaDownloader.State), typeof(ModDBDownloader.State), typeof(NexusDownloader.State) } }; } From 81ccec31443a4eab5a3e399b53fc484be8163343 Mon Sep 17 00:00:00 2001 From: erri120 Date: Sun, 27 Oct 2019 14:59:23 +0100 Subject: [PATCH 10/10] Added backwards compatibility for modlist.json --- Wabbajack.Lib/Installer.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Wabbajack.Lib/Installer.cs b/Wabbajack.Lib/Installer.cs index f91bb699..5582aad9 100644 --- a/Wabbajack.Lib/Installer.cs +++ b/Wabbajack.Lib/Installer.cs @@ -85,8 +85,13 @@ namespace Wabbajack.Lib using (var ar = new ZipArchive(fs, ZipArchiveMode.Read)) { var entry = ar.GetEntry("modlist"); + if (entry == null) + { + entry = ar.GetEntry("modlist.json"); + using (var e = entry.Open()) + return e.FromJSON(); + } using (var e = entry.Open()) - //return e.FromJSON(); return e.FromCERAS(ref CerasConfig.Config); } }