Files
WT-Offline/patches/exe/battle/allow-local-host-bot-spawns/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

59 lines
2.1 KiB
JSON

// Let BotSystem::changeUnit spawn the AI players' vehicles on a LocalMP host (0x11b2c3a: the g_multiplayer
// null guard becomes a jump to the Unit::changeAircraft call at 0x11b314e).
// Why the exe: the build drops the dedicated server's script spawn permission, so with a multiplayer
// session the function only logs "spawn denied by scripts"; non-host sessions already return at its start.
// Without it: no AI vehicle ever spawns in a LocalMP battle.
{
"id": "battle/allow-local-host-bot-spawns",
"title": "Let BotSystem spawn AI vehicles on a LocalMP host",
"features": [
"K-AI opponents and teammates"
],
"requires": [],
"variants": [
// Masked signature of BotSystem::changeUnit from the spawn point check (call 0x111a010)
// to the g_multiplayer null guard, 0x3c bytes; rip-relative and branch targets are wildcards.
// 2.61.0.37: unique hit at 0x11b2c14, edited instruction at +38 (0x11b2c3a).
// spawn_call: where the null guard's jz goes (the Unit::changeAircraft call); the edit jumps there
// unconditionally. The guard's rip displacement differs between builds, so it is a wildcard.
{
"written_for": "2.61.0.37",
"locate": {
"method": "signature",
"section": ".text",
"pattern": "48 8b 05 ?? ?? ?? ?? 48 8b 88 e0 03 00 00 48 8b 5c 24 20 48 89 da 4d 89 f0 e8 ?? ?? ?? ?? 84 c0 0f 84 ?? ?? ?? ?? 48 83 3d ?? ?? ?? ?? 00 0f 84 ?? ?? ?? ?? 48 8b 54 24 20",
"captures": {
"spawn_call": {
"offset": 48,
"type": "rel32"
}
}
},
"edit": {
"offset": 38,
"asm": [
"jmp {spawn_call}",
"nop",
"nop",
"nop",
"nop",
"nop",
"nop",
"nop",
"nop",
"nop"
],
"bytes": "e9 ?? ?? ?? ?? 90 90 90 90 90 90 90 90 90",
"expect_original": "48 83 3d ?? ?? ?? ?? 00 0f 84 ?? ?? ?? ??",
"fixups": [
{
"at": 1,
"type": "rel32",
"target": "spawn_call"
}
]
}
}
]
}