mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
fix the BSA encoder, add support for hand built patches
This commit is contained in:
parent
bfca62432c
commit
a6d90ccc3f
353
.gitignore
vendored
353
.gitignore
vendored
@ -12,3 +12,356 @@
|
|||||||
/Wabbajack/obj/Debug
|
/Wabbajack/obj/Debug
|
||||||
/Wabbajack.Common/bin/Debug
|
/Wabbajack.Common/bin/Debug
|
||||||
/Wabbajack.Common/obj/Debug
|
/Wabbajack.Common/obj/Debug
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
@ -9,11 +9,11 @@ namespace Compression.BSA.Test
|
|||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
const string TestDir = "c:\\Mod Organizer 2\\mods";
|
const string TestDir = "d:\\Personal YASHEd\\mods";
|
||||||
const string TempDir = "c:\\tmp\\out";
|
const string TempDir = "c:\\tmp\\out";
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
foreach (var bsa in Directory.EnumerateFiles(TestDir, "*.bsa", SearchOption.AllDirectories))
|
foreach (var bsa in Directory.EnumerateFiles(TestDir, "*.bsa", SearchOption.AllDirectories).Skip(3))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"From {bsa}");
|
Console.WriteLine($"From {bsa}");
|
||||||
Console.WriteLine("Cleaning Output Dir");
|
Console.WriteLine("Cleaning Output Dir");
|
||||||
@ -84,7 +84,7 @@ namespace Compression.BSA.Test
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using K4os.Compression.LZ4;
|
using lz4;
|
||||||
using K4os.Compression.LZ4.Streams;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -11,7 +10,6 @@ namespace Compression.BSA
|
|||||||
{
|
{
|
||||||
public class BSABuilder : IDisposable
|
public class BSABuilder : IDisposable
|
||||||
{
|
{
|
||||||
internal LZ4Level _compressionLevel;
|
|
||||||
internal byte[] _fileId;
|
internal byte[] _fileId;
|
||||||
internal uint _version;
|
internal uint _version;
|
||||||
internal uint _offset;
|
internal uint _offset;
|
||||||
@ -27,7 +25,6 @@ namespace Compression.BSA
|
|||||||
|
|
||||||
public BSABuilder()
|
public BSABuilder()
|
||||||
{
|
{
|
||||||
_compressionLevel = LZ4Level.L10_OPT;
|
|
||||||
_fileId = Encoding.ASCII.GetBytes("BSA\0");
|
_fileId = Encoding.ASCII.GetBytes("BSA\0");
|
||||||
_offset = 0x24;
|
_offset = 0x24;
|
||||||
}
|
}
|
||||||
@ -299,6 +296,7 @@ namespace Compression.BSA
|
|||||||
internal ulong _hash;
|
internal ulong _hash;
|
||||||
internal byte[] _nameBytes;
|
internal byte[] _nameBytes;
|
||||||
internal byte[] _pathBytes;
|
internal byte[] _pathBytes;
|
||||||
|
private byte[] _pathBSBytes;
|
||||||
internal byte[] _rawData;
|
internal byte[] _rawData;
|
||||||
internal int _originalSize;
|
internal int _originalSize;
|
||||||
private long _offsetOffset;
|
private long _offsetOffset;
|
||||||
@ -311,6 +309,7 @@ namespace Compression.BSA
|
|||||||
_hash = _name.GetBSAHash();
|
_hash = _name.GetBSAHash();
|
||||||
_nameBytes = _name.ToTermString();
|
_nameBytes = _name.ToTermString();
|
||||||
_pathBytes = _path.ToTermString();
|
_pathBytes = _path.ToTermString();
|
||||||
|
_pathBSBytes = _path.ToBSString();
|
||||||
_flipCompression = flipCompression;
|
_flipCompression = flipCompression;
|
||||||
|
|
||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
@ -328,8 +327,13 @@ namespace Compression.BSA
|
|||||||
if (_bsa.HeaderType == VersionType.SSE)
|
if (_bsa.HeaderType == VersionType.SSE)
|
||||||
{
|
{
|
||||||
var r = new MemoryStream();
|
var r = new MemoryStream();
|
||||||
using (var w = LZ4Stream.Encode(r, new LZ4EncoderSettings() { CompressionLevel = _bsa._compressionLevel }))
|
|
||||||
(new MemoryStream(_rawData)).CopyTo(w);
|
using (var f = LZ4Stream.CreateCompressor(r, LZ4StreamMode.Write, LZ4FrameBlockMode.Independent, LZ4FrameBlockSize.Max4MB, LZ4FrameChecksumMode.Content,
|
||||||
|
highCompression: true, leaveInnerStreamOpen: true))
|
||||||
|
{
|
||||||
|
|
||||||
|
new MemoryStream(_rawData).CopyTo(f);
|
||||||
|
}
|
||||||
|
|
||||||
_rawData = r.ToArray();
|
_rawData = r.ToArray();
|
||||||
|
|
||||||
@ -385,10 +389,19 @@ namespace Compression.BSA
|
|||||||
|
|
||||||
{
|
{
|
||||||
wtr.Write(_hash);
|
wtr.Write(_hash);
|
||||||
|
var size = _rawData.Length;
|
||||||
|
if (_bsa.HasNameBlobs)
|
||||||
|
{
|
||||||
|
size += _pathBSBytes.Length;
|
||||||
|
}
|
||||||
|
if (Compressed)
|
||||||
|
{
|
||||||
|
size += 4;
|
||||||
|
}
|
||||||
if (_flipCompression)
|
if (_flipCompression)
|
||||||
wtr.Write((uint)_rawData.Length | (0x1 << 30));
|
wtr.Write((uint)size | (0x1 << 30));
|
||||||
else
|
else
|
||||||
wtr.Write((uint)_rawData.Length);
|
wtr.Write((uint)size);
|
||||||
|
|
||||||
_offsetOffset = wtr.BaseStream.Position;
|
_offsetOffset = wtr.BaseStream.Position;
|
||||||
wtr.Write((uint)0xDEADBEEF);
|
wtr.Write((uint)0xDEADBEEF);
|
||||||
@ -405,7 +418,7 @@ namespace Compression.BSA
|
|||||||
{
|
{
|
||||||
if (_bsa.HasNameBlobs)
|
if (_bsa.HasNameBlobs)
|
||||||
{
|
{
|
||||||
wtr.Write(_path.ToBSString());
|
wtr.Write(_pathBSBytes);
|
||||||
}
|
}
|
||||||
wtr.Write((uint)_originalSize);
|
wtr.Write((uint)_originalSize);
|
||||||
wtr.Write(_rawData);
|
wtr.Write(_rawData);
|
||||||
@ -414,7 +427,7 @@ namespace Compression.BSA
|
|||||||
{
|
{
|
||||||
if (_bsa.HasNameBlobs)
|
if (_bsa.HasNameBlobs)
|
||||||
{
|
{
|
||||||
wtr.Write(_path.ToBSString());
|
wtr.Write(_pathBSBytes);
|
||||||
}
|
}
|
||||||
wtr.Write(_rawData);
|
wtr.Write(_rawData);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using K4os.Compression.LZ4.Streams;
|
using lz4;
|
||||||
|
|
||||||
namespace Compression.BSA
|
namespace Compression.BSA
|
||||||
{
|
{
|
||||||
@ -359,10 +359,13 @@ namespace Compression.BSA
|
|||||||
}
|
}
|
||||||
|
|
||||||
var original_size = rdr.ReadUInt32();
|
var original_size = rdr.ReadUInt32();
|
||||||
|
file_size -= 4;
|
||||||
if (_bsa.HeaderType == VersionType.SSE)
|
if (_bsa.HeaderType == VersionType.SSE)
|
||||||
{
|
{
|
||||||
var r = LZ4Stream.Decode(rdr.BaseStream);
|
using (var dc = LZ4Stream.CreateDecompressor(output, LZ4StreamMode.Write, true))
|
||||||
r.CopyTo(output);
|
{
|
||||||
|
rdr.BaseStream.CopyToLimit(dc, file_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -50,30 +50,12 @@
|
|||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="K4os.Compression.LZ4, Version=1.1.11.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
<Reference Include="lz4.AnyCPU.loader, Version=1.0.12.0, Culture=neutral, PublicKeyToken=7aa3c636ef56b77f, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\K4os.Compression.LZ4.1.1.11\lib\net46\K4os.Compression.LZ4.dll</HintPath>
|
<HintPath>..\packages\IonKiwi.lz4.net.1.0.12\lib\net472\lz4.AnyCPU.loader.dll</HintPath>
|
||||||
</Reference>
|
|
||||||
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.1.11.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.1.11\lib\net46\K4os.Compression.LZ4.Streams.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="K4os.Hash.xxHash, Version=1.0.6.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\K4os.Hash.xxHash.1.0.6\lib\net46\K4os.Hash.xxHash.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Numerics" />
|
<Reference Include="System.Numerics" />
|
||||||
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using lz4.AnyCPU.loader;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -8,6 +9,12 @@ namespace Compression.BSA
|
|||||||
internal static class Utils
|
internal static class Utils
|
||||||
{
|
{
|
||||||
private static Encoding Windows1251 = Encoding.GetEncoding(1251);
|
private static Encoding Windows1251 = Encoding.GetEncoding(1251);
|
||||||
|
|
||||||
|
static Utils ()
|
||||||
|
{
|
||||||
|
LZ4Loader.DisableVCRuntimeDetection = true;
|
||||||
|
}
|
||||||
|
|
||||||
public static string ReadStringLen(this BinaryReader rdr)
|
public static string ReadStringLen(this BinaryReader rdr)
|
||||||
{
|
{
|
||||||
var len = rdr.ReadByte();
|
var len = rdr.ReadByte();
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="IonKiwi.lz4.net" version="1.0.12" targetFramework="net472" />
|
<package id="IonKiwi.lz4.net" version="1.0.12" targetFramework="net472" />
|
||||||
<package id="K4os.Compression.LZ4" version="1.1.11" targetFramework="net472" />
|
|
||||||
<package id="K4os.Compression.LZ4.Streams" version="1.1.11" targetFramework="net472" />
|
|
||||||
<package id="K4os.Hash.xxHash" version="1.0.6" targetFramework="net472" />
|
|
||||||
<package id="System.Buffers" version="4.4.0" targetFramework="net472" />
|
|
||||||
<package id="System.Memory" version="4.5.3" targetFramework="net472" />
|
|
||||||
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" />
|
|
||||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
|
|
||||||
</packages>
|
</packages>
|
@ -27,6 +27,8 @@ namespace Wabbajack.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string WABBAJACK_INCLUDE = "WABBAJACK_INCLUDE";
|
||||||
|
|
||||||
public static String AppName = "Wabbajack";
|
public static String AppName = "Wabbajack";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Wabbajack.Common
|
namespace Wabbajack.Common
|
||||||
{
|
{
|
||||||
@ -46,6 +47,10 @@ namespace Wabbajack.Common
|
|||||||
public override bool TryGetMember(GetMemberBinder binder, out object result)
|
public override bool TryGetMember(GetMemberBinder binder, out object result)
|
||||||
{
|
{
|
||||||
result = _coll[binder.Name];
|
result = _coll[binder.Name];
|
||||||
|
if (result is string)
|
||||||
|
{
|
||||||
|
result = Regex.Unescape(((string)result).Trim('"'));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,8 @@ namespace Wabbajack.Common
|
|||||||
public static List<TR> PMap<TI, TR>(this IEnumerable<TI> coll, Func<TI, TR> f)
|
public static List<TR> PMap<TI, TR>(this IEnumerable<TI> coll, Func<TI, TR> f)
|
||||||
{
|
{
|
||||||
var colllst = coll.ToList();
|
var colllst = coll.ToList();
|
||||||
WorkQueue.MaxQueueSize = colllst.Count;
|
Interlocked.Add(ref WorkQueue.MaxQueueSize, colllst.Count);
|
||||||
WorkQueue.CurrentQueueSize = 0;
|
//WorkQueue.CurrentQueueSize = 0;
|
||||||
|
|
||||||
int remaining_tasks = colllst.Count;
|
int remaining_tasks = colllst.Count;
|
||||||
|
|
||||||
@ -201,6 +201,12 @@ namespace Wabbajack.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (WorkQueue.CurrentQueueSize == WorkQueue.MaxQueueSize)
|
||||||
|
{
|
||||||
|
WorkQueue.MaxQueueSize = 0;
|
||||||
|
WorkQueue.MaxQueueSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return tasks.Select(t =>
|
return tasks.Select(t =>
|
||||||
{
|
{
|
||||||
t.Wait();
|
t.Wait();
|
||||||
|
@ -57,6 +57,7 @@ namespace Wabbajack
|
|||||||
public List<RawSourceFile> AllFiles { get; private set; }
|
public List<RawSourceFile> AllFiles { get; private set; }
|
||||||
public ModList ModList { get; private set; }
|
public ModList ModList { get; private set; }
|
||||||
public ConcurrentBag<Directive> ExtraFiles { get; private set; }
|
public ConcurrentBag<Directive> ExtraFiles { get; private set; }
|
||||||
|
public Dictionary<string, dynamic> ModInis { get; private set; }
|
||||||
|
|
||||||
public List<IndexedArchive> IndexedArchives;
|
public List<IndexedArchive> IndexedArchives;
|
||||||
|
|
||||||
@ -252,6 +253,18 @@ namespace Wabbajack
|
|||||||
|
|
||||||
ExtraFiles = new ConcurrentBag<Directive>();
|
ExtraFiles = new ConcurrentBag<Directive>();
|
||||||
|
|
||||||
|
ModInis = Directory.EnumerateDirectories(Path.Combine(MO2Folder, "mods"))
|
||||||
|
.Select(f =>
|
||||||
|
{
|
||||||
|
var mod_name = Path.GetFileName(f);
|
||||||
|
var meta_path = Path.Combine(f, "meta.ini");
|
||||||
|
if (File.Exists(meta_path))
|
||||||
|
return (mod_name, meta_path.LoadIniFile());
|
||||||
|
return (null, null);
|
||||||
|
})
|
||||||
|
.Where(f => f.Item2 != null)
|
||||||
|
.ToDictionary(f => f.Item1, f => f.Item2);
|
||||||
|
|
||||||
var stack = MakeStack();
|
var stack = MakeStack();
|
||||||
|
|
||||||
Info("Running Compilation Stack");
|
Info("Running Compilation Stack");
|
||||||
@ -373,6 +386,7 @@ namespace Wabbajack
|
|||||||
var b = LoadDataForTo(entry.To, absolute_paths);
|
var b = LoadDataForTo(entry.To, absolute_paths);
|
||||||
BSDiff.Create(a, b, output);
|
BSDiff.Create(a, b, output);
|
||||||
entry.Patch = output.ToArray().ToBase64();
|
entry.Patch = output.ToArray().ToBase64();
|
||||||
|
Info($"Patch size {entry.Patch.Length} for {entry.To}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -435,7 +449,7 @@ namespace Wabbajack
|
|||||||
Status($"Getting Nexus info for {found.Name}");
|
Status($"Getting Nexus info for {found.Name}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var link = NexusAPI.GetNexusDownloadLink((NexusMod)result, NexusKey);
|
// var link = NexusAPI.GetNexusDownloadLink((NexusMod)result, NexusKey);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -560,6 +574,7 @@ namespace Wabbajack
|
|||||||
IgnoreRegex(Consts.GameFolderFilesDir + "\\\\.*\\.bsa"),
|
IgnoreRegex(Consts.GameFolderFilesDir + "\\\\.*\\.bsa"),
|
||||||
IncludeModIniData(),
|
IncludeModIniData(),
|
||||||
DirectMatch(),
|
DirectMatch(),
|
||||||
|
IncludeTaggedFiles(),
|
||||||
IncludePatches(),
|
IncludePatches(),
|
||||||
IncludeDummyESPs(),
|
IncludeDummyESPs(),
|
||||||
|
|
||||||
@ -582,6 +597,43 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If a user includes WABBAJACK_INCLUDE directly in the notes or comments of a mod, the contents of that
|
||||||
|
/// mod will be inlined into the installer. USE WISELY.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private Func<RawSourceFile, Directive> IncludeTaggedFiles()
|
||||||
|
{
|
||||||
|
var include_directly = ModInis.Where(kv => {
|
||||||
|
var general = kv.Value.General;
|
||||||
|
if (general.notes != null && general.notes.Contains(Consts.WABBAJACK_INCLUDE))
|
||||||
|
return true;
|
||||||
|
if (general.comments != null && general.comments.Contains(Consts.WABBAJACK_INCLUDE))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}).Select(kv => $"mods\\{kv.Key}\\");
|
||||||
|
|
||||||
|
|
||||||
|
return source =>
|
||||||
|
{
|
||||||
|
|
||||||
|
if (source.Path.StartsWith("mods"))
|
||||||
|
{
|
||||||
|
foreach (var modpath in include_directly)
|
||||||
|
{
|
||||||
|
if (source.Path.StartsWith(modpath))
|
||||||
|
{
|
||||||
|
var result = source.EvolveTo<InlineFile>();
|
||||||
|
result.SourceData = File.ReadAllBytes(source.AbsolutePath).ToBase64();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Some tools like the Cathedral Asset Optimizer will create dummy ESPs whos only existance is to make
|
/// Some tools like the Cathedral Asset Optimizer will create dummy ESPs whos only existance is to make
|
||||||
/// sure a BSA with the same name is loaded. We don't have a good way to detect these, but if an ESP is
|
/// sure a BSA with the same name is loaded. We don't have a good way to detect these, but if an ESP is
|
||||||
@ -682,13 +734,13 @@ namespace Wabbajack
|
|||||||
var results = new List<(string, string)>();
|
var results = new List<(string, string)>();
|
||||||
using (var a = new BSAReader(absolutePath))
|
using (var a = new BSAReader(absolutePath))
|
||||||
{
|
{
|
||||||
foreach (var entry in a.Files)
|
a.Files.PMap(entry =>
|
||||||
{
|
{
|
||||||
Status($"Hashing BSA: {absolutePath} - {entry.Path}");
|
Status($"Hashing BSA: {absolutePath} - {entry.Path}");
|
||||||
|
|
||||||
var data = entry.GetData();
|
var data = entry.GetData();
|
||||||
results.Add((entry.Path, data.SHA256()));
|
results.Add((entry.Path, data.SHA256()));
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -863,17 +915,7 @@ namespace Wabbajack
|
|||||||
.GroupBy(e => e.entry.Hash)
|
.GroupBy(e => e.entry.Hash)
|
||||||
.ToDictionary(e => e.Key);
|
.ToDictionary(e => e.Key);
|
||||||
|
|
||||||
var mod_inis = Directory.EnumerateDirectories(Path.Combine(MO2Folder, "mods"))
|
|
||||||
.Select(f =>
|
|
||||||
{
|
|
||||||
var mod_name = Path.GetFileName(f);
|
|
||||||
var meta_path = Path.Combine(f, "meta.ini");
|
|
||||||
if (File.Exists(meta_path))
|
|
||||||
return (mod_name, meta_path.LoadIniFile());
|
|
||||||
return (null, null);
|
|
||||||
})
|
|
||||||
.Where(f => f.Item2 != null)
|
|
||||||
.ToDictionary(f => f.Item1, f => f.Item2);
|
|
||||||
|
|
||||||
return source =>
|
return source =>
|
||||||
{
|
{
|
||||||
|
@ -131,6 +131,9 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Info($"Removing temp folder {Consts.BSACreationDir}");
|
||||||
|
Directory.Delete(Path.Combine(Outputfolder, Consts.BSACreationDir), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InstallIncludedFiles()
|
private void InstallIncludedFiles()
|
||||||
@ -266,6 +269,7 @@ namespace Wabbajack
|
|||||||
if (output_path.FileExists())
|
if (output_path.FileExists())
|
||||||
File.Delete(output_path);
|
File.Delete(output_path);
|
||||||
|
|
||||||
|
|
||||||
switch (archive) {
|
switch (archive) {
|
||||||
case NexusMod a:
|
case NexusMod a:
|
||||||
Info($"Downloading Nexus Archive - {archive.Name} - {a.GameName} - {a.ModID} - {a.FileID}");
|
Info($"Downloading Nexus Archive - {archive.Name} - {a.GameName} - {a.ModID} - {a.FileID}");
|
||||||
|
Loading…
Reference in New Issue
Block a user