Skip to content

Commit

Permalink
Merge pull request #1839 from UnderminersTeam/move-2-0-6-detection-ea…
Browse files Browse the repository at this point in the history
…rlier

Move 2.0.6 detection to object counting stage
  • Loading branch information
colinator27 authored Jul 21, 2024
2 parents 0334778 + fd745b9 commit d4f6431
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion UndertaleModLib/UndertaleChunks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,8 @@ public class UndertaleChunkTXTR : UndertaleListChunk<UndertaleEmbeddedTexture>
public override string Name => "TXTR";

private static bool checkedFor2022_3;
private static bool checkedFor2_0_6;

private void CheckFor2022_3And5(UndertaleReader reader)
{
// Detect GM2022.3
Expand Down Expand Up @@ -1580,7 +1582,10 @@ private void CheckForGMS2_0_6(UndertaleReader reader)
{
bool atLeastGMS2_0 = reader.undertaleData.IsGameMaker2();
if (!atLeastGMS2_0 || reader.undertaleData.IsVersionAtLeast(2, 0, 6))
{
checkedFor2_0_6 = true;
return;
}

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

reader.Position = returnPos;
checkedFor2_0_6 = true;
}

internal override void UnserializeChunk(UndertaleReader reader)
{
if (!checkedFor2022_3)
CheckFor2022_3And5(reader);

CheckForGMS2_0_6(reader);
if (!checkedFor2_0_6)
CheckForGMS2_0_6(reader);

base.UnserializeChunk(reader);
reader.SwitchReaderType(false);
Expand All @@ -1648,8 +1655,10 @@ internal override void UnserializeChunk(UndertaleReader reader)
internal override uint UnserializeObjectCount(UndertaleReader reader)
{
checkedFor2022_3 = false;
checkedFor2_0_6 = false;

CheckFor2022_3And5(reader);
CheckForGMS2_0_6(reader);

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

0 comments on commit d4f6431

Please sign in to comment.