Ceras version tolerance enabled

This commit is contained in:
Justin Swanson 2019-12-20 14:01:01 -06:00
parent f26747bfe5
commit af6b42563d
5 changed files with 33 additions and 28 deletions

View File

@ -310,7 +310,7 @@ namespace Wabbajack.Common
return new DynamicIniData(new FileIniDataParser().ReadData(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(file)))));
}
public static void ToCERAS<T>(this T obj, string filename, ref SerializerConfig config)
public static void ToCERAS<T>(this T obj, string filename, SerializerConfig config)
{
var ceras = new CerasSerializer(config);
byte[] buffer = null;
@ -324,7 +324,7 @@ namespace Wabbajack.Common
}
}
public static T FromCERAS<T>(this Stream data, ref SerializerConfig config)
public static T FromCERAS<T>(this Stream data, SerializerConfig config)
{
var ceras = new CerasSerializer(config);
byte[] bytes = data.ReadAll();

View File

@ -98,7 +98,7 @@ namespace Wabbajack.Lib
ModList.ReadmeIsWebsite = ReadmeIsWebsite;
//ModList.ToJSON(Path.Combine(ModListOutputFolder, "modlist.json"));
ModList.ToCERAS(Path.Combine(ModListOutputFolder, "modlist"), ref CerasConfig.Config);
ModList.ToCERAS(Path.Combine(ModListOutputFolder, "modlist"), CerasConfig.Config);
if (File.Exists(ModListOutputFile))
File.Delete(ModListOutputFile);

View File

@ -78,7 +78,7 @@ namespace Wabbajack.Lib
return e.FromJSON<ModList>();
}
using (var e = entry.Open())
return e.FromCERAS<ModList>(ref CerasConfig.Config);
return e.FromCERAS<ModList>(CerasConfig.Config);
}
}

View File

@ -8,25 +8,31 @@ 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.State),
typeof(DropboxDownloader), typeof(GoogleDriveDownloader.State), typeof(HTTPDownloader.State),
typeof(MegaDownloader.State), typeof(ModDBDownloader.State), typeof(NexusDownloader.State),
typeof(BSAStateObject), typeof(BSAFileStateObject), typeof(BA2StateObject), typeof(BA2DX10EntryState),
typeof(BA2FileEntryState), typeof(MediaFireDownloader.State), typeof(ArchiveMeta),
typeof(PropertyFile), typeof(SteamMeta), typeof(SteamWorkshopDownloader), typeof(SteamWorkshopDownloader.State),
typeof(LoversLabDownloader.State), typeof(GameFileSourceDownloader.State)
public static readonly SerializerConfig Config;
}
};
static CerasConfig()
{
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.State),
typeof(DropboxDownloader), typeof(GoogleDriveDownloader.State), typeof(HTTPDownloader.State),
typeof(MegaDownloader.State), typeof(ModDBDownloader.State), typeof(NexusDownloader.State),
typeof(BSAStateObject), typeof(BSAFileStateObject), typeof(BA2StateObject), typeof(BA2DX10EntryState),
typeof(BA2FileEntryState), typeof(MediaFireDownloader.State), typeof(ArchiveMeta),
typeof(PropertyFile), typeof(SteamMeta), typeof(SteamWorkshopDownloader), typeof(SteamWorkshopDownloader.State),
typeof(LoversLabDownloader.State), typeof(GameFileSourceDownloader.State)
},
};
Config.VersionTolerance.Mode = VersionToleranceMode.Standard;
}
}
}

View File

@ -91,11 +91,6 @@ namespace Wabbajack.Lib
/// </summary>
public string Readme;
/// <summary>
/// Whether readme is a website
/// </summary>
public bool ReadmeIsWebsite;
/// <summary>
/// Content Report in HTML form
/// </summary>
@ -118,6 +113,10 @@ namespace Wabbajack.Lib
.Take(Environment.ProcessorCount)
.Sum(a => a.Size) * 2;
/// <summary>
/// Whether readme is a website
/// </summary>
public bool ReadmeIsWebsite;
}
public class Directive