Repository navigation
Refactor: Read the archive and squash offsets as members - #7650
Merged
Merged
Conversation
Collaborator
|
Merged, thank you giveen, and welcome back! All 95 functions in the seven touched files MATCH, and place.py gives the shipped MD5 both with the original exe and with A few small things for a later pass, none of them blocking:
|
This was referenced Nov 14, 2026
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #7078
Model: Ares / claude-opus-5
Rewrites the 7 byte-offset accesses in
src/utilthat the issue counts, and 2 more it does not see because their offset is a variable.tools/rewrite_offsets.py --dry-runnow reports 0 rewrites for all four files.Adds
src/util/archive_directory.h, oneArchiveDirectoryview (int count; ArchiveEntry* entries;), and includes it in the fourutil/files that each carried an identical copy:hpi_4be320.cpp,hpi_4bb4e0.cpp,hpi_4bc800.cppandhpi_4bd830.cpp. That is the rule-2 fold for this folder.The name is evidence-based:
data/thaldren/structs.csvhas ThaldrensHPI_DirectoryEntryfor the sibling 9-byte entry record, whichsrc/util/archive_entry.halready namesArchiveEntry, and the directory header is the block that count and offset live in.countis the entry count andentriesthe offset of the first one from the archive base, which is what the rewrites show: the count is multiplied by 9 (the entry size) to size the new block, and read back as the loop bound.Two accesses the issue does not count:
*(unsigned int*)(base + root) = 0and++(*(unsigned int*)(base + root))in 0x4bd3b0. The issue counts(char*)p + <constant>, so a variable offset is invisible to it, but they are the samecountfield as the constant-offset read three lines below, and leaving them would have kept the field half-named.Checks: checkall 95 of 95 MATCH (every function in
hpi.cpp,hpi_4be320.cpp,hpi_4bb4e0.cpp,hpi_4bc800.cpp,hpi_4bd830.cpp,sqsh.cppandregistry.cpp); place.py MD5 8e74a1dffa1f5988624c52048f5b20cd, with and without--no-orig --strict; modules.py --check passes; cleanup_progress.py byte-offset count 62 to 53Left out:
ArchiveDirectorycopy inhpi.cppstays local, with the reason at its declaration. Folding it too costs that file 4 symbol ids and drops 0x4bb2e0 (HAPI_OpenArchive) to 94.5% and 0x4bd160 (HAPI_CloseArchive) to 99.1%.tools/idpad.pyfinds no set of real unused declarations that brings them back, and adding a fake one is what the rule forbids. Four files share the header, so the duplicate is down from five copies to two.*(unsigned int*)(base + 8)in 0x4bd830, the archives own header. Nothing insrc/declares that block anddata/thaldren/structs.csvhas no name for it, so there is no member to write; it is the only access in the folder with no struct to point at.*(char*)(a + 1)in 0x4b6820 (CompareByte1Equal) stays. The tool cannot rewrite it and neither can I: the function has no callers insrc/, so its parameters keep theintthatdata/progress.csvrecords for the decorated name, andint + 1advances 4 bytes. Changing the parameters tochar*to geta[1]would change the arithmetic.Suspected original bugs:
CompareByte1Equal): it compares only the length byte, so it reports two registry values equal when their bytes differ. Nothing insrc/calls it, so I cannot tell whether the callers wanted a length-only test; the name says otherwise.