Skip to content

Commit d4f6431

Browse files
authored
Merge pull request #1839 from UnderminersTeam/move-2-0-6-detection-earlier
Move 2.0.6 detection to object counting stage
2 parents 0334778 + fd745b9 commit d4f6431

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

UndertaleModLib/UndertaleChunks.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,8 @@ public class UndertaleChunkTXTR : UndertaleListChunk<UndertaleEmbeddedTexture>
14591459
public override string Name => "TXTR";
14601460

14611461
private static bool checkedFor2022_3;
1462+
private static bool checkedFor2_0_6;
1463+
14621464
private void CheckFor2022_3And5(UndertaleReader reader)
14631465
{
14641466
// Detect GM2022.3
@@ -1580,7 +1582,10 @@ private void CheckForGMS2_0_6(UndertaleReader reader)
15801582
{
15811583
bool atLeastGMS2_0 = reader.undertaleData.IsGameMaker2();
15821584
if (!atLeastGMS2_0 || reader.undertaleData.IsVersionAtLeast(2, 0, 6))
1585+
{
1586+
checkedFor2_0_6 = true;
15831587
return;
1588+
}
15841589

15851590
long returnPos = reader.Position;
15861591
bool noGeneratedMips = false;
@@ -1617,14 +1622,16 @@ private void CheckForGMS2_0_6(UndertaleReader reader)
16171622
reader.undertaleData.SetGMS2Version(2, 0, 6);
16181623

16191624
reader.Position = returnPos;
1625+
checkedFor2_0_6 = true;
16201626
}
16211627

16221628
internal override void UnserializeChunk(UndertaleReader reader)
16231629
{
16241630
if (!checkedFor2022_3)
16251631
CheckFor2022_3And5(reader);
16261632

1627-
CheckForGMS2_0_6(reader);
1633+
if (!checkedFor2_0_6)
1634+
CheckForGMS2_0_6(reader);
16281635

16291636
base.UnserializeChunk(reader);
16301637
reader.SwitchReaderType(false);
@@ -1648,8 +1655,10 @@ internal override void UnserializeChunk(UndertaleReader reader)
16481655
internal override uint UnserializeObjectCount(UndertaleReader reader)
16491656
{
16501657
checkedFor2022_3 = false;
1658+
checkedFor2_0_6 = false;
16511659

16521660
CheckFor2022_3And5(reader);
1661+
CheckForGMS2_0_6(reader);
16531662

16541663
// Texture blobs are already included in the count
16551664
return base.UnserializeObjectCount(reader);

0 commit comments

Comments
 (0)