Commit Graph

13 Commits

Author SHA1 Message Date
2a384e13f7 gamedata_maps: support UTF-8 BOM index.json, validate row fields, and write JSON atomically (GAMEDATA-MAPS-INDEX-AND-ATOMIC-IO) 2026-11-25 04:26:19 +01:00
8ce588721e gamedata_maps: name the index in a malformed-carve error (#6723)
Squash-merged after diff review of PR #6723 - gamedata_maps: name the index when its files list is missing
2026-11-23 10:02:20 -06:00
b23779d6a9 tests: pass errors=replace to subprocess pipes capturing python -I tools 2026-11-23 00:42:37 +02:00
c1d9a92f54 Merge pull request #2193 from Rafael 2026-11-22 11:42:39 -05:00
52d70c4b60 gamedata_index, gamedata_maps: a resource continues after any whole number of 64 KiB blocks (BUILD-599)
Both tools joined a following stream only after an exactly 65,536-byte one, the rule #2129 fixed in
text_tables. A resource's first stream can be 128 or 192 KiB (docs/page_directory.md).
- gamedata_index: only the headed `other` branch (0DRP pages and the MAGIC kinds) now continues after
  any nonzero multiple of 64 KiB. Binary, text and XML runs keep the exact rule, since nothing proves a
  continuation there; applying the multiple rule to them too folded 26,284 payloads into 25,000.
- gamedata_maps: the join is already bounded by the header's declared size, so any whole number of
  64 KiB blocks may continue.

Real data (counts only), data.rpf: 0DRP pages keep 15,768 payloads and gain the 50 continuation streams
(15,877 -> 15,927). Those 50 streams stop being separate payloads (43 `binary`, 7 `text`), so the
payloads go 26,284 -> 26,234; psin/rbf0 unchanged. gamedata_maps on two carves without heightmaps:
identical output.

Tests: test_a_resource_continues_after_any_whole_number_of_64k_blocks (a 128 KiB 0DRP page joins its
continuation, a 128 KiB binary run does not) and test_groups_a_continuation_after_a_128k_first_stream
(main: all fail).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:14:33 -03:00
6079e80392 gamedata_maps: report paths create their folder and cannot overwrite inputs
Validate --json before scanning <carve_dir> (and again against index.json rows): refuse existing directories and paths colliding with <carve_dir>, <carve_dir>/index.json, or any carved .bin stream (including symlinks, hard links, Windows verbatim prefixes, and macOS APFS/NFD case-only variants). Create missing parent folders before writing JSON with LF line endings. Adds unit tests in tests/test_gamedata_maps.py. No game files.
2026-11-22 16:51:34 +01:00
ec2bfdec9a gamedata_maps.py: reject non-finite grid bounds 2026-11-22 13:02:23 +01:00
e49d2a440d gamedata_maps: report JSON output write errors 2026-11-22 04:39:35 -03:00
cd6ade80c9 Gamedata: PAMH 0x08 is padding, add a tile census (ASSET-58) 2026-11-22 00:06:28 -03:00
c9ef98d7ae Gamedata: identify the MHIU 0x28 field as the default height (ASSET-48)
Byte 0x28 is a u8 default height: 23 in both MHIU payloads, the value the
empty rows hold, and the value the encoder crops each row by (0 of 6,902
span ends are 23 although 23 is 82% of cells). The decoder now reads the
default from the header, reports the three following bytes as pad_29 and
counts span ends on the default. A scan of all 12 archives finds 2 MHIU
payloads, both in common.rpf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:26:40 +00:00
739ef5df1e Decode the MHIU and PAMH heightmaps: row tables, max/min arrays and Z mapping
Both common.rpf payloads are heightmaps, not square/u16 grids. MHIU is a 2048x2048 single-layer map: u16 width@0x06, height@0x08, then height 8-byte row headers {u16 start, u16 count, i32 offset} and packed u8 heights with a measured default of 23. The two measured payloads fill 1,724/1,727 rows and their spans cover the packed bytes with 0 gaps and 0 overlaps; the old zero prefix is the empty rows' headers. PAMH is the GTA HMAP layout stored little-endian (version 1.2): a row table, width*height max u8 rows and width*height min u8 rows. The old u16 reading interleaved the two arrays. Both scale as min.z + value/255 * (max.z - min.z). Cross-check: MHIU vs PAMH max correlates at r=0.861 and r=0.870 in the natural orientation, with land-mask IoU 0.61. The MHIU 0x28 word is still unidentified and is not called a checksum. Tests are synthetic and cover the row table, the default fill, negative offsets, the max/min split and the 64 KiB stream join.
2026-11-22 01:24:54 +00:00
c813181bcb gamedata_maps.py: stop joining at the declared map length 2026-11-22 00:16:37 +01:00
bd27a74315 Decode the MHIU and PAMH map arrays
Add a stdlib reader for the two MHIU headers and square byte grids and the PAMH row table plus u16 grid, with synthetic tests and measured header notes. The checksum and the MHIU prefix remain unknown.
2026-11-21 22:27:43 +00:00