Skip to content

PSO writer: <pso> edits in .oiv packages install and uninstall - #137

Merged
Two-Play merged 1 commit into
developfrom
claude/oiv-pso-493027
Nov 22, 2026
Merged

Two-Play merged 1 commit into
developfrom
claude/oiv-pso-493027

Conversation

@Two-Play

Copy link
Copy Markdown
Owner

OpenIV packages with <pso> edits were refused. Now the PSO file is converted to XML, the nested add/replace/remove XPath edits are applied exactly like <xml>, and the result is written back as PSO. That needed a PSO writer.

PSO writer (rage-formats, Pso::from_xml)

  • XML → PSO, using the original file as the template. Its schema (PSCH) and the other sections (PSIG, STRE, …) are kept. The data (PSIN) and the block map (PMAP) are rebuilt the way the game's files are laid out:
    • one type per block, blocks in the original's order
    • items in depth-first order, 0x70 padding
    • chars, hashes, pointers and counted strings in their own named blocks
    • the GTA V and RDR2 block-map and pointer layouts
  • Covers structures (inline and pointed-to, including derived types), inline and external arrays, strings (fixed, pointer, counted), hashes, enums, flags, maps (key/item pairs), vectors and matrices.
  • CHKS (a checksum by an unknown method) is kept when the data comes out unchanged and dropped otherwise, as CodeWalker does.
  • An edit that names a field the structure doesn't have, or doesn't parse, is refused before anything is written.

Reader fixes the round trip turned up

  • RDR2 enum infos are 16 bytes per value, not 8, so every RDR2 enum and flag name was wrong before.
  • Enum values the enum doesn't list now print as numbers, not as an empty string.
  • String-pointer arrays were XML-escaped twice.

Round trip over both games (verify --meta --rebuild, rpf8 --meta --rebuild)

Game PSO files Byte-identical Other bytes, same XML Errors
GTA V Enhanced 4,943 3,973 970 0
RDR2 69,246 52,656 16,588 0 (2 files not fully readable by the reader, skipped)

The byte differences are in bytes the XML doesn't carry: uninitialised struct padding, the unused 4th float of 3D vectors, the order of the two length fields of some counted strings, and the dropped CHKS that comes with them.

Installer

  • <pso path> parses the same commands as <xml>. The preview shows N XML command(s) on the PSO data: x line(s) added, y removed.
  • Journal and undo work like the other edits; the change is grouped with the package.
  • Names that the XPaths compare with (Item[Name = 'adder']) are registered first, so hashes print as those names and match.
  • RSC7 metadata (resource .ymt, e.g. ped variations) is still refused, with an explanation. Docs updated (modding.md, cli.md, index table).

Tests

  • Unit tests in rage-formats: byte-identical round trip of a hand-built file, edits, refusals, RDR2 layout.
  • Package-parsing test.
  • End-to-end test: install of a <pso> replace + add on a fake game, check of the result, uninstall restores the original bytes.
  • Against the real GTA V Enhanced, using an isolated config and a fake game folder of symlinks: a package editing update/x64/dlcpacks/patchday5ng/dlc.rpf/x64/levels/gta5/vehicles.rpf/_manifest.ymf (nested archive; replace, remove and add). It installed to the scratch mods folder and reads back as intended. The edited file round-trips byte-identically, and uninstall restores the game's XML.
  • cargo clippy -D warnings and the tests for rage-formats, openrage-app, openrage-cli pass. openrage-gui builds. rdr2-ped --check still resolves 122,696 of 122,703 parts (not compared with a run before the enum fix).

Not checked in the game itself

  • No edited PSO file has been loaded by GTA V or RDR2. In particular, the game has not been tried with a file that has no CHKS (CodeWalker-written PSO files have none and are known to load), nor with any written RDR2 PSO.
  • Packages written for OpenIV use XPaths against OpenIV's XML for the file. OpenRAGE's XML follows CodeWalker's (the game's own meta format), but no real OpenIV <pso> package from the internet has been tried, so differences in naming (e.g. how unknown hashes are written) are unverified.
  • Not tried in the GUI's install dialog; the CLI and the library API it uses were.

🤖 Generated with Claude Code

- rage-formats: XML → PSO (`Pso::from_xml`), using the original file as the
  template: its schema and other sections stay, the data and block map are
  rebuilt with the game's layout (one type per block, original block order,
  depth-first items, 0x70 padding, GTA V and RDR2 block maps and pointers).
  Structures, pointers, arrays (inline and external), strings, hashes, enums,
  flags, maps, vectors and matrices. CHKS is dropped when the data changes.
- Reader fixes found by the round trip: RDR2 enum values are 16 bytes (flag
  and enum names were wrong), unknown enum values print as numbers, string
  arrays were escaped twice.
- names::parse_value: the hash behind a printed name.
- openrage verify --meta --rebuild and rpf8 --meta --rebuild: every PSO
  file to XML and back. GTA V Enhanced: 4,943 files, 3,973 byte-identical,
  all read back to the same XML. RDR2: 69,246 files, 52,656 identical, all
  others the same XML (2 not fully readable, skipped).
- oiv: <pso> parses its XML commands and is applied like <xml> on the
  file's XML, then written back; preview shows the lines changed, journal
  and undo as for other edits. Names compared in XPaths are registered so
  hashes match them.
- Docs: modding (supported kinds, what is still refused), cli, index table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Two-Play
Two-Play merged commit 0fe249c into develop Nov 22, 2026
6 checks passed
@Two-Play Two-Play mentioned this pull request Nov 24, 2026
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.

1 participant