gamedata_reader: preserve empty polymorphic objects (GAMEDATA-EMPTY-TYPED-OBJECTS) #1850

Manually merged
github merged 1 commit from gh-pr/1850/head into gh-pr/1850/base 2026-11-26 10:08:32 +00:00
Owner

@⁠cheltyi on GitHub · 2026-11-25 13:06 UTC · original
cheltyi:fix/gamedata-empty-typed-objects → main · +70 −3 · 3 files · 1 commits · merged 2026-11-25 17:28 UTC

Claimed in the coordination issue as: GAMEDATA-EMPTY-TYPED-OBJECTS (claim)

What and why

gamedata_reader turned an empty non-NULL typed XML object into an empty string and consumed its type attribute, losing the object's class. A hand-written <Item type="CEmpty"/> now becomes {"$type": "CEmpty"}. This preserves the documented polymorphic-object contract for default instances with no serialized fields.

The change uses the existing object conversion after the explicit scalar, vector, array, reference and registered-handler paths. Synthetic regressions cover empty roots, list/map children, whitespace, extra attributes, dispatch precedence and streaming/tree parity. The documentation records the corrected convention and object count.

A whole-archive check of the user's local common.rpf (size and SHA-256 match the Xbox 1.0.2.1 manifest) found 173 affected objects across 54 classes in 13 documents. Before/after comparison covers all 954 streams / 267 XML payloads: 259 well-formed documents and 8 malformed payloads in both runs; exactly 173 class restorations and zero other data changes. Polymorphic objects increase from 6,490 to 6,663. Only aggregate counts are reported; no game content is included.

This is independent of #1557, which changes root filtering and output I/O. Both diffs apply together and the combined reader tests pass.

Tested

  • python -I tests/test_gamedata_reader.py: 25 passed. Against unpatched main, the new empty-object regressions fail (five failing subtests/assertions); compatibility checks still pass.
  • Related gamedata XML/index/graph tests: 72 passed; all documentation tests: 47 passed; text line-ending checks: 3 passed.
  • Combined with #1557: test_gamedata_reader.py, 28 passed.
  • python -m compileall -q make_game.py tools tests, python -I make_game.py --help, git diff --check, and python -I scripts/check_no_game_data.py tools/gamedata_reader.py tests/test_gamedata_reader.py docs/gamedata.md: passed.
  • python -I scripts/run_semantic_tests.py tests/semantic --jobs 16: 489 files, 6,288 tests, zero failed files (134 s).
  • Local whole-archive comparison described above; output contains aggregate counts only.

GPUs tested: n/a (CPU-only XML conversion; Linux x86-64, Python 3.14.9).

AI-assisted: yes (Codex).

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption, including in quoted logs or reports.
  • No new translator rule (not applicable to this XML-reader fix).
**@⁠cheltyi** on GitHub · 2026-11-25 13:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1850) `cheltyi:fix/gamedata-empty-typed-objects` → `main` · +70 −3 · 3 files · 1 commits · merged 2026-11-25 17:28 UTC Claimed in the coordination issue as: GAMEDATA-EMPTY-TYPED-OBJECTS ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608)) ### What and why `gamedata_reader` turned an empty non-NULL typed XML object into an empty string and consumed its `type` attribute, losing the object's class. A hand-written `<Item type="CEmpty"/>` now becomes `{"$type": "CEmpty"}`. This preserves the documented polymorphic-object contract for default instances with no serialized fields. The change uses the existing object conversion after the explicit scalar, vector, array, reference and registered-handler paths. Synthetic regressions cover empty roots, list/map children, whitespace, extra attributes, dispatch precedence and streaming/tree parity. The documentation records the corrected convention and object count. A whole-archive check of the user's local `common.rpf` (size and SHA-256 match the Xbox 1.0.2.1 manifest) found 173 affected objects across 54 classes in 13 documents. Before/after comparison covers all 954 streams / 267 XML payloads: 259 well-formed documents and 8 malformed payloads in both runs; exactly 173 class restorations and zero other data changes. Polymorphic objects increase from 6,490 to 6,663. Only aggregate counts are reported; no game content is included. This is independent of #1557, which changes root filtering and output I/O. Both diffs apply together and the combined reader tests pass. ### Tested - `python -I tests/test_gamedata_reader.py`: 25 passed. Against unpatched `main`, the new empty-object regressions fail (five failing subtests/assertions); compatibility checks still pass. - Related gamedata XML/index/graph tests: 72 passed; all documentation tests: 47 passed; text line-ending checks: 3 passed. - Combined with #1557: `test_gamedata_reader.py`, 28 passed. - `python -m compileall -q make_game.py tools tests`, `python -I make_game.py --help`, `git diff --check`, and `python -I scripts/check_no_game_data.py tools/gamedata_reader.py tests/test_gamedata_reader.py docs/gamedata.md`: passed. - `python -I scripts/run_semantic_tests.py tests/semantic --jobs 16`: 489 files, 6,288 tests, zero failed files (134 s). - Local whole-archive comparison described above; output contains aggregate counts only. GPUs tested: n/a (CPU-only XML conversion; Linux x86-64, Python 3.14.9). AI-assisted: yes (Codex). ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption, including in quoted logs or reports. - [x] No new translator rule (not applicable to this XML-reader fix).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:08:28 +00:00
github manually merged commit 6e85823da4 into gh-pr/1850/base 2026-11-26 10:08:32 +00:00
Author
Owner

@⁠madvillain91 on GitHub · 2026-11-25 13:31 UTC · original · reviewed

Independent Windows 11 26H2 (26300.9711) check at 6e85823da against main 384abe5b0 (PR base 98c2f7777), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_gamedata_reader.py (25/25 in 1.833s) and test_text_write_line_endings.py (3/3 in 18.589s), with check_no_game_data.py and compileall clean. Verified empty/whitespace-only typed elements preserve {"$type": ...} across roots, lists, keyed maps, and streaming vs whole-tree conversion without affecting other leaf conventions or double-counting inside type handlers. LGTM.

**@⁠madvillain91** on GitHub · 2026-11-25 13:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1850#pullrequestreview-6058525856) · **reviewed** Independent Windows 11 26H2 (26300.9711) check at 6e85823da against main 384abe5b0 (PR base 98c2f7777), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_gamedata_reader.py (25/25 in 1.833s) and test_text_write_line_endings.py (3/3 in 18.589s), with check_no_game_data.py and compileall clean. Verified empty/whitespace-only typed elements preserve {"$type": ...} across roots, lists, keyed maps, and streaming vs whole-tree conversion without affecting other leaf conventions or double-counting inside type handlers. LGTM.
Author
Owner

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

Merged. Thank you, @⁠cheltyi. Empty polymorphic objects keep their class now, and the docs counts are updated.

  • The new tests fail on main and pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check.
  • Checked on main 6ade9f225 + 6e85823da: the semantic suite passes (490 files, 6,292 tests, 0 files failed); test_gamedata_reader pass; the 14 docs and writer tests pass; check_no_game_data.py is clean on the 3 changed files.

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

**@⁠aslan2142** on GitHub · 2026-11-25 17:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1850#issuecomment-7169568038) Merged. Thank you, @⁠cheltyi. Empty polymorphic objects keep their class now, and the docs counts are updated. - The new tests fail on `main` and pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check. - **Checked on `main` `6ade9f225` + `6e85823da`:** the semantic suite passes (490 files, 6,292 tests, 0 files failed); `test_gamedata_reader` pass; the 14 docs and writer tests pass; `check_no_game_data.py` is clean on the 3 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.