Several fixes for BSA compiling

This commit is contained in:
Timothy Baldridge 2020-04-15 05:53:49 -06:00
parent 65cac27403
commit 723f687dbd
5 changed files with 20 additions and 5 deletions

View File

@ -280,7 +280,7 @@ namespace Compression.BSA
case VersionType.SSE: case VersionType.SSE:
{ {
var r = new MemoryStream(); var r = new MemoryStream();
using (var w = LZ4Stream.Encode(r, new LZ4EncoderSettings {CompressionLevel = LZ4Level.L10_OPT}, true)) using (var w = LZ4Stream.Encode(r, new LZ4EncoderSettings {CompressionLevel = LZ4Level.L12_MAX}, true))
{ {
_srcData.CopyTo(w); _srcData.CopyTo(w);
} }

View File

@ -314,7 +314,18 @@ namespace Wabbajack.Common
if (!_typeToName.ContainsKey(serializedType)) if (!_typeToName.ContainsKey(serializedType))
{ {
throw new InvalidDataException($"No Binding name for {serializedType}"); var custom = serializedType.GetCustomAttributes(false)
.OfType<JsonNameAttribute>().FirstOrDefault();
if (custom == null)
{
throw new InvalidDataException($"No Binding name for {serializedType}");
}
_nameToType[custom.Name] = serializedType;
_typeToName[serializedType] = custom.Name;
assemblyName = null;
typeName = custom.Name;
return;
} }
var name = _typeToName[serializedType]; var name = _typeToName[serializedType];

View File

@ -30,8 +30,12 @@ namespace Wabbajack.Common
{ {
lock (this) lock (this)
{ {
// This can happen at times due to differences in compression sizes
if (_head + size >= _size) if (_head + size >= _size)
throw new InvalidDataException($"Size out of range. Declared {_size} used {_head + size}"); {
return new MemoryStream();
}
var startAt = _head; var startAt = _head;
_head += size; _head += size;
var stream = _mmap.CreateViewStream(startAt, size, MemoryMappedFileAccess.ReadWrite); var stream = _mmap.CreateViewStream(startAt, size, MemoryMappedFileAccess.ReadWrite);

View File

@ -66,7 +66,7 @@ namespace Wabbajack.Lib.CompilationSteps
var id = Guid.NewGuid().ToString(); var id = Guid.NewGuid().ToString();
var matches = await sourceFiles.PMap(_mo2Compiler.Queue, e => _mo2Compiler.RunStack(stack, new RawSourceFile(e, Consts.BSACreationDir.Combine((RelativePath)id, e.Name.FileName)))); var matches = await sourceFiles.PMap(_mo2Compiler.Queue, e => _mo2Compiler.RunStack(stack, new RawSourceFile(e, Consts.BSACreationDir.Combine((RelativePath)id, (RelativePath)e.Name))));
foreach (var match in matches) foreach (var match in matches)

View File

@ -17,7 +17,7 @@ namespace Wabbajack.Lib.CompilationSteps
source.AbsolutePath.Extension != Consts.ESM) return null; source.AbsolutePath.Extension != Consts.ESM) return null;
var bsa = source.AbsolutePath.ReplaceExtension(Consts.BSA); var bsa = source.AbsolutePath.ReplaceExtension(Consts.BSA);
var bsaTextures = source.AbsolutePath.AppendToName(" - Textures"); var bsaTextures = source.AbsolutePath.AppendToName(" - Textures").ReplaceExtension(Consts.BSA);
if (source.AbsolutePath.Size > 250 || !bsa.IsFile && !bsaTextures.IsFile) return null; if (source.AbsolutePath.Size > 250 || !bsa.IsFile && !bsaTextures.IsFile) return null;