Skip to content

Commit

Permalink
Handle another variation in rrtex format, also now log warning when s…
Browse files Browse the repository at this point in the history
…tructure size differs (#6)
  • Loading branch information
Taloth authored Oct 31, 2023
1 parent d12c785 commit c21a0d5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions AOEMods.Essence/Chunky/RRTex/RRTexReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ private static RRTexDataTman ReadDataTman(ChunkyFileReader reader, ChunkHeader h
Console.WriteLine($"RRTexDataTman.unknown6 not 1 (was {unknown6})");
}

if (unknown4 == 1)
{

}
else if (unknown4 == 2)
{
int unknown7 = reader.ReadInt32();

if (unknown7 != 1)
Console.WriteLine($"RRTexDataTman.unknown7 not 1 (was {unknown7})");
}
else
{
Console.WriteLine($"RRTexDataTman.unknown4 not 1 or 2 (was {unknown4})");
}

int[] mipTextureCounts = new int[mipCount];
for (int i = 0; i < mipCount; i++)
{
Expand All @@ -111,6 +127,12 @@ private static RRTexDataTman ReadDataTman(ChunkyFileReader reader, ChunkHeader h
}
}

long realLength = reader.BaseStream.Position - header.DataPosition;
if (header.Length != realLength)
{
Console.WriteLine($"RRTexDataTman header specifies {header.Length} bytes, but we read {realLength} bytes. Image likely to be corrupt and AOEMods.Essence may need to be patched.");
}

return new(
unknown1, width, height, unknown2, unknown3, textureCompression,
mipCount, unknown4, mipTextureCounts, sizeCompressed, sizeUncompressed
Expand Down

0 comments on commit c21a0d5

Please sign in to comment.