Add header size checks for determing versions
This commit is contained in:
parent
8fdd61253a
commit
5c65cef106
@ -154,6 +154,8 @@ namespace FirstPlugin
|
|||||||
|
|
||||||
public List<GFBMaterial> GenericMaterials = new List<GFBMaterial>();
|
public List<GFBMaterial> GenericMaterials = new List<GFBMaterial>();
|
||||||
|
|
||||||
|
public bool IsV2 = false;
|
||||||
|
|
||||||
public void Read(FileReader reader, GFBMDL Root)
|
public void Read(FileReader reader, GFBMDL Root)
|
||||||
{
|
{
|
||||||
Skeleton = new STSkeleton();
|
Skeleton = new STSkeleton();
|
||||||
@ -165,10 +167,27 @@ namespace FirstPlugin
|
|||||||
Version = reader.ReadUInt32();
|
Version = reader.ReadUInt32();
|
||||||
Boundings = reader.ReadSingles(9);
|
Boundings = reader.ReadSingles(9);
|
||||||
|
|
||||||
//This value is usually 68 for pkmn sw/sh
|
//Temp check for valid bone header size (does not vary sizes, always 26)
|
||||||
uint check = reader.ReadUInt32();
|
using (reader.TemporarySeek(72, SeekOrigin.Begin))
|
||||||
if (check > 100)
|
{
|
||||||
reader.Seek(-4);
|
long boneData = reader.ReadOffset(true, typeof(uint));
|
||||||
|
if (boneData < reader.BaseStream.Length - 4)
|
||||||
|
{
|
||||||
|
reader.SeekBegin(boneData);
|
||||||
|
reader.ReadUInt32(); //count
|
||||||
|
long offset = reader.ReadOffset(true, typeof(uint));
|
||||||
|
if (offset < reader.BaseStream.Length - 4)
|
||||||
|
{
|
||||||
|
reader.SeekBegin(offset);
|
||||||
|
uint infoOffset = reader.ReadUInt32();
|
||||||
|
if (infoOffset == 26)
|
||||||
|
IsV2 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsV2)
|
||||||
|
reader.ReadUInt32();
|
||||||
|
|
||||||
long TextureOffset = reader.ReadOffset(true, typeof(uint));
|
long TextureOffset = reader.ReadOffset(true, typeof(uint));
|
||||||
long ShaderNameOffset = reader.ReadOffset(true, typeof(uint));
|
long ShaderNameOffset = reader.ReadOffset(true, typeof(uint));
|
||||||
@ -498,6 +517,9 @@ namespace FirstPlugin
|
|||||||
ShaderName = reader.ReadNameOffset(true, typeof(uint), true);
|
ShaderName = reader.ReadNameOffset(true, typeof(uint), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"MAT Name {Name}");
|
||||||
|
Console.WriteLine($"ShaderName {ShaderName}");
|
||||||
|
|
||||||
if (ShaderParamAPosition != 0)
|
if (ShaderParamAPosition != 0)
|
||||||
{
|
{
|
||||||
reader.SeekBegin(InfoPosition + ShaderParamAPosition);
|
reader.SeekBegin(InfoPosition + ShaderParamAPosition);
|
||||||
@ -1212,6 +1234,8 @@ namespace FirstPlugin
|
|||||||
{
|
{
|
||||||
reader.SeekBegin(InfoPosition + LayoutTypePosition);
|
reader.SeekBegin(InfoPosition + LayoutTypePosition);
|
||||||
Type = reader.ReadEnum<BufferType>(true);
|
Type = reader.ReadEnum<BufferType>(true);
|
||||||
|
|
||||||
|
Console.WriteLine($"Type {Type}");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Seek back to next in array
|
//Seek back to next in array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user