Files
WT-Offline/patches/exe/battle/allow-local-host-player-respawn/patch.jsonc
T
N0VAN0M4LY 927201a462 feat(patches)!: support game-version variants in patch definitions
A game update used to fail a patch whenever any byte it compared moved, even
when only an address in the instruction changed. Patch definitions now say
what a change needs and read the rest from the code:

- patch.jsonc holds a list of variants, each written for one game build
  (written_for) with its own locate block and edit; locate.jsonc is merged
  into it. Exactly one variant must apply, otherwise the patch is left out.
  GUI script patches use the same variants rule.
- expect_original and the bytes to write use the signature syntax, so
  addresses that differ between builds can be wildcards.
- A locate block can capture values at the site (rel32 targets, immediates,
  displacements); a rel32 fixup fills a hole in the written bytes from a
  capture. allow-local-host-bot-spawns now jumps to the target of the
  conditional jump it replaces instead of a stored distance, which makes it
  apply to 2.61.0.43 as well.
- verified_on is gone from the definitions. patches/versions/<version>.jsonc
  records, per checked game build, which variant of every patch applies and
  where; scripts/record-game-version.ts writes it and the launcher reads the
  recorded versions from there.

The Python tools (check-patches, patch-exe, check-gui) read the same format;
check-patches assembles a variant whose assembly names captures at the site
it was located at.

Checked: root and launcher type checks; check-patches and check-gui on
2.61.0.37 and 2.61.0.43 (12 exe and 35 GUI patches each); check-patches and
check-gui report a deliberately broken patch with a non-zero exit;
build-game-copy from 2.61.0.43 into a temporary folder. The computed bytes of
allow-local-host-bot-spawns on 2.61.0.37 equal the bytes it stored before.

BREAKING CHANGE: Each patch needs a variants list. Move executable locators into patch.jsonc and regenerate game version records with record-game-version.ts.
2026-11-29 11:47:08 +08:00

35 lines
1.6 KiB
JSON

// Let the LocalMP host's player spawn in versus modes (GM_DOMINATION and others): the UnitRespawnRequest
// (0xf02f) branch of Unit::onEvent takes the spawn path at 0x1044f03 for every game mode (0x1044ecc jb -> jmp).
// Why the exe: the client keeps the spawn path only for GM_SINGLE_MISSION and GM_DYNAMIC; the versus modes'
// branch belongs to the dedicated server, which the build drops, and nothing outside the function decides it.
// Without it: after the "To Battle!" countdown the player falls back to vehicle selection.
{
"id": "battle/allow-local-host-player-respawn",
"title": "Let the LocalMP host's player spawn in versus modes",
"features": [
"K-Spawn score and respawns"
],
"requires": [],
"variants": [
// Masked signature of the 0xf02f (UnitRespawnRequest) branch of Unit::onEvent (0x103fbc0), from the
// human player check (call 0xfd34a0) to the spawn logic entry, 0x68 bytes; relative targets are wildcards.
// 2.61.0.37: unique hit at 0x1044e9b, edited instruction at +49 (0x1044ecc).
{
"written_for": "2.61.0.37",
"locate": {
"method": "signature",
"section": ".text",
"pattern": "48 89 d9 e8 ?? ?? ?? ?? 84 c0 0f 84 ?? ?? ?? ?? 48 83 3d ?? ?? ?? ?? 00 0f 84 ?? ?? ?? ?? 8b 05 ?? ?? ?? ?? 83 c0 fd 49 8b 95 98 0f 00 00 83 f8 02 72 ?? 0f b6 4a 08 83 ba f8 0b 00 00 00 79 ?? 83 ba f4 0b 00 00 00 0f 88 ?? ?? ?? ?? ba 06 00 00 00 e8 ?? ?? ?? ?? 4c 89 e9 b2 01 e8 ?? ?? ?? ?? e9 ?? ?? ?? ?? 31 d2"
},
"edit": {
"offset": 49,
"asm": [
"jmp 0x37"
],
"bytes": "eb 35",
"expect_original": "72 35"
}
}
]
}