Merge pull request #11 from halgari/issue-10

issue-10 add handling for dummy ESPs
This commit is contained in:
Timothy Baldridge 2019-08-10 10:04:27 -06:00 committed by GitHub
commit bfca62432c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -561,6 +561,7 @@ namespace Wabbajack
IncludeModIniData(), IncludeModIniData(),
DirectMatch(), DirectMatch(),
IncludePatches(), IncludePatches(),
IncludeDummyESPs(),
DeconstructBSAs(), DeconstructBSAs(),
@ -581,6 +582,35 @@ namespace Wabbajack
} }
/// <summary>
/// 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
/// less than 100 bytes in size and shares a name with a BSA it's a pretty good chance that it's a dummy
/// and the contents are generated.
/// </summary>
/// <returns></returns>
private Func<RawSourceFile, Directive> IncludeDummyESPs()
{
return source =>
{
if (Path.GetExtension(source.AbsolutePath) == ".esp")
{
var bsa = Path.Combine(Path.GetDirectoryName(source.AbsolutePath), Path.GetFileNameWithoutExtension(source.AbsolutePath) + ".bsa");
var bsa_textures = Path.Combine(Path.GetDirectoryName(source.AbsolutePath), Path.GetFileNameWithoutExtension(source.AbsolutePath) + " - Textures.bsa");
var esp_size = new FileInfo(source.AbsolutePath).Length;
if (esp_size <= 100 && (File.Exists(bsa) || File.Exists(bsa_textures)))
{
var inline = source.EvolveTo<InlineFile>();
inline.SourceData = File.ReadAllBytes(source.AbsolutePath).ToBase64();
return inline;
}
}
return null;
};
}
/// <summary> /// <summary>
/// This function will search for a way to create a BSA in the installed mod list by assembling it from files /// This function will search for a way to create a BSA in the installed mod list by assembling it from files
/// found in archives. To do this we hash all the files in side the BSA then try to find matches and patches for /// found in archives. To do this we hash all the files in side the BSA then try to find matches and patches for