mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Create .metas automatically for source-from-game files.
This commit is contained in:
parent
ed41308f12
commit
f6e9d672d2
@ -677,4 +677,4 @@ namespace Wabbajack.Common
|
||||
return a < b ? b < c ? b : a < c ? c : a : b > c ? b : a > c ? c : a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -665,6 +665,7 @@ namespace Wabbajack.Common
|
||||
|
||||
using (var f = File.OpenWrite(tmpName))
|
||||
{
|
||||
Status("Creating Patch");
|
||||
BSDiff.Create(a, b, f);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace Wabbajack.Lib
|
||||
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(LoversLabDownloader.State), typeof(GameFileSourceDownloader.State)
|
||||
|
||||
}
|
||||
};
|
||||
|
@ -17,10 +17,13 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
var gameName = (string)archiveINI?.General?.gameName;
|
||||
var gameFile = (string)archiveINI?.General?.gameFile;
|
||||
var game = GameRegistry.GetByMO2ArchiveName(gameName);
|
||||
if (gameFile == null || gameFile == null || game == null)
|
||||
|
||||
if (gameFile == null || gameFile == null)
|
||||
return null;
|
||||
|
||||
var game = GameRegistry.GetByMO2ArchiveName(gameName);
|
||||
if (game == null) return null;
|
||||
|
||||
var path = game.GameLocation();
|
||||
var filePath = Path.Combine(path, gameFile);
|
||||
|
||||
@ -66,7 +69,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
public override bool Verify()
|
||||
{
|
||||
return File.Exists(SourcePath) && SourcePath.FileHash() == Hash;
|
||||
return File.Exists(SourcePath) && SourcePath.FileHashCached() == Hash;
|
||||
}
|
||||
|
||||
public override IDownloader GetDownloader()
|
||||
|
@ -5,12 +5,15 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.CompilationSteps;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;
|
||||
using Game = Wabbajack.Common.Game;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
@ -29,6 +32,8 @@ namespace Wabbajack.Lib
|
||||
|
||||
public override string GamePath { get; }
|
||||
|
||||
public GameMetaData CompilingGame { get; set; }
|
||||
|
||||
public override string ModListOutputFolder => "output_folder";
|
||||
|
||||
public override string ModListOutputFile { get; }
|
||||
@ -38,6 +43,8 @@ namespace Wabbajack.Lib
|
||||
MO2Folder = mo2Folder;
|
||||
MO2Profile = mo2Profile;
|
||||
MO2Ini = Path.Combine(MO2Folder, "ModOrganizer.ini").LoadIniFile();
|
||||
var mo2game = (string)MO2Ini.General.gameName;
|
||||
CompilingGame = GameRegistry.Games.First(g => g.Value.MO2Name == mo2game).Value;
|
||||
GamePath = ((string)MO2Ini.General.gamePath).Replace("\\\\", "\\");
|
||||
ModListOutputFile = outputFile;
|
||||
}
|
||||
@ -72,7 +79,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
protected override bool _Begin()
|
||||
{
|
||||
ConfigureProcessor(16);
|
||||
ConfigureProcessor(18);
|
||||
UpdateTracker.Reset();
|
||||
UpdateTracker.NextStep("Gathering information");
|
||||
Info("Looking for other profiles");
|
||||
@ -116,6 +123,13 @@ namespace Wabbajack.Lib
|
||||
if (Directory.Exists(ModListOutputFolder))
|
||||
Utils.DeleteDirectory(ModListOutputFolder);
|
||||
|
||||
UpdateTracker.NextStep("Inferring metas for game file downloads");
|
||||
InferMetas();
|
||||
|
||||
UpdateTracker.NextStep("Reindexing downloads after meta inferring");
|
||||
VFS.AddRoot(MO2DownloadsFolder);
|
||||
VFS.WriteToFile(_vfsCacheName);
|
||||
|
||||
UpdateTracker.NextStep("Finding Install Files");
|
||||
Directory.CreateDirectory(ModListOutputFolder);
|
||||
|
||||
@ -244,7 +258,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
ModList = new ModList
|
||||
{
|
||||
GameType = GameRegistry.Games.Values.First(f => f.MO2Name == MO2Ini.General.gameName).Game,
|
||||
GameType = CompilingGame.Game,
|
||||
WabbajackVersion = WabbajackVersion,
|
||||
Archives = SelectedArchives.ToList(),
|
||||
ModManager = ModManager.MO2,
|
||||
@ -275,6 +289,41 @@ namespace Wabbajack.Lib
|
||||
|
||||
return true;
|
||||
}
|
||||
private void InferMetas()
|
||||
{
|
||||
var to_find = Directory.EnumerateFiles(MO2DownloadsFolder)
|
||||
.Where(f => !f.EndsWith(".meta") && !f.EndsWith(Consts.HashFileExtension))
|
||||
.Where(f => !File.Exists(f + ".meta"))
|
||||
.ToList();
|
||||
|
||||
if (to_find.Count == 0) return;
|
||||
|
||||
var games = new[]{CompilingGame}.Concat(GameRegistry.Games.Values.Where(g => g != CompilingGame));
|
||||
var game_files = games
|
||||
.Where(g => g.GameLocation() != null)
|
||||
.SelectMany(game => Directory.EnumerateFiles(game.GameLocation(), "*", DirectoryEnumerationOptions.Recursive).Select(name => (game, name)))
|
||||
.GroupBy(f => (Path.GetFileName(f.name), new FileInfo(f.name).Length))
|
||||
.ToDictionary(f => f.Key);
|
||||
|
||||
to_find.PMap(Queue, f =>
|
||||
{
|
||||
var vf = VFS.Index.ByFullPath[f];
|
||||
if (!game_files.TryGetValue((Path.GetFileName(f), vf.Size), out var found))
|
||||
return;
|
||||
|
||||
var (game, name) = found.FirstOrDefault(ff => ff.name.FileHash() == vf.Hash);
|
||||
if (name == null)
|
||||
return;
|
||||
|
||||
File.WriteAllLines(f+".meta", new[]
|
||||
{
|
||||
"[General]",
|
||||
$"gameName={game.MO2ArchiveName}",
|
||||
$"gameFile={name.RelativeTo(game.GameLocation()).Replace("\\", "/")}"
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void IncludeArchiveMetadata()
|
||||
|
Loading…
Reference in New Issue
Block a user