Repository navigation
fix(extractor): duplicate asset-index entries race in loose output - #215
Merged
999sian merged 1 commit intoOct 20, 2026
Merged
Conversation
… extraction Nine paths are indexed twice with different sizes, so loose extraction raced. Keep the largest, matching PakBuilder::Write, so loose output is deterministic and packed output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Result: loose extraction (the editable
assets_src/tree modders work in, and--loose-assets) is deterministic again, and matches the packed cache. The packed cache players use is unchanged: it already resolved duplicates deterministically.Files:
tools/src/assets_extractor/assets_extractor.hppCause
The generated
port/port_asset_index.clists 9 paths twice, at the same offset but with different sizes:assets/*.jsonhas per-region entries for those files and the generator keeps both. The tilemap, gfx and sweep passes extract every entry in parallel, so two threads write one loose file and the last to finish wins. Two runs of the same build produced differentassets_src/trees.Packed output was never affected:
PakBuilder::Writealready sorts duplicates and keeps the largest. The room maps the game loads come from the area-table pass, which sizes each one by its real LZ stream, so they were correct either way. Picking the smaller copy would truncate three of these room maps (2, 21 and 15 bytes short of their stream), but thosetilemaps/copies aren't read at runtime.Change
unique_asset_index_entries()resolves each path to one entry before any parallel work, keeping the largest, which is the same rule asPakBuilder::Write. Loose and packed output then agree, and packed output is byte-identical to before. The largest copy holds the full compressed stream for every duplicate (checked against the USA ROM). The single-threadedbuild_embedded_asset_lookupis left as is.The generated index itself isn't edited: it says "DO NOT EDIT MANUALLY", and
tools/generate_asset_index.pyisn't in the repo. Since the index's offsets are USA-baseline, the generator could keep only the USA entry per path.Tested
Windows, with retail USA, EU and JP ROMs (SHA-1s match
tmc*.sha1):Developed with assistance from Claude Code (Opus 5.5). I reviewed and tested the changes as described above.