diff --git a/UndertaleModLib/Models/UndertaleSprite.cs b/UndertaleModLib/Models/UndertaleSprite.cs index 1ceddbe8f..682f46c96 100644 --- a/UndertaleModLib/Models/UndertaleSprite.cs +++ b/UndertaleModLib/Models/UndertaleSprite.cs @@ -1174,11 +1174,20 @@ public class UndertaleYYSWFGradientFillData : UndertaleObject public UndertaleYYSWFGradientFillType GradientFillType { get; set; } public UndertaleYYSWFMatrix33 TransformationMatrix { get; set; } public UndertaleSimpleList Records { get; set; } + /// + /// Unknown purpose. Probably to accomodate for new texture formats. + /// + /// + /// Presumably present in GM 2022.1+. + /// + public int? TPEIndex { get; set; } /// public void Serialize(UndertaleWriter writer) { writer.Write((int)GradientFillType); + if (TPEIndex is not null) + writer.Write(TPEIndex.Value); writer.WriteUndertaleObject(TransformationMatrix); writer.WriteUndertaleObject(Records); } @@ -1187,6 +1196,10 @@ public void Serialize(UndertaleWriter writer) public void Unserialize(UndertaleReader reader) { GradientFillType = (UndertaleYYSWFGradientFillType)reader.ReadInt32(); + if (reader.undertaleData.IsVersionAtLeast(2022, 1)) + { + TPEIndex = reader.ReadInt32(); + } TransformationMatrix = reader.ReadUndertaleObject(); Records = new UndertaleSimpleList(); int count = reader.ReadInt32(); @@ -1651,6 +1664,13 @@ public class UndertaleYYSWFBitmapData : UndertaleObject public UndertaleYYSWFBitmapType Type { get; set; } public int Width { get; set; } public int Height { get; set; } + /// + /// Unknown purpose. Probably to accomodate for new texture formats. + /// + /// + /// Presumably present in GM 2022.1+. + /// + public int? TPEIndex { get; set; } public byte[] ImageData { get; set; } public byte[] AlphaData { get; set; } public byte[] ColorPaletteData { get; set; } @@ -1663,18 +1683,25 @@ public void Serialize(UndertaleWriter writer) writer.Write(Width); writer.Write(Height); - writer.Write(ImageData is null ? 0 : ImageData.Length); - writer.Write(AlphaData is null ? 0 : AlphaData.Length); - writer.Write(ColorPaletteData is null ? 0 : ColorPaletteData.Length); + if (TPEIndex is null) + { + writer.Write(ImageData is null ? 0 : ImageData.Length); + writer.Write(AlphaData is null ? 0 : AlphaData.Length); + writer.Write(ColorPaletteData is null ? 0 : ColorPaletteData.Length); - if (ImageData != null) - writer.Write(ImageData); - if (AlphaData != null) - writer.Write(AlphaData); - if (ColorPaletteData != null) - writer.Write(ColorPaletteData); + if (ImageData != null) + writer.Write(ImageData); + if (AlphaData != null) + writer.Write(AlphaData); + if (ColorPaletteData != null) + writer.Write(ColorPaletteData); - writer.Align(4); + writer.Align(4); + } + else + { + writer.Write(TPEIndex.Value); + } } /// @@ -1684,18 +1711,25 @@ public void Unserialize(UndertaleReader reader) Width = reader.ReadInt32(); Height = reader.ReadInt32(); - int iL = reader.ReadInt32(); - int aL = reader.ReadInt32(); - int cL = reader.ReadInt32(); + if (reader.undertaleData.IsVersionAtLeast(2022, 1)) + { + TPEIndex = reader.ReadInt32(); + } + else + { + int iL = reader.ReadInt32(); + int aL = reader.ReadInt32(); + int cL = reader.ReadInt32(); - if (iL > 0) - ImageData = reader.ReadBytes(iL); - if (aL > 0) - AlphaData = reader.ReadBytes(aL); - if (cL > 0) - ColorPaletteData = reader.ReadBytes(cL); + if (iL > 0) + ImageData = reader.ReadBytes(iL); + if (aL > 0) + AlphaData = reader.ReadBytes(aL); + if (cL > 0) + ColorPaletteData = reader.ReadBytes(cL); - reader.Align(4); + reader.Align(4); + } } }