mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
And priority to how game files are resolved
This commit is contained in:
parent
6c74279bfd
commit
0b74c04c86
@ -3,7 +3,7 @@
|
|||||||
#### Version - 2.1.0.0 - ???
|
#### Version - 2.1.0.0 - ???
|
||||||
* Game files are available as downloads automatically during compilation/installation
|
* Game files are available as downloads automatically during compilation/installation
|
||||||
* Game files are patched/copied/used in BSA creation automatically
|
* Game files are patched/copied/used in BSA creation automatically
|
||||||
* CleanedESM support removed from the compiler stack (still usable during installation for backwards compatability)
|
* CleanedESM support removed from the compiler stack (still usable during installation for backwards compatibility)
|
||||||
* VR games automatically pull from base games if they are required and are installed during compilation
|
* VR games automatically pull from base games if they are required and are installed during compilation
|
||||||
|
|
||||||
#### Version - 2.0.9.4 - 6/16/2020
|
#### Version - 2.0.9.4 - 6/16/2020
|
||||||
|
@ -47,6 +47,8 @@ namespace Wabbajack.Lib
|
|||||||
public ModList ModList = new ModList();
|
public ModList ModList = new ModList();
|
||||||
|
|
||||||
public List<IndexedArchive> IndexedArchives = new List<IndexedArchive>();
|
public List<IndexedArchive> IndexedArchives = new List<IndexedArchive>();
|
||||||
|
public Dictionary<AbsolutePath, IndexedArchive> ArchivesByFullPath { get; set; } = new Dictionary<AbsolutePath, IndexedArchive>();
|
||||||
|
|
||||||
public Dictionary<Hash, IEnumerable<VirtualFile>> IndexedFiles = new Dictionary<Hash, IEnumerable<VirtualFile>>();
|
public Dictionary<Hash, IEnumerable<VirtualFile>> IndexedFiles = new Dictionary<Hash, IEnumerable<VirtualFile>>();
|
||||||
|
|
||||||
public ACompiler(int steps)
|
public ACompiler(int steps)
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Alphaleonis.Win32.Filesystem;
|
using Alphaleonis.Win32.Filesystem;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Wabbajack.Lib.Downloaders;
|
||||||
|
using Wabbajack.VirtualFileSystem;
|
||||||
|
|
||||||
namespace Wabbajack.Lib.CompilationSteps
|
namespace Wabbajack.Lib.CompilationSteps
|
||||||
{
|
{
|
||||||
@ -11,13 +13,27 @@ namespace Wabbajack.Lib.CompilationSteps
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int GetFilePriority(MO2Compiler compiler, VirtualFile file)
|
||||||
|
{
|
||||||
|
var archive = file.TopParent;
|
||||||
|
var adata = compiler.ArchivesByFullPath[archive.AbsoluteName];
|
||||||
|
if (adata.State is GameFileSourceDownloader.State gs)
|
||||||
|
{
|
||||||
|
return gs.Game == compiler.CompilingGame.Game ? 1 : 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||||
{
|
{
|
||||||
|
var mo2Compiler = (MO2Compiler)_compiler;
|
||||||
if (!_compiler.IndexedFiles.TryGetValue(source.Hash, out var found)) return null;
|
if (!_compiler.IndexedFiles.TryGetValue(source.Hash, out var found)) return null;
|
||||||
var result = source.EvolveTo<FromArchive>();
|
var result = source.EvolveTo<FromArchive>();
|
||||||
|
|
||||||
var match = found.Where(f => f.Name.FileName == source.Path.FileName)
|
var match = found.Where(f => f.Name.FileName == source.Path.FileName)
|
||||||
.OrderBy(f => f.NestingFactor)
|
.OrderBy(f => GetFilePriority(mo2Compiler, f))
|
||||||
|
.ThenBy(f => f.NestingFactor)
|
||||||
.FirstOrDefault()
|
.FirstOrDefault()
|
||||||
?? found.OrderBy(f => f.NestingFactor).FirstOrDefault();
|
?? found.OrderBy(f => f.NestingFactor).FirstOrDefault();
|
||||||
|
|
||||||
|
@ -80,7 +80,8 @@ namespace Wabbajack.Lib.CompilationSteps
|
|||||||
{
|
{
|
||||||
// Just match some file in the archive based on the smallest delta difference
|
// Just match some file in the archive based on the smallest delta difference
|
||||||
found = arch.SelectMany(a => a.ThisAndAllChildren)
|
found = arch.SelectMany(a => a.ThisAndAllChildren)
|
||||||
.OrderBy(o => Math.Abs(o.Size - source.File.Size))
|
.OrderBy(o => DirectMatch.GetFilePriority(_mo2Compiler, o))
|
||||||
|
.ThenBy(o => Math.Abs(o.Size - source.File.Size))
|
||||||
.First();
|
.First();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,6 +290,7 @@ namespace Wabbajack.Lib
|
|||||||
public string Meta = string.Empty;
|
public string Meta = string.Empty;
|
||||||
public string Name = string.Empty;
|
public string Name = string.Empty;
|
||||||
public VirtualFile File { get; }
|
public VirtualFile File { get; }
|
||||||
|
public AbstractDownloadState? State { get; set; }
|
||||||
|
|
||||||
public IndexedArchive(VirtualFile file)
|
public IndexedArchive(VirtualFile file)
|
||||||
{
|
{
|
||||||
|
@ -221,7 +221,9 @@ namespace Wabbajack.Lib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await CleanInvalidArchives();
|
IndexedArchives = IndexedArchives.DistinctBy(a => a.File.AbsoluteName).ToList();
|
||||||
|
|
||||||
|
await CleanInvalidArchivesAndFillState();
|
||||||
|
|
||||||
UpdateTracker.NextStep("Finding Install Files");
|
UpdateTracker.NextStep("Finding Install Files");
|
||||||
ModListOutputFolder.CreateDirectory();
|
ModListOutputFolder.CreateDirectory();
|
||||||
@ -293,6 +295,8 @@ namespace Wabbajack.Lib
|
|||||||
.Where(f => f.Item1 != default)
|
.Where(f => f.Item1 != default)
|
||||||
.Select(f => new KeyValuePair<AbsolutePath, dynamic>(f.Item1, f.Item2)));
|
.Select(f => new KeyValuePair<AbsolutePath, dynamic>(f.Item1, f.Item2)));
|
||||||
|
|
||||||
|
ArchivesByFullPath = IndexedArchives.ToDictionary(a => a.File.AbsoluteName);
|
||||||
|
|
||||||
if (cancel.IsCancellationRequested) return false;
|
if (cancel.IsCancellationRequested) return false;
|
||||||
var stack = MakeStack();
|
var stack = MakeStack();
|
||||||
UpdateTracker.NextStep("Running Compilation Stack");
|
UpdateTracker.NextStep("Running Compilation Stack");
|
||||||
@ -359,15 +363,16 @@ namespace Wabbajack.Lib
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool UseGamePaths { get; set; } = true;
|
public bool UseGamePaths { get; set; } = true;
|
||||||
|
|
||||||
private async Task CleanInvalidArchives()
|
private async Task CleanInvalidArchivesAndFillState()
|
||||||
{
|
{
|
||||||
var remove = (await IndexedArchives.PMap(Queue, async a =>
|
var remove = (await IndexedArchives.PMap(Queue, async a =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await ResolveArchive(a);
|
a.State = (await ResolveArchive(a)).State;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -125,6 +125,9 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public VirtualFile TopParent => IsNative ? this : Parent.TopParent;
|
||||||
|
|
||||||
|
|
||||||
public T ThisAndAllChildrenReduced<T>(T acc, Func<T, VirtualFile, T> fn)
|
public T ThisAndAllChildrenReduced<T>(T acc, Func<T, VirtualFile, T> fn)
|
||||||
{
|
{
|
||||||
acc = fn(acc, this);
|
acc = fn(acc, this);
|
||||||
|
Loading…
Reference in New Issue
Block a user