Skip to content

Commit

Permalink
Merge pull request #1848 from Jacky720/lts-differentiation
Browse files Browse the repository at this point in the history
Fix 2022.0.2 detection
  • Loading branch information
colinator27 authored Jul 27, 2024
2 parents 7912f63 + 1df139d commit c47aca8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions UndertaleModLib/Models/UndertaleFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public void Serialize(UndertaleWriter writer)
writer.Write(AscenderOffset);
if (writer.undertaleData.IsVersionAtLeast(2022, 2))
writer.Write(Ascender);
if (writer.undertaleData.IsVersionAtLeast(2023, 2))
if (writer.undertaleData.IsNonLTSVersionAtLeast(2023, 2))
writer.Write(SDFSpread);
if (writer.undertaleData.IsVersionAtLeast(2023, 6))
writer.Write(LineHeight);
Expand Down Expand Up @@ -335,7 +335,7 @@ public void Unserialize(UndertaleReader reader)
AscenderOffset = reader.ReadInt32();
if (reader.undertaleData.IsVersionAtLeast(2022, 2))
Ascender = reader.ReadUInt32();
if (reader.undertaleData.IsVersionAtLeast(2023, 2))
if (reader.undertaleData.IsNonLTSVersionAtLeast(2023, 2))
SDFSpread = reader.ReadUInt32();
if (reader.undertaleData.IsVersionAtLeast(2023, 6))
LineHeight = reader.ReadUInt32();
Expand All @@ -350,7 +350,7 @@ public static uint UnserializeChildObjectCount(UndertaleReader reader)
skipSize += 4; // AscenderOffset
if (reader.undertaleData.IsVersionAtLeast(2022, 2))
skipSize += 4; // Ascender
if (reader.undertaleData.IsVersionAtLeast(2023, 2))
if (reader.undertaleData.IsNonLTSVersionAtLeast(2023, 2))
skipSize += 4; // SDFSpread
if (reader.undertaleData.IsVersionAtLeast(2023, 6))
skipSize += 4; // LineHeight
Expand Down
5 changes: 4 additions & 1 deletion UndertaleModLib/UndertaleChunks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,10 @@ private void CheckForGM2023_6(UndertaleReader reader)
if (reader.ReadUInt32() > 0) // Font count
{
uint firstFontPointer = reader.ReadUInt32();
reader.AbsPosition = firstFontPointer + 56; // Two more values: SDFSpread and LineHeight. 48 + 4 + 4 = 56.
reader.AbsPosition = firstFontPointer + 52; // Also the LineHeight value. 48 + 4 = 52.
if (reader.undertaleData.IsNonLTSVersionAtLeast(2023, 2)) // SDFSpread is present from 2023.2 non-LTS onward
reader.AbsPosition += 4; // (detected by PSEM/PSYS chunk existence)

uint glyphsLength = reader.ReadUInt32();
GMS2023_6 = true;
if ((glyphsLength * 4) > this.Length)
Expand Down

0 comments on commit c47aca8

Please sign in to comment.