Index: keep a resource whose system page continues on a resource boundary in one entry (index version 6) #156

Manually merged
github merged 2 commits from gh-pr/156/head into gh-pr/156/base 2026-11-26 20:14:01 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 13:45 UTC · original
holdmysocks:claude/index-split-resources → master · +95 −4 · 4 files · 2 commits · merged 2026-11-24 14:14 UTC

Follow-up to #149 (SIX-98). A full texture dictionary export still gave 11 "texture data out of range" warnings, all from one levels entry. The cause is in the carving index, not in the texture decoding.

Cause

group_streams starts a new entry when a contiguous RAGE-object stream begins on a 4 KiB + 0x10 boundary. A resource's later system-page stream can land on such a boundary by chance.

The entry in question shows this:

  • Its first stream inflates to 0x30000 bytes, but its page-map pointer is 0x50031000, so the system page goes on.
  • The index ended that entry after the first stream. The rest (a second system stream and two graphics streams) became a separate "drawable" with no models.
  • The leftover first part was taken for a texture dictionary, because of the embedded tint palettes, and its texture offsets pointed into graphics pages it did not have.

Fix

Grouping keeps adding contiguous streams while the entry's page-map pointer (+0x08 of its first stream) lies past the bytes it has. The loader already reads multi-stream system pages that way.

Effect (all archives, regrouped from the cached stream scans with examples/regroup)

  • 22 entries change, nothing else:
    • 20 in levels.rpf;
    • one in anim.rpf;
    • one in story000.rpf.
  • The 20 levels entries are map models. Each was split into an untyped head and a "drawable" with 0 models. Now each loads as one drawable with 1–2 models and 24–206 geometries. The one that was taken for a texture dictionary has 13 models.
  • Full texture dictionary export on a rebuilt levels index: 0 warnings and 0 errors, from 2,365 dictionaries (before: 11 warnings, from 2,366 dictionaries counting the false one).

Index version 6 (separate commit)

  • Existing indexes keep the split until they are rebuilt, so the second commit bumps INDEX_VERSION, as #8 did.
  • Every work folder then needs sixng index. With the cached stream scans, the levels.rpf rebuild (grouping and names) took 6 min here.
  • If the bump should wait or ship separately, drop that commit.

Checks: a unit test for the split case. cargo test -p sixng-core: 163 pass. The workspace builds.

**@⁠holdmysocks** on GitHub · 2026-11-24 13:45 UTC · [original](https://github.com/holdmysocks/SixNG/pull/156) `holdmysocks:claude/index-split-resources` → `master` · +95 −4 · 4 files · 2 commits · merged 2026-11-24 14:14 UTC Follow-up to #149 (SIX-98). A full texture dictionary export still gave 11 "texture data out of range" warnings, all from one levels entry. The cause is in the carving index, not in the texture decoding. ## Cause `group_streams` starts a new entry when a contiguous RAGE-object stream begins on a 4 KiB + 0x10 boundary. A resource's later system-page stream can land on such a boundary by chance. The entry in question shows this: - Its first stream inflates to 0x30000 bytes, but its page-map pointer is 0x50031000, so the system page goes on. - The index ended that entry after the first stream. The rest (a second system stream and two graphics streams) became a separate "drawable" with no models. - The leftover first part was taken for a texture dictionary, because of the embedded tint palettes, and its texture offsets pointed into graphics pages it did not have. ## Fix Grouping keeps adding contiguous streams while the entry's page-map pointer (+0x08 of its first stream) lies past the bytes it has. The loader already reads multi-stream system pages that way. ## Effect (all archives, regrouped from the cached stream scans with `examples/regroup`) - 22 entries change, nothing else: - 20 in levels.rpf; - one in anim.rpf; - one in story000.rpf. - The 20 levels entries are map models. Each was split into an untyped head and a "drawable" with 0 models. Now each loads as one drawable with 1–2 models and 24–206 geometries. The one that was taken for a texture dictionary has 13 models. - Full texture dictionary export on a rebuilt levels index: 0 warnings and 0 errors, from 2,365 dictionaries (before: 11 warnings, from 2,366 dictionaries counting the false one). ## Index version 6 (separate commit) - Existing indexes keep the split until they are rebuilt, so the second commit bumps `INDEX_VERSION`, as #8 did. - Every work folder then needs `sixng index`. With the cached stream scans, the levels.rpf rebuild (grouping and names) took 6 min here. - If the bump should wait or ship separately, drop that commit. Checks: a unit test for the split case. `cargo test -p sixng-core`: 163 pass. The workspace builds.
A contiguous RAGE-object stream that starts on a 4 KiB + 0x10 boundary
began a new entry even when the previous resource's page-map pointer lay
past the system page it had so far. 22 resources were split in two
(20 map models in levels.rpf, one in anim.rpf, one in story000.rpf): the
head became an untyped entry and the rest a drawable with no models, or a
texture dictionary whose texture data was out of range (the 11 warnings of
a full texture dictionary export). Grouping now continues while the
page-map pointer is not yet covered.

examples/regroup: regroup an archive's cached streams and list the entries
that change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:13:58 +00:00
github manually merged commit 593c106044 into gh-pr/156/base 2026-11-26 20:14:01 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.