[PR #1850] [MERGED] gamedata_reader: preserve empty polymorphic objects (GAMEDATA-EMPTY-TYPED-OBJECTS) #1862

Closed
opened 2026-11-26 21:19:13 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1850
Author: @cheltyi
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: fix/gamedata-empty-typed-objects


📝 Commits (1)

  • 6e85823 gamedata_reader: preserve empty polymorphic objects

📊 Changes

3 files changed (+70 additions, -3 deletions)

View changed files

📝 docs/gamedata.md (+5 -2)
📝 tests/test_gamedata_reader.py (+61 -0)
📝 tools/gamedata_reader.py (+4 -1)

📄 Description

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).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1850 **Author:** [@cheltyi](https://github.com/cheltyi) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `fix/gamedata-empty-typed-objects` --- ### 📝 Commits (1) - [`6e85823`](https://github.com/ubiquitarianism/leonida/commit/6e85823da41528fd8fcc21379b3a9f58a2d44f24) gamedata_reader: preserve empty polymorphic objects ### 📊 Changes **3 files changed** (+70 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/gamedata.md` (+5 -2) 📝 `tests/test_gamedata_reader.py` (+61 -0) 📝 `tools/gamedata_reader.py` (+4 -1) </details> ### 📄 Description Claimed in the coordination issue as: GAMEDATA-EMPTY-TYPED-OBJECTS ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163147873)) ### 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:19:13 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1862
No description provided.