Files
WT-Offline/patches/native/local_mp_air_ai_sync.jsonc
T
N0VAN0M4LY fe29b5fe9c fix(battle): serialize LocalMP air AI unsortedPlanes updates
Add the local_mp_air_ai_sync native module to serialize calls to
TeamAiManager::addToUnsortedPlanes with an exclusive SRWLOCK on LocalMP
hosts.

Root cause (verified on 2.61.0.60, 2.61.0.58, and 2.61.0.37):
Aircraft physics and AI updates run concurrently across worker threads
via threadpool::parallel_for. When bot aircraft finish their behavior
tree (such as right after an aircraft crashes), AirAi::update tail-calls
TeamAiManager::addToUnsortedPlanes, which locks the global unit table
for lookup but mutates the team's shared unsortedPlanes
dag::Vector<uint32_t> (including reserve/HeapReAlloc) without a lock.
Under 32-bot LocalMP air battles, concurrent reallocations on this
vector corrupt the Windows heap (0xC0000374).

Also guard resolve_offender_killer in local_mp_kills.c with an
install-time check that LMP_OFFENDER_STRIDE <= LMP_OFFENDER_BUF_SIZE so
future struct growth skips cleanly instead of overflowing the stack
buffer.

Checks:
- MSVC /W4 build of wto_ws.dll (0 warnings in repository C files)
- Root and @wto/launcher npm run typecheck
- 15/15 native module resolution on 2.61.0.37 (0x807be0), 2.61.0.58
  (0x80a2b0), and 2.61.0.60 (0x80a150), checkPatchSet, wtotools
  check-patches on 2.61.0.60 (14/14), and temporary copy build
  verification (build-game-copy.ts)
- Pending live multi-match air/nuclear-escalation acceptance in an
  isolated copy.
2026-12-05 00:03:27 +08:00

29 lines
860 B
JSON

// Serialize concurrent updates to the team AI unsortedPlanes list on a LocalMP host.
// The local server cannot add locking inside the client's parallel aircraft physics threads.
// Without it: concurrent HeapReAlloc calls on the shared vector corrupt the heap (0xC0000374).
{
"module": "local_mp_air_ai_sync",
"features": [
"K-AI opponents and teammates"
],
"requires": [
"local_mp_core"
],
"sites": {
// TeamAiManager::addToUnsortedPlanes; unique reference to "unsortedPlanes".
// Verified at 2.61.0.37 0x807be0, 2.61.0.58 0x80a2b0, 2.61.0.60 0x80a150.
"air_ai_add_unsorted_plane": {
"variants": [
{
"written_for": "2.61.0.37",
"locate": {
"method": "string_ref",
"string": "unsortedPlanes",
"target": "function"
}
}
]
}
}
}