Recognize fragments with null optional header pointers #8
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/breadbbbb--rpf9-explorer!8
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/8/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@cxchhh on GitHub · 2026-11-22 03:24 UTC · original
cxchhh:codex/fragment-header-optional-pointers→main· +14 −5 · 1 files · 2 commits · merged 2026-11-22 09:44 UTCWhy
LooksLikeFragmentrequires the pointers at+16,+32and+40to be system pointers. It also requires the four 16-bit fields at+48..+54to form two equal count/capacity pairs. Neither rule holds for most fragments in the package. Fragments that fail the check never become scan candidates, so no change to recovery or decoding can reach them.Measured over every resource in
levels.rpfthat an independent carving index (SixNG, which types resources by their recovered.#ft/.#drnames) labels as a fragment (50,802):+8,+24,+168are system pointers+16,+32,+40all system pointers+16,+32,+40all null+48 == +50and+52 == +54+48in 1..4096,+50≤ 4096,+52≤+54≤ 4096+50can be larger than+48(642 fragments), and+54is often larger than+52, so these fields are not count/capacity pairs.Change
+8(page map),+24(drawable) and+168(name) required.+16,+32and+40. A non-null value must still be a system pointer.+52 <= +54order.Decoding still validates the embedded drawable at
+24, so a looser header check costs at most a rejected decode. Over all 326,112 resources inlevels.rpf, the new rule matches no resource the index types as a drawable, texture dictionary or anything else (0 false positives). Drawables are tested before fragments, as before.Results
Measured against current
main(917e9b9, which includes #1 and drawable dictionaries).Across the ten archives that Leonida scans, each decoder using its own scanner, as resources recovered / candidates:
917e9b9917e9b9+ this PRdata.rpfpack/shared_minigame000pack/core_restofworldpacks.rpfpack/story000levels.rpftextures.rpf,story000_restofworldThe candidates that do not recover at
917e9b9are mostly texture dictionaries; #9 removes them.A drawable dictionary counts once in this table, however many drawables it holds. The difference comes entirely from fragments:
levels.rpf: 28,743 more fragments decode, all with real geometry: about 98M vertices and 99M triangles. About 23,000 of them have more than 100 triangles. On the 50,802 resources that an independent carving index (SixNG, which types resources by their recovered.#ftnames) labels as fragments, recovery goes from 21,497 to 50,241 (98.9%).data.rpf: 594 more fragments decode, all with real geometry.packs.rpf: every fragment there decodes to the same 25-vertex, 32-triangle mesh, so the 2,551 extra fragments there add no real geometry. poke900310-lgtm noted this in ItsNotRexed/Leonida#29; the real geometry of those fragments is elsewhere.The remaining 561 fragments in
levels.rpfare rejected later, inReadMesh, and this PR does not change them:Tests
mainignoresTests/, so the test project is not part of this PR. The code is below so it can be run locally: copy both files toTests/FragmentHeaderSmoke/and rundotnet run --project Tests/FragmentHeaderSmoke -c Release.The test builds a fragment around a one-triangle embedded drawable. It covers:
+50 > +48with+52 < +54;+52 > +54, of+48 = 0, of a non-null+32that is not a system pointer, and of a null drawable pointer.Without the fix, the test fails at "fragment with null +16, +32 and +40". With the fix, it passes on
917e9b9. The fixture is generated in code and contains no game data.Tests/FragmentHeaderSmoke/FragmentHeaderSmoke.csprojTests/FragmentHeaderSmoke/Program.csTesting environment
Tested on Linux x64 with .NET SDK 8.0.428, CPU only.
Corebuilds with warnings as errors. I could not build the Windows app (App, .NET 10 Windows) on this machine, and this PR does not touch it.AI-assisted: an AI agent (Claude, Anthropic) did the investigation, code, tests and measurements on the author's behalf. No game data is included here.
🤖 Generated with Claude Code
@cxchhh on GitHub · 2026-11-22 08:09 UTC · original
A downstream measurement, in case it helps with review. Leonida's placement-driven world build (ItsNotRexed/Leonida#1183) resolves each map placement to an exported model. In a 700 m × 700 m downtown box of
levels.rpfthere are 29,258 HD placements:917e9b9(Leonida's current pin), 10,729 of them (36.7%) find a recovered model;The names resolve either way, and every match is confirmed by the 64-bit archetype key. The missing ~1,800 archetypes are all
.#ftfragments, so the gap is in fragment recovery, the part this PR changes. I didn't measure #8 alone in that box. Over the ten archives, #8 by itself added 31,934 models.