Repository navigation
Refactor: Share the HPI archive views - #7651
Merged
Merged
Conversation
Collaborator
|
Merged, thank you giveen! Checked together with #7652: all 181 functions in the touched files MATCH, and place.py gives the shipped MD5 both with the original exe and with |
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
Takes
src/utilto zero counted byte-offset accesses, and folds the two HPI archive views that the folder duplicated.*(int*)(8 + base)in 0x4bd830 (HAPI_WriteArchiveData) becomes(int)((Header*)base)->size.src/util/hpi_header.h, oneHeader(the 0x14-byte archive header: magic, version, size, obfuscate flag, directory offset), and includes it inhpi.cppandhpi_4bd830.cpp, which each carried an identical copy.hpi.cppnow also includes thearchive_directory.hthat Refactor: Read the archive and squash offsets as members #7650 added, soArchiveDirectoryhas one declaration for the whole folder instead of five copies becoming two.Both folds cost
hpi.cpp4 symbol ids, and 0x4bb2e0 (HAPI_OpenFile) and 0x4bd160 (HAPI_CloseFile) only match again with filler:tools/idpad.pyfinds no set that works without the four declarations now above the views. They are real functions that other files already declare the same way (ProtectUnitDefsReadOnlyandProtectUnitDefsReadWritein 25 places includingsrc/units/unit.cppandsrc/orders/order_targets.cpp;SetMemFussyDefaultandIsMemFussyin 32 includingsrc/graphics/draw.cppandsrc/gui/dialogs.cpp), andhpi.cppalready carried an "Unused here" block of the same kind for 0x4bb190. The comment above them says which two functions they hold.This corrects the last "Left out" bullet of #7650, which said the
base + 8access had "no struct to point at". That was wrong:hpi_4bd830.cppalready declared the archive header asHeaderwithunsigned int sizeat +0x8, andhpi.cppnamed the same blockHeadertoo. I had searched for a type named after an archive instead of for the name the file already uses.Checks: checkall 240 of 240 MATCH (every function in all 14
src/utilfiles); place.py MD5 8e74a1dffa1f5988624c52048f5b20cd, with and without--no-orig --strict; modules.py --check passes; cleanup_progress.py byte-offset count 56 to 55, andtools/rewrite_offsets.py --dry-runreports 0 rewrites for every file in the folderThe layout is the same inside and outside the
pack(1)region (hpi_4bd830.cppincludes the header inside it,hpi.cppoutside it): magic 0, version 4, size 8, obfuscate 0xc, unknown_d 0xd, list 0x10, total 0x14 either way, which is what the field comments already said. Neither file includesgraphics/gaf.h, which has its own unrelatedHeader.Left out:
TdfFieldListintdf_4c3120.cppandtdf_4c51b0.cpphas the same body in both, but cannot share a header:tdf_4c51b0.cppdeliberately declaresTdfFielddifferently (itsnextis aTdfEntry*and it carries akey), and the issue says a view that disagrees with the definition stays out. OneTdfFieldListwould bind to two different element types.OPENHAPIFILEandOpenHapiFileare the same block inhpi.cppandhpi_4bd830.cppunder two spellings. Folding them means picking one spelling for both files, which is a rename rather than a gather, and Clean-up: rewrite the byte-offset accesses left #7078 asks for offset rewrites only.Suspected original bugs: