Skip to content

world_archetypes: read CMapTypes archetype definitions; check map extents (BUILD-557) - #2329

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
leozinhoszg:world-archetypes
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
leozinhoszg:world-archetypes

Conversation

@leozinhoszg

Copy link
Copy Markdown
Contributor

BUILD-557.

What

tools/world_archetypes.py reads archetype definitions from CMapTypes resources (the .ytyp role):
CBaseArchetypeDef, CMloArchetypeDef and CTimeArchetypeDef, every field found by its case-sensitive joaat
in the resource's own member table, the way world_index.py reads CEntityDef. Output: name, assetName,
assetType, bbMin/bbMax, bsCentre/bsRadius, lodDist, hdTextureDist, flags, the dictionary hashes,
plus the member table of each archetype struct seen. It imports world_index and world_census and changes
neither, so it stays clear of #1981.

--check-extents rebuilds each map's entitiesExtentsMin/Max from its entities' archetype boxes, for every
map whose entities all have a definition in the window, and compares stored vs conjugated quaternion and
with vs without scale.

Measured (levels.rpf, 8–9 GiB window, package 1.0.2.1)

  • 119 CMapTypes resources, 31,800 definitions (31,785 base, 15 interior), 14,955 names; duplicate names always
    carry the same box.
  • Rotation, 827 fully-defined maps with a rotated entity: the conjugated quaternion reproduces the stored
    extents in 616 (median error 0.16 mm), the stored quaternion in 236 (0.63 m). The union never exceeds the
    stored extents (827/827). This backs the conjugate rule already in docs/world.md with box geometry.
  • Scale, 179 maps with a scaled entity: 155 match without scale, 101 with scale; with scale 41 unions exceed
    the stored extents, without scale none. So the extents are computed without the entity scale. The scale
    rule for rendering is left as it is.
  • assetType against the names rpf9_names.py --types dr,ft,dd lists in all of levels.rpf: type 1 →
    3,611/3,614 .#ft, type 2 → 8,681/8,689 .#dr, type 3 → 2,327/2,637 .#dr, type 0 = the 15 interiors; no
    name crosses between 1 and 2. Type 3 as the drawable-dictionary type is written down as an inference.

Tests

  • python -I tests/test_world_archetypes.py: 13 tests on synthetic resources (fields found by hash under two
    different layouts, kinds, malformed blocks, transforms, the extents check with a known answer, the CLI on a
    folder of carved files and on a minimal RPF9). No game data.
  • test_world_index.py, test_world_census.py, test_docs_links.py, test_text_write_line_endings.py and
    compileall pass. Python 3.13 on Windows 11; no GPU involved.
  • The measurements above were run on the retail package locally; nothing from it is in the PR.

AI-assisted (Claude Code).

…ents (BUILD-557)

tools/world_archetypes.py reads the archetype structs of CMapTypes resources
(CBaseArchetypeDef, CMloArchetypeDef, CTimeArchetypeDef) by member hash, the
way world_index.py reads CEntityDef: name, assetName, assetType, bbMin/bbMax,
bsCentre/bsRadius, lodDist, flags. It imports world_index and world_census and
changes neither, so it does not touch the lines ItsNotRexed#1981 changes.

--check-extents rebuilds each fully-defined map's entitiesExtents from the
transformed archetype boxes. In levels.rpf 8-9 GiB the conjugated quaternion
reproduces 616 of 827 rotated maps (median error 0.16 mm), the stored one 236
(0.63 m), and the extents are computed without the entity scale.

docs/world.md: the member table, assetType measured against rpf9_names.py
(1 = fragment, 2 = drawable, 3 = drawable-like, no crossover), and the two
extents checks. Synthetic tests only, no game data.
@mrp1no

mrp1no commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Independent check of cf021320e5f2bc407eca78f386ffe64ed4a0229f on my own Xbox Series 1.0.2.1 copy (Windows 11 Pro 26300, Python 3.15.2, CPU only): pass, every measured count reproduces exactly.

python -I tools/world_archetypes.py levels.rpf --start 8589934592 --limit 1073741824 --check-extents --out <local> (34 s):

PR mine
CMapTypes resources 119 119
definitions (base / interior) 31,800 (31,785 / 15) 31,800 (31,785 / 15)
names, names with differing boxes 14,955, 0 14,955, 0
rotated maps: conjugate / stored match 616 / 236 of 827 616 / 236 of 827 (211 neither)
median error conjugate / stored 0.16 mm / 0.63 m 0.159 mm / 0.627 m
union inside extents (conjugate) 827/827 827/827
scaled maps: match without / with scale 155 / 101 of 179 155 / 101 of 179
exceed extents with / without scale 41 / 0 41 / 0

assetType totals in the window: 0 → 15, 1 → 10,765, 2 → 18,383, 3 → 2,637. Not reproduced: the cross-check against rpf9_names.py --types dr,ft,dd over the whole archive.

tests/test_world_archetypes.py (13) and tests/test_world_index.py pass. Nothing from the package is attached. AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit 9994327 into ItsNotRexed:main Nov 22, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants