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 1 commit
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
10 changes: 9 additions & 1 deletion UndertaleModLib/UndertaleChunks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,11 +1576,15 @@ internal override void SerializeChunk(UndertaleWriter writer)
// GMS 2.0.6.96 is the oldest available runtime version,
// so this actually could be some other version between GMS 2.0 - 2.0.6.
// (the oldest copy of "Zeus-Runtime.rss" on web.archive.org has this version as first one)
private static bool checkedFor2_0_6;
colinator27 marked this conversation as resolved.
Show resolved Hide resolved
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 +1621,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 +1654,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