Files
firestorm/MW4COMPARE/reports/maps-decoded-diff.txt
T
83478b7666 Add MW4COMPARE: .mw4 decompiler toolchain and V4H comparison harness
Tooling built to recover editable source for six 'Mech chassis that exist
in the parallel FS_Build_V4H build but not in this repo. Reverse-engineers
every compiled record type in the .mw4 package format back to the .data /
.instance / .subsystems / .damage / .contents / .torso / .engine /
.armature sources the content pipeline consumes.

Nothing here is wired into the game build. It is a standalone analysis
harness run from Linux.

Package format
--------------
"#VBD" container. Directory records are [len][name][FILETIME][origSize]
[storedSize][offset], payload base at dword 0x0C. A record is stored raw
when storedSize == origSize, otherwise LZW (9->12-bit LSB-first codes,
256=clear, 257=EOF, dict from 258), per Database.cpp:451.

GameModel records are flat /Zp4 structs following the C++ inheritance
chain Entity(0) -> Mover(28) -> MWObject(80) -> Vehicle(664) -> Mech(756),
1636 bytes total. CreateMessage records follow Replicator -> Entity ->
Mover -> MWMover -> MWObject -> Vehicle -> Mech from start=16 (the
undeclared Connection__Message header), ending at 341 and padded to 344.

tools/decompile/
----------------
  datamap.py        header-driven layout engine; CHAIN + ANCHORS
                    {Vehicle:664, Mech:756} assert the struct offsets
  mw4msg.py         CreateMessage reader/walker
  data.py           .data      constants.py  define/table symbol resolution
  damage.py         .damage    contents.py   .contents
  smallmodel.py     .torso + .engine         instance.py  .instance
  armature.py / armature_parts.py  .armature + armaturedata/armaturevideo
  assembly.py       joint hierarchy renderer
  make_generic_doll.py  builds generic MFD/Radar damage dolls
  verify_*.py       per-type round-trip verifiers

Verified round-trip across all 64 shared chassis:
  .armature      2938/2976 pages     .subsystems  7579/7585 keys
  .data map      6071/6071 values    .data trip   8291/8306 keys
  .damage        6605/6605 keys      .contents    7480/7480 keys
  .torso+.engine 1280/1280 keys      .instance     896/896 keys, 64/64 pages
  armature_parts 1202/1202 .data, 1149/1202 .video

Layout-discovery lessons (documented in DECOMPILING.md)
-------------------------------------------------------
- Never let a field map be discovered by the values that verify it. A
  value-matching pass reported 4288/4288 while mis-assigning 34 keys. The
  map was rebuilt from header declaration order, anchored on uniquely
  resolved fields.
- Read the factory, not the data. 12 .data fields and 5 Torso fields are
  declared plain Stuff::Scalar but multiplied by Radians_Per_Degree in
  Mech_Tool.cpp:889 / Torso_Tool.cpp.
- Strip typedefs before walking a header. A stray `typedef int AttributeID;`
  masked a missing ClassID - two 4-byte errors cancelling out, caught only
  by the ANCHORS assertion.
- A verifier that silently narrows its own input reports success. Braced
  blocks must be hidden before splitting pages, replacing both CR and LF,
  because a `Shadow={...}` block contains a line reading `[shadow]` and
  splitlines() also splits on bare CR.
- NSWIZZLE is undefined, so the #else branch is live and orders members
  differently. bool is 1 byte; char x[MaxStringLength] is 256.
- V4H carries stale Mech IDs (their Atlas is 5, ours 6), so 64 of 65 shared
  chassis are off by one; --retarget-ids emits $(M_<Chassis>)/$(IDS_<Chassis>).

reports/ holds generated diffs. The two ~5 MB manifest-*.tsv intermediates
are gitignored; regenerate everything with run-comparison.sh.

Co-authored-by: Claude Opus 5 (Anthropic) <noreply@anthropic.com>
Co-authored-by: GitHub Copilot <copilot@github.com>
2026-08-08 16:47:57 -05:00

76 lines
3.1 KiB
Plaintext

