Skip to content

Commit

Permalink
fixed Mirage\Anim string reading
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashrindy committed Oct 24, 2024
1 parent 60bc3d2 commit 84ce4df
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 19 deletions.
4 changes: 2 additions & 2 deletions AshDumpLib/ExtendedBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public virtual void Jump(long offset, SeekOrigin origin)
Seek(offset + genericOffset, origin);
}

public virtual string ReadStringTableEntry(bool useGenOffset = false)
public virtual string ReadStringTableEntry(bool useGenOffset = false, bool dontCheckForZeroes = false)
{
long pointer = Read<int>();
if (pointer > 0)
if (pointer > 0 || dontCheckForZeroes)
{
if (useGenOffset)
pointer += genericOffset;
Expand Down
8 changes: 4 additions & 4 deletions AshDumpLib/HedgehogEngine/Archives/PAC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ void ReadV3(ExtendedBinaryReader reader)
rootChunk.uncompressedData = uncompressedRootData.ToArray();
}
reader.Seek(prePos1, SeekOrigin.Begin);
File.WriteAllBytes(FilePath + "_og.root", rootChunk.uncompressedData);
//File.WriteAllBytes(FilePath + "_og.root", rootChunk.uncompressedData);
PAC rootPac = new();
rootPac.Open(FileName + ".root", rootChunk.uncompressedData, parseFiles);
foreach (var x in rootPac.Files)
Expand All @@ -968,7 +968,7 @@ void ReadV3(ExtendedBinaryReader reader)
}
rootPac.dependencies[i].main.uncompressedData = uncompressedData.ToArray();
}
File.WriteAllBytes(FilePath + "_og." + i, rootPac.dependencies[i].main.uncompressedData);
//File.WriteAllBytes(FilePath + "_og." + i, rootPac.dependencies[i].main.uncompressedData);
PAC tempPac = new();
tempPac.Open(rootPac.dependencies[i].name, rootPac.dependencies[i].main.uncompressedData, parseFiles);
foreach (var x in tempPac.Files)
Expand Down Expand Up @@ -1025,7 +1025,7 @@ void WriteV3(ExtendedBinaryWriter writer)
dep.chunks = ddChunks;
deps.Add(dep);
depPacs.Add(depPac);
File.WriteAllBytes($"{FilePath}.{index}", dmemStream.ToArray());
//File.WriteAllBytes($"{FilePath}.{index}", dmemStream.ToArray());
index++;
}
PAC rootPac = new();
Expand Down Expand Up @@ -1190,7 +1190,7 @@ void WriteV3(ExtendedBinaryWriter writer)

writer.Align(16);

File.WriteAllBytes(FilePath + ".root", rootChunk.uncompressedData);
//File.WriteAllBytes(FilePath + ".root", rootChunk.uncompressedData);
}

public struct PACVersion
Expand Down
2 changes: 1 addition & 1 deletion AshDumpLib/HedgehogEngine/BINA/BINAReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void ReadHeader()
this.Skip(RelativeDataOffset);
}

public override string ReadStringTableEntry(bool useGenOffset = false)
public override string ReadStringTableEntry(bool useGenOffset = false, bool dontCheckForZeroes = false)
{
//Reads the string table pointer
long pointer = Read<long>();
Expand Down
2 changes: 1 addition & 1 deletion AshDumpLib/HedgehogEngine/Mirage/Anim/CameraAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void Read(ExtendedBinaryReader reader, List<Keyframe> keyframes)
var prePos = reader.Position;
reader.Jump(pointer, SeekOrigin.Begin);

Name = reader.ReadStringTableEntry();
Name = reader.ReadStringTableEntry(dontCheckForZeroes: true);
RotationOrAim = reader.Read<byte>() == 1;
reader.Skip(3);
FPS = reader.Read<float>();
Expand Down
2 changes: 1 addition & 1 deletion AshDumpLib/HedgehogEngine/Mirage/Anim/MaterialAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void Read(ExtendedBinaryReader reader, List<Keyframe> keyframes)
var pointer = reader.Read<uint>();
var prePos = reader.Position;
reader.Jump(pointer, SeekOrigin.Begin);
Name = reader.ReadStringTableEntry();
Name = reader.ReadStringTableEntry(dontCheckForZeroes: true);
FPS = reader.Read<float>();
FrameStart = reader.Read<float>();
FrameEnd = reader.Read<float>();
Expand Down
6 changes: 3 additions & 3 deletions AshDumpLib/HedgehogEngine/Mirage/Anim/UVAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public override void Read(ExtendedBinaryReader reader)
}

