1
0
mirror of synced 2024-12-11 07:16:05 +01:00

TPL : Add support for little endian

This commit is contained in:
KillzXGaming 2020-09-18 17:20:36 -04:00
parent 9a0f6ebddd
commit 2f6605761a
2 changed files with 7 additions and 3 deletions

View File

@ -28,7 +28,8 @@ namespace FirstPlugin
using (var reader = new FileReader(stream, true)) using (var reader = new FileReader(stream, true))
{ {
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian; reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
return reader.ReadUInt32() == 0x0020AF30 || Utils.GetExtension(FileName) == ".tpl"; uint magic = reader.ReadUInt32();
return magic == 0x0020AF30 || magic == 0x30AF2000 || Utils.GetExtension(FileName) == ".tpl";
} }
} }

View File

@ -17,12 +17,13 @@ namespace FirstPlugin
public List<ImageEntry> Images = new List<ImageEntry>(); public List<ImageEntry> Images = new List<ImageEntry>();
public bool IsV1 = false; public bool IsV1 = false;
public bool IsBigEndian = true;
public void Read(FileReader reader) public void Read(FileReader reader)
{ {
reader.SetByteOrder(true); reader.SetByteOrder(true);
uint Identifier = reader.ReadUInt32(); uint Identifier = reader.ReadUInt32();
if (Identifier != 0x0020AF30) { if (Identifier != 0x0020AF30 && Identifier != 0x30AF2000) {
IsV1 = true; IsV1 = true;
reader.Position = 0; reader.Position = 0;
@ -36,6 +37,8 @@ namespace FirstPlugin
} }
} }
else { else {
IsBigEndian = Identifier == 0x0020AF30;
reader.SetByteOrder(IsBigEndian);
uint ImageCount = reader.ReadUInt32(); uint ImageCount = reader.ReadUInt32();
uint ImageOffsetTable = reader.ReadUInt32(); uint ImageOffsetTable = reader.ReadUInt32();
for (int i = 0; i < ImageCount; i++) { for (int i = 0; i < ImageCount; i++) {
@ -61,7 +64,7 @@ namespace FirstPlugin
public void Write(FileWriter writer) public void Write(FileWriter writer)
{ {
writer.SetByteOrder(true); writer.SetByteOrder(IsBigEndian);
if (IsV1) { if (IsV1) {
writer.Write(Images.Count); writer.Write(Images.Count);
for (int i = 0; i < Images.Count; i++) for (int i = 0; i < Images.Count; i++)