Files
WT-Offline/patches/exe/battle/count-bots-as-active-players/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

36 lines
1.3 KiB
JSON

// Count AI players in countActivePlayers, the player count that domination ticket bleed and the
// battle's player-count rules use.
// Why the exe: the stock count walks MPlayers with a filter that skips bots (MPlayer+0x1d8 bit 7,
// "isBot"), because online battles have human players only; in a LocalMP battle the AI players take
// the human players' places, so the filter would count the AI team as empty. The filter is an
// immediate in the function; nothing outside it can change it.
// Without it: the AI team counts as having no active players.
{
"id": "battle/count-bots-as-active-players",
"title": "Count AI players as active players in LocalMP battles",
"features": [
"K-Kill, assist and capture scoring"
],
"requires": [],
"variants": [
// Masked signature of countActivePlayers (prologue through the player filter mask), 0x1b bytes.
// 2.61.0.37: unique hit at 0x11b9b60, edited instruction (or eax, 0x3a) at +24 (0x11b9b78).
{
"written_for": "2.61.0.37",
"locate": {
"method": "signature",
"section": ".text",
"pattern": "41 57 41 56 41 54 56 57 53 48 83 ec 38 89 cf 80 f2 01 0f b6 c2 c1 e0 0a 83 c8 3a"
},
"edit": {
"offset": 24,
"asm": [
"or eax, 0x32"
],
"bytes": "83 c8 32",
"expect_original": "83 c8 3a"
}
}
]
}