Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move 2.0.6 detection to object counting stage #1839

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading