From e7c7913b749cb88c3a364a35d6000b7df3814a6d Mon Sep 17 00:00:00 2001 From: Benjamin Urquhart Date: Wed, 1 May 2024 01:32:11 -0400 Subject: [PATCH 1/2] "Fix" 2024.2 detection (makes Undertale Yellow load again) --- UndertaleModLib/UndertaleChunks.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UndertaleModLib/UndertaleChunks.cs b/UndertaleModLib/UndertaleChunks.cs index 626d8432c..bc942ddc8 100644 --- a/UndertaleModLib/UndertaleChunks.cs +++ b/UndertaleModLib/UndertaleChunks.cs @@ -923,10 +923,10 @@ private void CheckForTileCompression(UndertaleReader reader) { // Check complete, found and tested a layer. reader.undertaleData.SetGMS2Version(2024, 2); - reader.Position = returnTo; - checkedFor2024_2 = true; - return; } + reader.Position = returnTo; + checkedFor2024_2 = true; + return; } } From 921e0c8ce66765f21997794ad6f789930265223e Mon Sep 17 00:00:00 2001 From: Benjamin Urquhart Date: Thu, 2 May 2024 13:48:31 -0400 Subject: [PATCH 2/2] Fix it correctly --- UndertaleModLib/Models/UndertaleRoom.cs | 2 +- UndertaleModLib/UndertaleChunks.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/UndertaleModLib/Models/UndertaleRoom.cs b/UndertaleModLib/Models/UndertaleRoom.cs index 4b0c1a972..02153c6f7 100644 --- a/UndertaleModLib/Models/UndertaleRoom.cs +++ b/UndertaleModLib/Models/UndertaleRoom.cs @@ -1799,7 +1799,7 @@ public void ReadCompressedTileData(UndertaleReader reader) // sanity check: run of 2 empty tiles if (length != 0x81) - throw new IOException("Expected 0x81, got " + length.ToString("X2")); + throw new IOException("Expected 0x81, got 0x" + length.ToString("X2")); if (tile != unchecked((uint)-1)) throw new IOException("Expected -1, got " + tile + " (0x" + tile.ToString("X8") + ")"); } diff --git a/UndertaleModLib/UndertaleChunks.cs b/UndertaleModLib/UndertaleChunks.cs index bc942ddc8..48b83e966 100644 --- a/UndertaleModLib/UndertaleChunks.cs +++ b/UndertaleModLib/UndertaleChunks.cs @@ -916,7 +916,10 @@ private void CheckForTileCompression(UndertaleReader reader) if (layerType != LayerType.Tiles) continue; - reader.Position += 10 * 4; + reader.Position += 32; + int effectCount = reader.ReadInt32(); + reader.Position += effectCount * 12 + 4; + int tileMapWidth = reader.ReadInt32(); int tileMapHeight = reader.ReadInt32(); if (nextOffset - reader.AbsPosition != (tileMapWidth * tileMapHeight * 4))