mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
finish ba2 integration
This commit is contained in:
parent
29943aab87
commit
31b764204f
@ -35,7 +35,7 @@ namespace Wabbajack.Common
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Consts.SupportedBSAs.Any(b => source.EndsWith(b)))
|
||||
if (Consts.SupportedBSAs.Any(b => source.ToLower().EndsWith(b)))
|
||||
ExtractAllWithBSA(source, dest);
|
||||
else if (source.EndsWith(".exe"))
|
||||
ExtractAllWithInno(source, dest);
|
||||
@ -216,6 +216,7 @@ namespace Wabbajack.Common
|
||||
/// <returns></returns>
|
||||
public static bool CanExtract(string v)
|
||||
{
|
||||
v = v.ToLower();
|
||||
return Consts.SupportedArchives.Contains(v) || Consts.SupportedBSAs.Contains(v);
|
||||
}
|
||||
|
||||
|
@ -407,6 +407,7 @@ namespace Wabbajack
|
||||
group.PMap(entry =>
|
||||
{
|
||||
Info($"Patching {entry.To}");
|
||||
Status($"Patching {entry.To}");
|
||||
using (var origin = by_path[string.Join("|", entry.ArchiveHashPath.Skip(1))].OpenRead())
|
||||
using (var output = new MemoryStream())
|
||||
{
|
||||
@ -431,10 +432,15 @@ namespace Wabbajack
|
||||
var bsa_id = to.Split('\\')[1];
|
||||
var bsa = InstallDirectives.OfType<CreateBSA>().First(b => b.TempID == bsa_id);
|
||||
|
||||
using (var a = new BSAReader(Path.Combine(MO2Folder, bsa.To)))
|
||||
using (var a = BSADispatch.OpenRead(Path.Combine(MO2Folder, bsa.To)))
|
||||
{
|
||||
var file = a.Files.First(e => e.Path == Path.Combine(to.Split('\\').Skip(2).ToArray()));
|
||||
return file.GetData();
|
||||
var find = Path.Combine(to.Split('\\').Skip(2).ToArray());
|
||||
var file = a.Files.First(e => e.Path.Replace('/', '\\') == find);
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
file.CopyDataTo(ms);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -927,7 +933,7 @@ namespace Wabbajack
|
||||
|
||||
return source =>
|
||||
{
|
||||
if (!Consts.SupportedBSAs.Contains(Path.GetExtension(source.Path))) return null;
|
||||
if (!Consts.SupportedBSAs.Contains(Path.GetExtension(source.Path).ToLower())) return null;
|
||||
|
||||
var default_include = false;
|
||||
if (source.Path.StartsWith("mods"))
|
||||
@ -959,20 +965,17 @@ namespace Wabbajack
|
||||
;
|
||||
|
||||
CreateBSA directive;
|
||||
using (var bsa = new BSAReader(source.AbsolutePath))
|
||||
using (var bsa = BSADispatch.OpenRead(source.AbsolutePath))
|
||||
{
|
||||
directive = new CreateBSA
|
||||
{
|
||||
To = source.Path,
|
||||
TempID = id,
|
||||
Type = (uint)bsa.HeaderType,
|
||||
FileFlags = (uint)bsa.FileFlags,
|
||||
ArchiveFlags = (uint)bsa.ArchiveFlags
|
||||
State = bsa.State,
|
||||
FileStates = bsa.Files.Select(f => f.State).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
return directive;
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Compression.BSA;
|
||||
using VFS;
|
||||
using Wabbajack.Common;
|
||||
|
||||
@ -167,15 +168,10 @@ namespace Wabbajack
|
||||
[Serializable]
|
||||
public class CreateBSA : Directive
|
||||
{
|
||||
public string IsCompressed;
|
||||
public bool ShareData;
|
||||
public string TempID;
|
||||
public uint Type;
|
||||
public uint Version;
|
||||
|
||||
public uint FileFlags { get; set; }
|
||||
public bool Compress { get; set; }
|
||||
public uint ArchiveFlags { get; set; }
|
||||
public ArchiveStateObject State { get; set; }
|
||||
public List<FileStateObject> FileStates { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
@ -242,30 +242,21 @@ namespace Wabbajack
|
||||
{
|
||||
Status($"Building {bsa.To}");
|
||||
var source_dir = Path.Combine(Outputfolder, Consts.BSACreationDir, bsa.TempID);
|
||||
var source_files = Directory.EnumerateFiles(source_dir, "*", SearchOption.AllDirectories)
|
||||
.Select(e => e.Substring(source_dir.Length + 1))
|
||||
.ToList();
|
||||
|
||||
if (source_files.Count > 0)
|
||||
using (var a = new BSABuilder())
|
||||
using (var a = bsa.State.MakeBuilder())
|
||||
{
|
||||
bsa.FileStates.PMap(state =>
|
||||
{
|
||||
//a.Create(Path.Combine(Outputfolder, bsa.To), (bsa_archive_type_t)bsa.Type, entries);
|
||||
a.HeaderType = (VersionType)bsa.Type;
|
||||
a.FileFlags = (FileFlags)bsa.FileFlags;
|
||||
a.ArchiveFlags = (ArchiveFlags)bsa.ArchiveFlags;
|
||||
|
||||
source_files.PMap(f =>
|
||||
Status($"Adding {state.Path} to BSA");
|
||||
using (var fs = File.OpenRead(Path.Combine(source_dir, state.Path)))
|
||||
{
|
||||
Status($"Adding {f} to BSA");
|
||||
using (var fs = File.OpenRead(Path.Combine(source_dir, f)))
|
||||
{
|
||||
a.AddFile(f, fs);
|
||||
}
|
||||
});
|
||||
a.AddFile(state, fs);
|
||||
}
|
||||
});
|
||||
|
||||
Info($"Writing {bsa.To}");
|
||||
a.Build(Path.Combine(Outputfolder, bsa.To));
|
||||
}
|
||||
Info($"Writing {bsa.To}");
|
||||
a.Build(Path.Combine(Outputfolder, bsa.To));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace Wabbajack
|
||||
if (file != null)
|
||||
{
|
||||
ShutdownOnClose = false;
|
||||
new MainWindow(RunMode.Compile, file).Start().Show();
|
||||
new MainWindow(RunMode.Compile, file).Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ namespace Wabbajack
|
||||
if (file != null)
|
||||
{
|
||||
ShutdownOnClose = false;
|
||||
new MainWindow(RunMode.Install, file).Start().Show();
|
||||
new MainWindow(RunMode.Install, file).Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ namespace Wabbajack.Validation
|
||||
if (nexus_mod_permissions.TryGetValue(p.ArchiveHashPath[0], out var archive))
|
||||
{
|
||||
if (!(archive.permissions.CanExtractBSAs ?? true) &&
|
||||
p.ArchiveHashPath.Skip(1).ButLast().Any(a => Consts.SupportedBSAs.Contains(Path.GetExtension(a))))
|
||||
p.ArchiveHashPath.Skip(1).ButLast().Any(a => Consts.SupportedBSAs.Contains(Path.GetExtension(a).ToLower())))
|
||||
{
|
||||
ValidationErrors.Push($"{p.To} from {archive.archive.NexusURL} is set to disallow BSA Extraction");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user