移除ESC-ARC带lzw压缩的打包功能

*没研究明白*游戏针对data script是强制lzw
This commit is contained in:
Chenx221 2024-10-26 22:46:12 +08:00
parent b0f19dbace
commit 608bbb36d6
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
3 changed files with 26 additions and 19 deletions

View File

@ -170,6 +170,7 @@ namespace EscudeTools
if (!Directory.Exists(output))
Directory.CreateDirectory(output);
var lzwManifest = new List<LzwEntry>();
string jsonPath = Path.Combine(output, "lzwManifest.json");
using FileStream inputStream = new(pFile, FileMode.Open, FileAccess.Read);
using BinaryReader br = new(inputStream);
foreach (Entry entry in pItem)
@ -206,6 +207,11 @@ namespace EscudeTools
if (lzwManifest.Count > 0)
{
using (FileStream fs = File.Create(jsonPath))
{
byte[] jsonBytes = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(lzwManifest));
fs.Write(jsonBytes, 0, jsonBytes.Length);
}
LzwDecode(lzwManifest, output);
};
@ -306,13 +312,13 @@ namespace EscudeTools
#endregion
}
//原先还在思考怎么实现lzw压缩
//摸一会儿鱼回来想到,不压缩好像也没问题
public bool Repack(string path, int version, bool useCustomKey = false, string customKeyProviderPath = "") //目前支持v2v1
{
if (useCustomKey)
LoadKey(customKeyProviderPath);
GeneratePItem(path);
if(File.Exists(Path.Combine(path, "lzwManifest.json")))
return false; //Q:为什么不支持 //A:因为我实在不想研究lzw算法欢迎PR
m_seed = isLoaded ? LoadedKey : 2210579460;
string outputPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(path) + ".bin");
using (FileStream fs = new(outputPath, FileMode.Create))
@ -371,27 +377,29 @@ namespace EscudeTools
}
foreach (Entry entry in pItem)
{
byte[] data = File.ReadAllBytes(Path.Combine(path, entry.Name));
bw.Write(data);
}
}
byte[] data = File.ReadAllBytes(Path.Combine(path, entry.Name));
bw.Write(data);
}
}
return true;
}
private void GeneratePItem(string path)
{
pItem.Clear();
var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories)
.Where(file => !file.EndsWith("lzwManifest.json", StringComparison.OrdinalIgnoreCase))
.ToArray();
foreach (var file in files)
{
var relativePath = Path.GetRelativePath(path, file);
var fileInfo = new FileInfo(file);
pItem.Add(new Entry
{
Name = relativePath,
Size = (uint)fileInfo.Length
});
}
var relativePath = Path.GetRelativePath(path, file);
var fileInfo = new FileInfo(file);
pItem.Add(new Entry
{
Name = relativePath,
Size = (uint)fileInfo.Length
});
}
m_count = (uint)pItem.Count;
}
}

View File

@ -329,19 +329,18 @@ namespace EscudeTools
//}
//Batch Repack ESC-ARC Package
if (Directory.Exists(args[0]) && Directory.Exists(args[1]))
if (Directory.Exists(args[0]))// && Directory.Exists(args[1])
{
string[] directories = Directory.GetDirectories(args[0]);
foreach (string directory in directories)
{
PackManager pm = new();
string providerFilePath = Path.Combine(args[1], Path.GetFileName(directory) + ".bin");
//string providerFilePath = Path.Combine(args[1], Path.GetFileName(directory) + ".bin");
if (pm.Repack(directory, 2, true))
Console.WriteLine("Repack Package Success");
else
{
Console.WriteLine("Repack Package Failed");
return;
}
}
}

View File

@ -2,7 +2,7 @@
"profiles": {
"EscudeTools": {
"commandName": "Project",
"commandLineArgs": "G:\\x221.local\\lab3\\test\\output\r\nG:\\x221.local\\lab3\\test\\helper"
"commandLineArgs": "G:\\x221.local\\lab3\\Haison\\output\\output"
}
}
}