update
This commit is contained in:
parent
3adf8c207a
commit
ea52c2128b
@ -170,7 +170,7 @@ namespace EscudeTools
|
||||
// Add columns to the create table query
|
||||
foreach (var column in sheet.col)
|
||||
{
|
||||
createTableQuery.Append($"{column.name} {Utils.GetSQLiteColumnType(column.type, column.size)}, ");
|
||||
createTableQuery.Append($"{column.name} {Utils.GetSQLiteColumnType(column.type)}, ");
|
||||
}
|
||||
|
||||
createTableQuery.Remove(createTableQuery.Length - 2, 2); // Remove the last comma and space
|
||||
|
@ -114,9 +114,8 @@ namespace EscudeTools
|
||||
{
|
||||
static readonly byte[] lsfFileSignature = [0x4C, 0x53, 0x46, 0x00];
|
||||
static readonly byte[] lsfLayerSkipSignature = [0x00, 0x75, 0x6C, 0x00]; //flowchat部分的lsf块
|
||||
private static string WorkPath = string.Empty;
|
||||
private LsfData lsfData = new();
|
||||
private Dictionary<string, LsfData> lsfDataLookup = new();
|
||||
private Dictionary<string, LsfData> lsfDataLookup = [];
|
||||
|
||||
private bool preFetchInfo;
|
||||
|
||||
@ -158,7 +157,7 @@ namespace EscudeTools
|
||||
return lsfData; // 如果未找到,则返回 null
|
||||
}
|
||||
|
||||
private LsfFileHeader LoadLsfHeader(string path)
|
||||
private static LsfFileHeader LoadLsfHeader(string path)
|
||||
{
|
||||
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
if (fs.Length < 0x1C)
|
||||
|
@ -226,7 +226,7 @@ namespace EscudeTools
|
||||
return true;
|
||||
}
|
||||
|
||||
private void LzwDecode(List<LzwEntry> lzwManifest, string output)
|
||||
private static void LzwDecode(List<LzwEntry> lzwManifest, string output)
|
||||
{
|
||||
foreach (var i in lzwManifest)
|
||||
{
|
||||
@ -244,19 +244,13 @@ namespace EscudeTools
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class LzwDecoder : IDisposable
|
||||
internal sealed class LzwDecoder(Stream input, int unpacked_size) : IDisposable
|
||||
{
|
||||
private MsbBitStream m_input;
|
||||
private byte[] m_output;
|
||||
private MsbBitStream m_input = new(input, true);
|
||||
private byte[] m_output = new byte[unpacked_size];
|
||||
|
||||
public byte[] Output { get { return m_output; } }
|
||||
|
||||
public LzwDecoder(Stream input, int unpacked_size)
|
||||
{
|
||||
m_input = new MsbBitStream(input, true);
|
||||
m_output = new byte[unpacked_size];
|
||||
}
|
||||
|
||||
public void Unpack()
|
||||
{
|
||||
int dst = 0;
|
||||
@ -320,9 +314,9 @@ namespace EscudeTools
|
||||
#endregion
|
||||
}
|
||||
|
||||
public bool Repack(string path, int version, bool useCustomKey = false, string customKeyProviderPath = "") //目前支持v2v1
|
||||
public bool Repack(string path, int version, string customKeyProviderPath = "") //目前支持v2v1
|
||||
{
|
||||
if (useCustomKey)
|
||||
if (customKeyProviderPath!="")
|
||||
LoadKey(customKeyProviderPath);
|
||||
ReadPItem(path);
|
||||
List<LzwEntry> lzwManifest = [];
|
||||
@ -330,9 +324,8 @@ namespace EscudeTools
|
||||
lzwManifest = JsonSerializer.Deserialize<List<LzwEntry>>(File.ReadAllText(Path.Combine(path, "lzwManifest.json"))) ?? [];
|
||||
m_seed = isLoaded ? LoadedKey : 2210579460;
|
||||
string outputPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(path) + ".bin");
|
||||
using (FileStream fs = new(outputPath, FileMode.Create))
|
||||
using (BinaryWriter bw = new(fs))
|
||||
{
|
||||
using FileStream fs = new(outputPath, FileMode.Create);
|
||||
using BinaryWriter bw = new(fs);
|
||||
bw.Write(fileSignature);
|
||||
bw.Write(supportPackVersion[version - 1]);
|
||||
bw.Write(m_seed);
|
||||
@ -352,7 +345,7 @@ namespace EscudeTools
|
||||
bw.Write(result);
|
||||
bw.Write(storeOffset);
|
||||
uint size = pItem[i].Size;
|
||||
if (Utils.searchLzwEntryList(lzwManifest, pItem[i].Name) != -1)
|
||||
if (Utils.SearchLzwEntryList(lzwManifest, pItem[i].Name) != -1)
|
||||
size = (uint)FakeCompress(File.ReadAllBytes(Path.Combine(path, pItem[i].Name))).Length;
|
||||
bw.Write(size);
|
||||
storeOffset += size;
|
||||
@ -374,7 +367,7 @@ namespace EscudeTools
|
||||
BitConverter.GetBytes(storeOffset).CopyTo(index, indexOffset);
|
||||
indexOffset += 4;
|
||||
uint size = pItem[i].Size;
|
||||
if (Utils.searchLzwEntryList(lzwManifest, pItem[i].Name) != -1)
|
||||
if (Utils.SearchLzwEntryList(lzwManifest, pItem[i].Name) != -1)
|
||||
size = (uint)FakeCompress(File.ReadAllBytes(Path.Combine(path, pItem[i].Name))).Length;
|
||||
BitConverter.GetBytes(size).CopyTo(index, indexOffset);
|
||||
indexOffset += 4;
|
||||
@ -394,14 +387,13 @@ namespace EscudeTools
|
||||
foreach (Entry entry in pItem)
|
||||
{
|
||||
byte[] data;
|
||||
if (Utils.searchLzwEntryList(lzwManifest, entry.Name) != -1)
|
||||
if (Utils.SearchLzwEntryList(lzwManifest, entry.Name) != -1)
|
||||
data = FakeCompress(File.ReadAllBytes(Path.Combine(path, entry.Name)));
|
||||
else
|
||||
data = File.ReadAllBytes(Path.Combine(path, entry.Name));
|
||||
|
||||
bw.Write(data);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -437,8 +429,7 @@ namespace EscudeTools
|
||||
//不压其实也没事
|
||||
public static byte[] FakeCompress(byte[] Data)
|
||||
{
|
||||
using (MemoryStream Stream = new())
|
||||
{
|
||||
using MemoryStream Stream = new();
|
||||
byte[] Buffer = new byte[4];
|
||||
((uint)Utils.Reverse((uint)Data.Length)).WriteTo(Buffer, 0);
|
||||
Stream.WriteCString("acp");
|
||||
@ -462,4 +453,3 @@ namespace EscudeTools
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -105,7 +105,7 @@ namespace EscudeTools
|
||||
stream.CopyTo(fileStream);
|
||||
}
|
||||
|
||||
public static string GetSQLiteColumnType(ushort type, uint size)
|
||||
public static string GetSQLiteColumnType(ushort type)
|
||||
{
|
||||
if (type == 1)
|
||||
return "INTEGER";
|
||||
@ -197,37 +197,26 @@ namespace EscudeTools
|
||||
byte[] Arr = BitConverter.GetBytes(Data);
|
||||
Array.Reverse(Arr, 0, Arr.Length);
|
||||
string type = Data.GetType().FullName;
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
case Const.INT8:
|
||||
case Const.UINT8:
|
||||
return Data;
|
||||
case Const.INT16:
|
||||
return BitConverter.ToInt16(Arr, 0);
|
||||
case Const.UINT16:
|
||||
return BitConverter.ToUInt16(Arr, 0);
|
||||
case Const.INT32:
|
||||
return BitConverter.ToInt32(Arr, 0);
|
||||
case Const.UINT32:
|
||||
return BitConverter.ToUInt32(Arr, 0);
|
||||
case Const.INT64:
|
||||
return BitConverter.ToInt64(Arr, 0);
|
||||
case Const.UINT64:
|
||||
return BitConverter.ToUInt64(Arr, 0);
|
||||
case Const.DOUBLE:
|
||||
return BitConverter.ToDouble(Arr, 0);
|
||||
case Const.FLOAT:
|
||||
return BitConverter.ToSingle(Arr, 0);
|
||||
default:
|
||||
throw new Exception("Unk Data Type.");
|
||||
}
|
||||
Const.INT8 or Const.UINT8 => Data,
|
||||
Const.INT16 => BitConverter.ToInt16(Arr, 0),
|
||||
Const.UINT16 => BitConverter.ToUInt16(Arr, 0),
|
||||
Const.INT32 => BitConverter.ToInt32(Arr, 0),
|
||||
Const.UINT32 => BitConverter.ToUInt32(Arr, 0),
|
||||
Const.INT64 => BitConverter.ToInt64(Arr, 0),
|
||||
Const.UINT64 => BitConverter.ToUInt64(Arr, 0),
|
||||
Const.DOUBLE => BitConverter.ToDouble(Arr, 0),
|
||||
Const.FLOAT => BitConverter.ToSingle(Arr, 0),
|
||||
_ => throw new Exception("Unk Data Type."),
|
||||
};
|
||||
}
|
||||
public static void WriteTo(uint Value, byte[] Binary, uint At)
|
||||
{
|
||||
BitConverter.GetBytes(Value).CopyTo(Binary, At);
|
||||
}
|
||||
|
||||
public static int searchLzwEntryList(List<LzwEntry> lle, string keyword)
|
||||
public static int SearchLzwEntryList(List<LzwEntry> lle, string keyword)
|
||||
{
|
||||
foreach (LzwEntry le in lle)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user