Files
WT-Offline/patches/native/local_mp_support.jsonc
T
N0VAN0M4LY dde852e2b1 feat(patcher): resolve native LocalMP values from patch definitions
The LocalMP modules of wto_ws.dll scanned for 42 functions at start-up and
used about a hundred structure offsets compiled in as constants, so a game
update could move a field without anything noticing. Their needs are now
definitions under patches/native/<module>.jsonc, resolved by the patcher when
it builds the game copy, the same way exe patches are located:

- Locate methods: "string_ref" finds code by the string it loads (optionally
  with a pattern around the lea, to read the field a scoreboard row stores
  under that name), and "within" searches a short pattern inside the function
  of a site located before it (function ranges from the exception directory).
- Each module lists its sites (functions, globals, call targets and the
  instructions whose captures give structure offsets), its features and the
  modules it requires. A module whose sites are not all found is reported
  like an unavailable patch, with the modules depending on it.
- The resolved values go into wto_ws.cfg as native.<site>[.<capture>] lines,
  with the executable's PE time stamp and image size so the library can
  refuse values resolved for another build.
- Version records include the native module variants and values.
- Patch-set folders: the patcher, the scripts and the launcher take the root
  of a patch set (exe, gui, native, versions) instead of separate folders.
- New feature tags K-Chat and radio and K-Nuclear bomb in both language packs.

The library still scans by itself; reading these values is the next change.

Checked: root and launcher type checks; all 10 modules resolve on 2.61.0.37,
where the 239 values equal what the drafting tool read with a disassembler, and
on 2.61.0.43, where every structure offset is unchanged except the GameSaveData
HUD event queue (0xae8 -> 0xb18); build-game-copy from 2.61.0.37 into a
temporary folder writes the values into wto_ws.cfg.
2026-11-29 12:15:30 +08:00

64 lines
1.8 KiB
JSON

// Mission support unit (the nuclear carrier) after it is destroyed (native/wto-net/src/local_mp_support.c).
// Without it: a second nuclear carrier spawns where the first died and nobody flies it.
{
"module": "local_mp_support",
"features": [
"K-Nuclear bomb"
],
"requires": [
"local_mp_core"
],
"sites": {
// setControlledUnit(mplayer, eid).
// 2.61.0.37: 0x598a70
"set_controlled_unit": {
"variants": [
{
"written_for": "2.61.0.37",
"locate": {
"method": "signature",
"pattern": "56 57 53 48 83 ec 40 89 d7 48 89 ce 89 d0 48 89 44 24 28 c7 44 24 20 03 00 00 00"
}
}
]
},
// MPlayer per-frame update.
// 2.61.0.37: 0x59d270 (push r15; push r14; push r13; ...)
"mplayer_update": {
"variants": [
{
"written_for": "2.61.0.37",
"locate": {
"method": "signature",
"pattern": "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec 98 00 00 00 0f 29 bc 24 80 00 00 00 0f 29 74 24 70 0f 28 f1"
}
}
]
},
// MPlayer missionSupportUnitRef.
// 2.61.0.37: 0x59da3c (mov dword ptr [rsi + 0xb58], eax; mov rcx, qword ptr [rsp + 0x38]; mov qword ptr [rsi + 0xb50], rcx)
"mplayer_support_unit": {
"variants": [
{
"written_for": "2.61.0.37",
"locate": {
"method": "within",
"in": "mplayer_update",
"pattern": "89 86 ?? ?? ?? ?? 48 8b 4c 24 38 48 89 8e ?? ?? ?? ??",
"captures": {
"eid": {
"offset": 2,
"type": "u32"
},
"unit": {
"offset": 14,
"type": "u32"
}
}
}
}
]
}
}
}