OLD-7482: restore old upstream PR 7482 - instance_lists, world_interior_names, world_lights_paths: read the block number from 20 bits #717

Manually merged
github merged 2 commits from gh-pr/717/head into gh-pr/717/base 2026-11-26 09:17:48 +00:00
Owner

@⁠aslan2142 on GitHub · 2026-11-24 12:50 UTC · original
aslan2142:resource-pointer-width → main · +59 −14 · 10 files · 2 commits · merged 2026-11-25 22:25 UTC

Claimed in the coordination issue as: OLD-7482 #14

Restoration of my original pull request, old upstream PR 7482 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 51f3160923; the two commits cherry-picked without conflicts and are unchanged.

What and why

  • A resource pool pointer keeps its 1-based block number in the low 20 bits and the byte offset from bit 20 (docs/psin.md, docs/ped_catalogues.md, tools/psin_data.py).
  • instance_lists and world_interior_names masked only 12 bits, as docs/world.md said. A block number of 4,096 or more would be read as the wrong block.
  • world_lights_paths (Meta.ref) also read 12 bits. It refused any pointer with bits 12-19 set as a pool reference, so a pointer to block 4,096 or above fell through to the system-pointer path.
  • New world_index.split_pointer is now the one decoder for all three tools and for world_index itself, which already read 20 bits inline.
  • docs/world.md and docs/world_lights_paths.md now give the 20-bit form.
  • On the game's current resources, bits 12-19 are always zero, so the tools' reported counts don't change. The fix matters for a resource with 4,096 blocks or more.
  • One synthetic test per tool covers a block number above 4,095, and split_pointer has its own test.
  • Draft #315 (old-pr/10049) touches tools/instance_lists.py, tests/test_instance_lists.py and docs/world.md too; git merge-tree finds no conflict with it.

Tested

Linux, Python 3.14, CPU only, synthetic inputs only (no game files).

  • main with only this PR's tests added: the 4 new tests fail (3 FAIL, 1 ERROR).
  • This branch, standalone with python -I:
    • tests/test_instance_lists.py: 17 tests OK.
    • tests/test_world_index.py: 47 tests OK (5 skipped, as on main).
    • tests/test_world_interior_names.py: 28 tests OK.
    • tests/test_world_lights_paths.py: 32 tests OK (1 skipped, as on main).
  • python -m compileall -q tools tests, git diff --check and python -I scripts/check_no_game_data.py on the 10 changed files: clean.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 12:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/717) `aslan2142:resource-pointer-width` → `main` · +59 −14 · 10 files · 2 commits · merged 2026-11-25 22:25 UTC Claimed in the coordination issue as: OLD-7482 https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 Restoration of my original pull request, old upstream PR 7482 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 51f31609236a952badeb9c9aba9efc2a6e4dc2ff; the two commits cherry-picked without conflicts and are unchanged. ### What and why - A resource pool pointer keeps its 1-based block number in the low 20 bits and the byte offset from bit 20 (`docs/psin.md`, `docs/ped_catalogues.md`, `tools/psin_data.py`). - `instance_lists` and `world_interior_names` masked only 12 bits, as `docs/world.md` said. A block number of 4,096 or more would be read as the wrong block. - `world_lights_paths` (`Meta.ref`) also read 12 bits. It refused any pointer with bits 12-19 set as a pool reference, so a pointer to block 4,096 or above fell through to the system-pointer path. - New `world_index.split_pointer` is now the one decoder for all three tools and for `world_index` itself, which already read 20 bits inline. - `docs/world.md` and `docs/world_lights_paths.md` now give the 20-bit form. - On the game's current resources, bits 12-19 are always zero, so the tools' reported counts don't change. The fix matters for a resource with 4,096 blocks or more. - One synthetic test per tool covers a block number above 4,095, and `split_pointer` has its own test. - Draft #315 (`old-pr/10049`) touches `tools/instance_lists.py`, `tests/test_instance_lists.py` and `docs/world.md` too; `git merge-tree` finds no conflict with it. ### Tested Linux, Python 3.14, CPU only, synthetic inputs only (no game files). - `main` with only this PR's tests added: the 4 new tests fail (3 FAIL, 1 ERROR). - This branch, standalone with `python -I`: - `tests/test_instance_lists.py`: 17 tests OK. - `tests/test_world_index.py`: 47 tests OK (5 skipped, as on `main`). - `tests/test_world_interior_names.py`: 28 tests OK. - `tests/test_world_lights_paths.py`: 32 tests OK (1 skipped, as on `main`). - `python -m compileall -q tools tests`, `git diff --check` and `python -I scripts/check_no_game_data.py` on the 10 changed files: clean. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5).
