移除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)) if (!Directory.Exists(output))
Directory.CreateDirectory(output); Directory.CreateDirectory(output);
var lzwManifest = new List<LzwEntry>(); var lzwManifest = new List<LzwEntry>();
string jsonPath = Path.Combine(output, "lzwManifest.json");
using FileStream inputStream = new(pFile, FileMode.Open, FileAccess.Read); using FileStream inputStream = new(pFile, FileMode.Open, FileAccess.Read);
using BinaryReader br = new(inputStream); using BinaryReader br = new(inputStream);
foreach (Entry entry in pItem) foreach (Entry entry in pItem)
@ -206,6 +207,11 @@ namespace EscudeTools
if (lzwManifest.Count > 0) 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); LzwDecode(lzwManifest, output);
}; };
@ -306,13 +312,13 @@ namespace EscudeTools
#endregion #endregion
} }
//原先还在思考怎么实现lzw压缩
//摸一会儿鱼回来想到,不压缩好像也没问题
public bool Repack(string path, int version, bool useCustomKey = false, string customKeyProviderPath = "") //目前支持v2v1 public bool Repack(string path, int version, bool useCustomKey = false, string customKeyProviderPath = "") //目前支持v2v1
{ {
if (useCustomKey) if (useCustomKey)
LoadKey(customKeyProviderPath); LoadKey(customKeyProviderPath);
GeneratePItem(path); GeneratePItem(path);
if(File.Exists(Path.Combine(path, "lzwManifest.json")))
return false; //Q:为什么不支持 //A:因为我实在不想研究lzw算法欢迎PR
m_seed = isLoaded ? LoadedKey : 2210579460; m_seed = isLoaded ? LoadedKey : 2210579460;
string outputPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(path) + ".bin"); string outputPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(path) + ".bin");
using (FileStream fs = new(outputPath, FileMode.Create)) using (FileStream fs = new(outputPath, FileMode.Create))
@ -381,7 +387,9 @@ namespace EscudeTools
private void GeneratePItem(string path) private void GeneratePItem(string path)
{ {
pItem.Clear(); 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) foreach (var file in files)
{ {
var relativePath = Path.GetRelativePath(path, file); var relativePath = Path.GetRelativePath(path, file);

View File

@ -329,19 +329,18 @@ namespace EscudeTools
//} //}
//Batch Repack ESC-ARC Package //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]); string[] directories = Directory.GetDirectories(args[0]);
foreach (string directory in directories) foreach (string directory in directories)
{ {
PackManager pm = new(); 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)) if (pm.Repack(directory, 2, true))
Console.WriteLine("Repack Package Success"); Console.WriteLine("Repack Package Success");
else else
{ {
Console.WriteLine("Repack Package Failed"); Console.WriteLine("Repack Package Failed");
return;
} }
} }
} }

View File

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