diff --git a/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj b/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj
index 4cd2ed6..890019c 100644
--- a/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj
+++ b/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj
@@ -2,9 +2,9 @@
net6.0;net7.0
- 0.80.30
- 0.80.30
- 0.80.30
+ 0.80.65
+ 0.80.65
+ 0.80.65
Copyright © Perfare 2020-2022; Copyright © hozuki 2020
embedded
diff --git a/AssetStudio/AssetStudio.csproj b/AssetStudio/AssetStudio.csproj
index fd85873..1717872 100644
--- a/AssetStudio/AssetStudio.csproj
+++ b/AssetStudio/AssetStudio.csproj
@@ -2,9 +2,9 @@
net6.0;net7.0
- 0.80.30
- 0.80.30
- 0.80.30
+ 0.80.65
+ 0.80.65
+ 0.80.65
Copyright © Razmoth 2022; Copyright © Perfare 2018-2022
embedded
diff --git a/AssetStudio/AssetsHelper.cs b/AssetStudio/AssetsHelper.cs
index 5e09f93..62a330c 100644
--- a/AssetStudio/AssetsHelper.cs
+++ b/AssetStudio/AssetsHelper.cs
@@ -19,7 +19,7 @@ namespace AssetStudio
public static CancellationTokenSource tokenSource = new CancellationTokenSource();
private static string BaseFolder = "";
- private static Dictionary Map = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ private static Dictionary CABMap = new Dictionary(StringComparer.OrdinalIgnoreCase);
private static Dictionary> Offsets = new Dictionary>();
private static AssetsManager assetsManager = new AssetsManager() { Silent = true, SkipProcess = true, ResolveDependencies = false };
@@ -39,7 +39,7 @@ namespace AssetStudio
public static void Clear()
{
- Map.Clear();
+ CABMap.Clear();
Offsets.Clear();
BaseFolder = string.Empty;
@@ -56,7 +56,7 @@ namespace AssetStudio
public static bool TryAdd(string name, out string path)
{
- if (Map.TryGetValue(name, out var entry))
+ if (CABMap.TryGetValue(name, out var entry))
{
path = Path.Combine(BaseFolder, entry.Path);
if (!Offsets.ContainsKey(path))
@@ -81,269 +81,326 @@ namespace AssetStudio
return false;
}
- public static void BuildMap(string[] files, string mapName, string baseFolder, Game game)
+ public static void BuildCABMap(string[] files, string mapName, string baseFolder, Game game)
{
- Logger.Info($"Building Map...");
+ Logger.Info("Building CABMap...");
try
{
- Map.Clear();
+ CABMap.Clear();
Progress.Reset();
var collision = 0;
BaseFolder = baseFolder;
assetsManager.Game = game;
- for (int i = 0; i < files.Length; i++)
+ foreach (var file in LoadFiles(files))
{
- var file = files[i];
- assetsManager.LoadFiles(file);
- if (assetsManager.assetsFileList.Count > 0)
- {
- var relativePath = Path.GetRelativePath(BaseFolder, file);
- foreach (var assetsFile in assetsManager.assetsFileList)
- {
- if (tokenSource.IsCancellationRequested)
- {
- Logger.Info("Building Map has been aborted !!");
- return;
- }
- var dependencies = assetsFile.m_Externals.Select(x => x.fileName).ToArray();
- var entry = new Entry()
- {
- Path = relativePath,
- Offset = assetsFile.offset,
- Dependencies = dependencies
- };
-
- if (Map.ContainsKey(assetsFile.fileName))
- {
- collision++;
- continue;
- }
- Map.Add(assetsFile.fileName, entry);
- }
- Logger.Info($"[{i + 1}/{files.Length}] Processed {Path.GetFileName(file)}");
- Progress.Report(i + 1, files.Length);
- }
- assetsManager.Clear();
+ BuildCABMap(file, ref collision);
}
- Map = Map.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value, StringComparer.OrdinalIgnoreCase);
- var outputFile = Path.Combine(MapName, $"{mapName}.bin");
+ DumpCABMap(mapName);
- Directory.CreateDirectory(Path.GetDirectoryName(outputFile));
-
- using (var binaryFile = File.OpenWrite(outputFile))
- using (var writer = new BinaryWriter(binaryFile))
- {
- writer.Write(BaseFolder);
- writer.Write(Map.Count);
- foreach (var kv in Map)
- {
- writer.Write(kv.Key);
- writer.Write(kv.Value.Path);
- writer.Write(kv.Value.Offset);
- writer.Write(kv.Value.Dependencies.Length);
- foreach (var cab in kv.Value.Dependencies)
- {
- writer.Write(cab);
- }
- }
- }
-
- Logger.Info($"Map build successfully !! {collision} collisions found");
+ Logger.Info($"CABMap build successfully !! {collision} collisions found");
}
catch (Exception e)
{
- Logger.Warning($"Map was not build, {e}");
+ Logger.Warning($"CABMap was not build, {e}");
}
}
- public static void BuildBoth(string[] files, string mapName, string baseFolder, Game game, string savePath, ExportListType exportListType, ManualResetEvent resetEvent = null, Regex[] nameFilters = null, Regex[] containerFilters = null)
+ private static IEnumerable LoadFiles(string[] files)
{
- Logger.Info($"Building Both...");
- Map.Clear();
- Progress.Reset();
- var collision = 0;
- BaseFolder = baseFolder;
- assetsManager.Game = game;
- var assets = new List();
for (int i = 0; i < files.Length; i++)
{
var file = files[i];
assetsManager.LoadFiles(file);
if (assetsManager.assetsFileList.Count > 0)
{
- var relativePath = Path.GetRelativePath(BaseFolder, file);
- var containers = new List<(PPtr