修复明显的错误,仍然存在bug

除导出type1外其他测试通过
This commit is contained in:
Chenx221 2024-10-19 00:15:39 +08:00
parent 206999c456
commit 4ad356f145
3 changed files with 73 additions and 44 deletions

View File

@ -52,45 +52,64 @@
//} //}
//Batch Unpack Script(Full, Text, Mess) ////Batch Unpack Script(Full, Text, Mess)
if (Directory.Exists(args[0])) //if (Directory.Exists(args[0]))
{ //{
string[] files = Directory.GetFiles(args[0], "*.bin"); // string[] files = Directory.GetFiles(args[0], "*.bin");
foreach (string file in files) // foreach (string file in files)
{ // {
ScriptManager smr = new(); // ScriptManager smr = new();
if (smr.LoadScriptFile(file)) // if (smr.LoadScriptFile(file))
{ // {
Console.WriteLine($"Load {file} Success"); // Console.WriteLine($"Load {file} Success");
} // }
else // else
{ // {
Console.WriteLine($"Load {file} Failed"); // Console.WriteLine($"Load {file} Failed");
return; // return;
} // }
if (smr.ExportDatabase(Path.GetDirectoryName(args[0]))) // if (smr.ExportDatabase(Path.GetDirectoryName(args[0])))
Console.WriteLine("Export Script Success"); // Console.WriteLine("Export Script Success");
else // else
{ // {
Console.WriteLine("Export Script Failed"); // Console.WriteLine("Export Script Failed");
return; // return;
} // }
if (smr.ExportTextDatabase(Path.GetDirectoryName(args[0]))) // if (smr.ExportTextDatabase(Path.GetDirectoryName(args[0])))
Console.WriteLine("Export Text Success"); // Console.WriteLine("Export Text Success");
else // else
{ // {
Console.WriteLine("Export Text Failed"); // Console.WriteLine("Export Text Failed");
return; // return;
} // }
if (smr.ExportMessDatabase(Path.GetDirectoryName(args[0]))) // if (smr.ExportMessDatabase(Path.GetDirectoryName(args[0])))
Console.WriteLine("Export Mess Success"); // Console.WriteLine("Export Mess Success");
else // else
{ // {
Console.WriteLine("Export Mess Failed"); // Console.WriteLine("Export Mess Failed");
return; // return;
} // }
} // }
} //}
////Export Script Type 1
//if (File.Exists(args[0])) //fail //lost 1 //something diff
//{
// ScriptManager.Repackv1(args[0], true);
//}
////Export Script Type 2
//if (File.Exists(args[0])) //pass
//{
// ScriptManager.Repackv2(args[0], true);
//}
////Export Script Type 3
//if (File.Exists(args[0])) //pass
//{
// ScriptManager.Repackv3(args[0]);
//}
//ScriptManager smr = new(); //ScriptManager smr = new();

View File

@ -2,7 +2,7 @@
"profiles": { "profiles": {
"EscudeTools": { "EscudeTools": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "G:\\x221.local\\lab\\test1\\script" "commandLineArgs": "\"G:\\x221.local\\lab\\test1\\type3\\script_text.db\""
} }
} }
} }

View File

@ -321,9 +321,9 @@ namespace EscudeTools
foreach (string ts in sf.TextString) foreach (string ts in sf.TextString)
{ {
insertCmd.Parameters.Clear(); insertCmdSub.Parameters.Clear();
insertCmd.Parameters.AddWithValue("@Text", ts ?? ""); insertCmdSub.Parameters.AddWithValue("@Text", ts ?? "");
insertCmd.ExecuteNonQuery(); insertCmdSub.ExecuteNonQuery();
} }
transaction.Commit(); transaction.Commit();
@ -427,6 +427,9 @@ namespace EscudeTools
Encoding? shiftJis = provider.GetEncoding("shift-jis"); Encoding? shiftJis = provider.GetEncoding("shift-jis");
foreach (var tableName in tableNames) foreach (var tableName in tableNames)
{ {
string folder = Path.Combine(Path.GetDirectoryName(sqlitePath), "repack");
if (!Directory.Exists(folder))
Directory.CreateDirectory(folder);
string outputPath = Path.Combine(Path.GetDirectoryName(sqlitePath), "repack", tableName + ".bin"); string outputPath = Path.Combine(Path.GetDirectoryName(sqlitePath), "repack", tableName + ".bin");
using FileStream fs = new(outputPath, FileMode.Create); using FileStream fs = new(outputPath, FileMode.Create);
using BinaryWriter bw = new(fs); using BinaryWriter bw = new(fs);
@ -436,6 +439,7 @@ namespace EscudeTools
TextCount = 0, TextCount = 0,
TextSize = 0, TextSize = 0,
MessCount = 0, MessCount = 0,
Commands = []
}; };
uint Offset = 0; uint Offset = 0;
List<uint> messOffset = new(); List<uint> messOffset = new();
@ -603,6 +607,9 @@ namespace EscudeTools
Encoding? shiftJis = provider.GetEncoding("shift-jis"); Encoding? shiftJis = provider.GetEncoding("shift-jis");
foreach (var tableName in tableNames) foreach (var tableName in tableNames)
{ {
string folder = Path.Combine(Path.GetDirectoryName(sqlitePath), "repack");
if (!Directory.Exists(folder))
Directory.CreateDirectory(folder);
string outputPath = Path.Combine(Path.GetDirectoryName(sqlitePath), "repack", tableName + ".001"); string outputPath = Path.Combine(Path.GetDirectoryName(sqlitePath), "repack", tableName + ".001");
using FileStream fs = new(outputPath, FileMode.Create); using FileStream fs = new(outputPath, FileMode.Create);
using BinaryWriter bw = new(fs); using BinaryWriter bw = new(fs);
@ -694,7 +701,7 @@ namespace EscudeTools
return true; return true;
} }
public static bool Repackv3(string sqlitePath, bool scramble = true) public static bool Repackv3(string sqlitePath)
{ {
if (!File.Exists(sqlitePath)) if (!File.Exists(sqlitePath))
return false; return false;
@ -714,6 +721,9 @@ namespace EscudeTools
Encoding? shiftJis = provider.GetEncoding("shift-jis"); Encoding? shiftJis = provider.GetEncoding("shift-jis");
foreach (var tableName in tableNames) foreach (var tableName in tableNames)
{ {
string folder = Path.Combine(Path.GetDirectoryName(sqlitePath), "repack");
if (!Directory.Exists(folder))
Directory.CreateDirectory(folder);
string outputPath = Path.Combine(Path.GetDirectoryName(sqlitePath), "repack", tableName + ".bin"); string outputPath = Path.Combine(Path.GetDirectoryName(sqlitePath), "repack", tableName + ".bin");
using FileStream fs = new(outputPath, FileMode.Create); using FileStream fs = new(outputPath, FileMode.Create);
using BinaryWriter bw = new(fs); using BinaryWriter bw = new(fs);