### alpine02.mw4
# entries: A=458 B=458 A_only=0 B_only=0 decoded-differ=0
### arctic04.mw4
# entries: A=341 B=341 A_only=0 B_only=0 decoded-differ=0
### arctic06.mw4
# entries: A=342 B=342 A_only=0 B_only=0 decoded-differ=0
### colsm01.mw4
# entries: A=182 B=182 A_only=0 B_only=0 decoded-differ=1
~ maps/colsm01/colsm01.data{gamemodel} A=184B B=184B
### colsm02.mw4
# entries: A=248 B=248 A_only=0 B_only=0 decoded-differ=2
~ maps/colsm02/colsm02.instance A=100B B=100B
~ textures/skysc2f1.tga A=196652B B=196652B
### darklord.mw4
# entries: A=135 B=135 A_only=0 B_only=0 decoded-differ=0
### desert07.mw4
# entries: A=399 B=399 A_only=0 B_only=0 decoded-differ=1
~ maps/desert07/desert07.data{gamemodel} A=184B B=184B
### fact01.mw4
# entries: A=201 B=201 A_only=0 B_only=0 decoded-differ=1
~ maps/fact01/fact01.data{gamemodel} A=184B B=184B
### firestorm.mw4
# entries: A=63 B=63 A_only=0 B_only=0 decoded-differ=1
~ maps/firestorm/firestorm.data{gamemodel} A=184B B=184B
### grassland.mw4
# entries: A=287 B=287 A_only=0 B_only=0 decoded-differ=0
### hotplate.mw4
# entries: A=219 B=219 A_only=0 B_only=0 decoded-differ=1
~ maps/hotplate/hotplate.data{gamemodel} A=184B B=184B
### ice3.mw4
# entries: A=219 B=219 A_only=0 B_only=0 decoded-differ=1
~ maps/ice3/ice3.data{gamemodel} A=184B B=184B
### jung02.mw4
# entries: A=174 B=174 A_only=0 B_only=0 decoded-differ=1
~ maps/jung02/jung02.data{gamemodel} A=184B B=184B
### lunar01.mw4
# entries: A=249 B=249 A_only=0 B_only=0 decoded-differ=1
~ maps/lunar01/lunar01.data{gamemodel} A=184B B=184B
### minerl03.mw4
# entries: A=358 B=358 A_only=0 B_only=0 decoded-differ=1
~ maps/minerl03/minerl03.data{gamemodel} A=184B B=184B
### nazca.mw4
# entries: A=224 B=224 A_only=0 B_only=0 decoded-differ=1
~ maps/nazca/nazca.data{gamemodel} A=184B B=184B
### palace01.mw4
# entries: A=244 B=244 A_only=0 B_only=0 decoded-differ=1
~ maps/palace01/palace01.data{gamemodel} A=184B B=184B
### peaks.mw4
# entries: A=219 B=219 A_only=0 B_only=0 decoded-differ=1
~ maps/peaks/peaks.data{gamemodel} A=184B B=184B
### reduex.mw4
# entries: A=248 B=248 A_only=0 B_only=0 decoded-differ=1
~ maps/reduex/reduex.data{gamemodel} A=184B B=184B
### rookiearena2-terrain-v1.mw4
# entries: A=63 B=63 A_only=0 B_only=0 decoded-differ=1
~ maps/rookiearena2-terrain-v1/rookiearena2-terrain-v1.data{gamemodel} A=184B B=184B
### scrub02.mw4
# entries: A=355 B=355 A_only=0 B_only=0 decoded-differ=1
~ maps/scrub02/scrub02.data{gamemodel} A=184B B=184B
### stormcanyon.mw4
# entries: A=128 B=128 A_only=0 B_only=0 decoded-differ=1
~ maps/stormcanyon/stormcanyon.data{gamemodel} A=184B B=184B
### stormcanyonsiege.mw4
# entries: A=137 B=137 A_only=0 B_only=0 decoded-differ=1
~ maps/stormcanyonsiege/stormcanyonsiege.data{gamemodel} A=184B B=184B
### swamp01.mw4
# entries: A=488 B=488 A_only=0 B_only=0 decoded-differ=2
~ maps/swamp01/crater.data{gamemodel} A=32B B=32B
~ maps/swamp01/swamp01.data{gamemodel} A=184B B=184B
### urban01.mw4
# entries: A=446 B=446 A_only=0 B_only=0 decoded-differ=0
### urban02.mw4
# entries: A=396 B=396 A_only=0 B_only=0 decoded-differ=0
### urban05.mw4
# entries: A=396 B=396 A_only=0 B_only=0 decoded-differ=0