A 0DRP/PSIN pool pointer keeps the 1-based block number in its low 20 bits
and the byte offset above (docs/psin.md, docs/ped_catalogues.md, psin_data).
instance_lists and world_interior_names masked 12 bits, as docs/world.md
said, so a block number of 4,096 or more would have been read as a wrong block.

world_index.split_pointer is now the one decoder for the three tools, and
docs/world.md gives the 20-bit form. Over the 0x7a resources of levels.rpf,
story000.rpf, shared_minigame000.rpf and packs.rpf (232,846), the most blocks
one has is 1,760, and every non-null 0x52 array and 0x42 string pointer has
bits 12-19 at zero, so the counts the tools report don't change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Meta.ref took the block number from bits 0..11 and refused any value with
bits 12-19 set as a pool reference, so a pointer to block 4,096 or above
fell through to the system-pointer path. Those bits are the high bits of the
20-bit block number. The guard did not screen system pointers either: with
fewer than 4,096 blocks, a value with bits 12-19 set has a 20-bit block number
above the block count, so it still reaches the system-pointer path.

Over levels.rpf (188,449 0x7a resources, 8,576 with lights) the summary is
byte-identical with the old and the new decoder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:17:46 +00:00
github manually merged commit 0cbc40239b into gh-pr/717/base 2026-11-26 09:17:48 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:25 UTC · original · approved these changes

Audited and verified. Clean-room compliant.

  • Reads block numbers from 20 bits across instance_lists, world_interior_names, world_lights_paths via world_index.split_pointer.
  • Supports resources with >4096 blocks per psin.md and world.md specifications.
  • Regression tests in tests/test_instance_lists.py, test_world_index.py, test_world_interior_names.py PASS.
**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/717#pullrequestreview-6039983841) · **approved these changes** Audited and verified. Clean-room compliant. - Reads block numbers from 20 bits across instance_lists, world_interior_names, world_lights_paths via world_index.split_pointer. - Supports resources with >4096 blocks per psin.md and world.md specifications. - Regression tests in tests/test_instance_lists.py, test_world_index.py, test_world_interior_names.py PASS.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:25 UTC · original

Merged: instance_lists, world_interior_names, world_lights_paths read the block number from 20 bits.

  • Changed since review: Nothing. It merges cleanly with main, and no review point is open.
  • Tested: test_instance_lists, test_world_index, test_world_interior_names and test_world_lights_paths pass on main + this head (Linux, CPython 3.14).
  • Checked on main 581ddba5d + 0cbc40239: the semantic suite passes (492 files, 6,315 tests, 0 files failed); test_instance_lists, test_world_index, test_world_interior_names, test_world_lights_paths pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 10 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 22:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/717#issuecomment-7176341417) Merged: `instance_lists`, `world_interior_names`, `world_lights_paths` read the block number from 20 bits. - **Changed since review:** Nothing. It merges cleanly with `main`, and no review point is open. - **Tested:** `test_instance_lists`, `test_world_index`, `test_world_interior_names` and `test_world_lights_paths` pass on `main` + this head (Linux, CPython 3.14). - **Checked on `main` `581ddba5d` + `0cbc40239`:** the semantic suite passes (492 files, 6,315 tests, 0 files failed); `test_instance_lists`, `test_world_index`, `test_world_interior_names`, `test_world_lights_paths` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 10 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.