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

2024.11 compatibility hacks #2013

Draft
wants to merge 29 commits into
base: underanalyzer
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fe9696b
2024.11 compatibility: Horrible hack to ignore null entries in list c…
Dobby233Liu Jan 9, 2025
9bed1ff
Assume GM 2024.11 if null pointers exist, add unknown property to UTFont
Dobby233Liu Jan 15, 2025
447f33e
Remove accidentally included debugging
Dobby233Liu Jan 15, 2025
6b110e8
**TEMP** Hack to make finding references work
Dobby233Liu Jan 15, 2025
9bc4c56
Make it possible to save with nulls in list chunk
Dobby233Liu Jan 16, 2025
fe1623e
Add ResourceListTreeViewItem with special handling for null items
Dobby233Liu Jan 16, 2025
01ad4ae
Random refactors to ResourceListTreeViewItem
Dobby233Liu Jan 18, 2025
82ea608
Convert resource list header hiding logic to style and restore old be…
Dobby233Liu Jan 18, 2025
3c2176f
Restore accidentally removed VisibleIfNotNull converter in MainWindow
Dobby233Liu Jan 18, 2025
d33c31f
Fix BGND reading & AGRP child object count miscounting
Dobby233Liu Jan 18, 2025
c1fe7da
Improve UndertaleResourceById handling regarding deleted objects
Dobby233Liu Jan 18, 2025
475643e
Fix UTFont estimated child object count in 2024.11+
Dobby233Liu Jan 18, 2025
97e5285
Add hidden setting ShowNullEntriesInDataHierarchy (disabled by default)
Dobby233Liu Jan 18, 2025
f61b170
Clarify ResourceById resource == null && cachedid >= 0 error
Dobby233Liu Jan 19, 2025
60caf58
Raise 2024.11 detection requirement to GMS2, better approach for null…
Dobby233Liu Jan 21, 2025
d1da607
Forgot to use old CachedId if the resource ocuppying the slot is stil…
Dobby233Liu Jan 21, 2025
a1fbca9
Check list boundary and fix typo
Dobby233Liu Jan 21, 2025
3633d1e
Try handling null in AddAssetsFromList
Dobby233Liu Feb 5, 2025
6db9587
Try handling null in GlobalDecompileContext
Dobby233Liu Feb 5, 2025
05cb9e7
Properly detect UnknownAlwaysZero in UTFont
Dobby233Liu Feb 16, 2025
aff5517
Cleanup
Dobby233Liu Feb 16, 2025
612b98c
Cleanup, properly calculate next glyph position, better safe than sorry
Dobby233Liu Feb 16, 2025
9e18dd6
Make the comment more coherent
Dobby233Liu Feb 16, 2025
e89d794
I promise this is the last cleanup
Dobby233Liu Feb 16, 2025
392ae25
Fix my broken XML comments
Dobby233Liu Feb 16, 2025
4723e12
Transform gm2024_11_WhatToSkip to BitArray
Dobby233Liu Feb 16, 2025
3958ec8
Null detection attempt
Dobby233Liu Feb 16, 2025
d5f7638
Forgot about this
Dobby233Liu Feb 16, 2025
c057ef9
Null adaptation 2: Parallel.ForEach flavor
Dobby233Liu Feb 16, 2025
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
Prev Previous commit
Next Next commit
Cleanup, properly calculate next glyph position, better safe than sorry
Dobby233Liu committed Mar 7, 2025
commit 612b98c1c9333fdbdb1990aa7193178d2155c9c1
25 changes: 14 additions & 11 deletions UndertaleModLib/UndertaleChunks.cs
Original file line number Diff line number Diff line change
@@ -791,9 +791,10 @@ Checking a shorter range narrows possibility of error.
return;
}

long positionToReturn = reader.Position, startAbsPosition = reader.AbsPosition;
long positionToReturn = reader.AbsPosition;
bool GMS2023_6 = false;
bool GMS2024_11 = false;
// When this is set to true the detection logic will not run again
bool GMS2024_11_Failed = false;

uint possibleFontCount = reader.ReadUInt32();
@@ -812,9 +813,10 @@ Checking a shorter range narrows possibility of error.
}
if (firstAndNextFontPointers.Count == 1)
{
// Add in the position of the padding
firstAndNextFontPointers.Add(startAbsPosition + Length - 512);
// Add in the position of the padding i.e. the end of the font list
firstAndNextFontPointers.Add(positionToReturn + Length - 512);
}

if (firstAndNextFontPointers.Count > 0)
{
reader.AbsPosition = firstAndNextFontPointers[0] + 52; // Also the LineHeight value. 48 + 4 = 52.
@@ -823,7 +825,7 @@ Checking a shorter range narrows possibility of error.

uint glyphsLength = reader.ReadUInt32();
GMS2023_6 = true;
if (glyphsLength * 4 > Length)
if (glyphsLength * 4 > (firstAndNextFontPointers[1] - reader.AbsPosition))
{
GMS2023_6 = false;
}
@@ -837,10 +839,9 @@ Checking a shorter range narrows possibility of error.
throw new IOException("One of the glyph pointers is null?");
glyphPointers.Add(glyphPointer);
}
// Hopefully the last thing in a UTFont is the glyph list
long pointerAfterFirstGlyph = glyphPointers.Count > 1 ? glyphPointers[1] : firstAndNextFontPointers[1];
foreach (uint pointer in glyphPointers)
for (int i = 0; i < glyphPointers.Count; i++)
{
uint pointer = glyphPointers[i];
if (reader.AbsPosition != pointer)
{
GMS2023_6 = false;
@@ -854,15 +855,17 @@ Checking a shorter range narrows possibility of error.
{
if (!GMS2024_11)
{
// Hopefully the last thing in a UTFont is the glyph list
long pointerNextGlyph = i < (glyphPointers.Count - 1) ? glyphPointers[i + 1] : firstAndNextFontPointers[1];
// And hopefully the last thing in a glyph is the kerning list
long pointerAfterKerningList = reader.AbsPosition + 4 * kerningLength;
// If we won't land into the next glyph just right
if (pointerAfterKerningList != pointerAfterFirstGlyph)
if (pointerAfterKerningList != pointerNextGlyph)
{
kerningLength = reader.ReadUInt16(); // Discard last read
pointerAfterKerningList = reader.AbsPosition + 4 * kerningLength;
if (pointerAfterKerningList != pointerAfterFirstGlyph)
throw new IOException("Detected that there are more/less values than UnknownAlwaysZero before the kerning list");
if (pointerAfterKerningList != pointerNextGlyph)
reader.SubmitWarning("There appears to be more/less values than UnknownAlwaysZero before the kerning list in a UTFont.Glyph - potential data loss");
GMS2024_11 = true;
}
else
@@ -889,7 +892,7 @@ Checking a shorter range narrows possibility of error.
if (!reader.undertaleData.IsVersionAtLeast(2023, 6))
reader.undertaleData.SetGMS2Version(2023, 6);
}
reader.Position = positionToReturn;
reader.AbsPosition = positionToReturn;

checkedFor2023_6And2024_11 = true;
}