reader.Jump(uvsPointer, SeekOrigin.Begin);
MaterialName = reader.ReadStringTableEntry();
TextureName = reader.ReadStringTableEntry();
MaterialName = reader.ReadStringTableEntry(dontCheckForZeroes: true);
TextureName = reader.ReadStringTableEntry(dontCheckForZeroes: true);
var uvCount = reader.Read<int>();
for (int i = 0; i < uvCount; i++)
{
Expand Down Expand Up @@ -120,7 +120,7 @@ public void Read(ExtendedBinaryReader reader, List<Keyframe> keyframes)
var pointer = reader.Read<uint>();
var prePos = reader.Position;
reader.Jump(pointer, SeekOrigin.Begin);
Name = reader.ReadStringTableEntry();
Name = reader.ReadStringTableEntry(dontCheckForZeroes: true);
FPS = reader.Read<float>();
FrameStart = reader.Read<float>();
FrameEnd = reader.Read<float>();
Expand Down
6 changes: 3 additions & 3 deletions AshDumpLib/HedgehogEngine/Mirage/Anim/VisibilityAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public override void Read(ExtendedBinaryReader reader)
}

reader.Jump(vissPointer, SeekOrigin.Begin);
SkeletonName = reader.ReadStringTableEntry();
InputName = reader.ReadStringTableEntry();
SkeletonName = reader.ReadStringTableEntry(dontCheckForZeroes: true);
InputName = reader.ReadStringTableEntry(dontCheckForZeroes: true);
var visCount = reader.Read<int>();
for (int i = 0; i < visCount; i++)
{
Expand Down Expand Up @@ -117,7 +117,7 @@ public void Read(ExtendedBinaryReader reader, List<Keyframe> keyframes)
var pointer = reader.Read<uint>();
var prePos = reader.Position;
reader.Jump(pointer, SeekOrigin.Begin);
Name = reader.ReadStringTableEntry();
Name = reader.ReadStringTableEntry(dontCheckForZeroes: true);
FPS = reader.Read<float>();
FrameStart = reader.Read<float>();
FrameEnd = reader.Read<float>();
Expand Down
20 changes: 16 additions & 4 deletions AshDumpLibTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,22 @@
//NeedleShader needleShader = new(filepath);
//Animator asm = new(filepath);
//asm.SaveToFile(filepath + "1");
PAC pAC = new();
pAC.parseFiles = false;
pAC.Open(filepath);
pAC.SaveToFile(filepath+".pac");
foreach(var i in Directory.GetFiles(filepath))
{
PAC pAC = new();
pAC.parseFiles = false;
pAC.Open(i);
if(pAC.Files.Where(x => x.Extension == "cam-anim").Count() > 0)
foreach(var l in pAC.Files.Where(x => x.Extension == "cam-anim"))
{
CameraAnimation camanim = new();
camanim.Open(l.FileName, l.Data);
foreach(var m in camanim.Cameras)
if(m.AspectRatio > 1.79 || m.AspectRatio < 1.76)
Console.WriteLine($"{i}\\{l.FileName}: {m.Name} - bad aspect ratio");
}
}

//pAC.parseFiles = false;
//pAC.SaveToFile(filepath + "test.pac");
//PointCloud pcmodel = new(filepath);
Expand Down

0 comments on commit 84ce4df

Please sign in to comment.