fix(native): filter avionics damage notices and enemy parts feedback

Replace the ineffective hero_unit comparison with producer-side hooks on the two stock LocalMP leaks:
1) Avionics/electronics failure dispatcher (2.61.0.37 0xfca8b0, .43 0xfce8e0): track the damaged Unit* from [component + unit] on the current thread and suppress HUD_MSG_DAMAGE notices and optic-view exits (0x15cd9c0) for non-local units while keeping native failure effects intact.
2) Unit::onEvent hit-parts fallthrough (2.61.0.37 0x103fbc0, .43 0x1043fe0): track the hit event on the current thread and filter enqueue_enemy_parts, hit_cam_important, and naval_hit_state to attacks from the local controlled unit, local MPlayer's units (in-flight munitions after switching), or the watched spectator unit.

Checked: native/wto-net/build.ps1 compiles with zero warnings in project sources; checkPatchSet, root and launcher typechecks, 2.61.0.37 check-patches, and native module resolution on both 2.61.0.37 and 2.61.0.43 (11/11 modules ready, 0 failures) pass. In-game verification pending.
This commit is contained in:
N0VAN0M4LY committed 2026-12-02 08:14:54 +08:00
1 parent 96077153c6
commit f3d04d137f
4 files changed
+271 -60

No files matched your search

@@ -1,7 +1,7 @@
// Send damage and control-loss notices only for the unit they describe on a LocalMP host.
// The barrel and breech producers know the affected unit; the control-loss hints describe the
// stock hero manager's current-hero cell, which on a local host can be left on another unit.
// The HUD receives only the type, text index and ID.
// Bind self damage, avionics failure and hit-parts feedback to the player on a LocalMP host.
// The stock damage producers skip hero/attacker checks on dedicated-server paths because a
// dedicated server has no HUD; on a LocalMP host both run in the same process.
// The HUD receives only the type, text index and ID, or the victim's damaged parts list.
{
"module": "local_mp_damage_notifications",
"features": [
@@ -91,8 +91,7 @@
]
},
// HUD_MSG_DAMAGE delivery: resolves the text index to localized text, then pushes
// {type, text, id} into the local HUD event queue. The control-loss hints (HUD text indices
// 261..283) are pushed here.
// {type, text, id} into the local HUD event queue.
// 2.61.0.37: 0x19b1030; 2.61.0.43: 0x19b6ba0.
"hud_damage_deliver": {
"variants": [
@@ -105,18 +104,105 @@
}
]
},
// HeroManager::on_controlled_hero_changed stores the previous and current controlled unit into
// two adjacent process-wide cells. The hint refresh code reads the current one.
// 2.61.0.37: 0xec6319, cell 0x7bad418; 2.61.0.43: 0xeca349, cell 0x7bb9778.
"hero_unit": {
// Unit avionics/electronics failure dispatcher (13-entry switch for guidance, sensors, radar,
// RWR, TWS, optics, targeting pod, laser designator, NVG, indicators). Reads its owning Unit*
// from [comp + unit]; most cases emit HUD_MSG_DAMAGE without checking the unit's hero flag.
// 2.61.0.37: 0xfca8b0; 2.61.0.43: 0xfce8e0.
"avionics_damage": {
"variants": [
{
"written_for": "2.61.0.37",
"locate": {
"method": "signature",
"pattern": "48 89 05 ?? ?? ?? ?? 48 89 3d ?? ?? ?? ?? 48 8b 3d ?? ?? ?? ?? 48 39 fe 0f 94 c0 08 c8",
"pattern": "41 57 41 56 41 55 41 54 56 57 55 53 48 83 ec 58 0f 29 74 24 40 48 89 ce 83 fa 0c 0f 87 ?? ?? ?? ?? 89 d0 48 8d 0d ?? ?? ?? ?? 48 63 04 81 48 01 c8 ff e0 48 8b 46 ??",
"captures": {
"cell": { "offset": 10, "type": "rel32" }
"unit": { "offset": 54, "type": "u8" }
}
}
}
]
},
// Camera optic-view exit invoked by avionics_damage cases 2, 7 and 8 without checking hero.
// 2.61.0.37: 0xfcab0b -> 0x15cd9c0; 2.61.0.43: 0xfceb3b -> 0x15d2760.
"avionics_exit_optic": {
"variants": [
{
"written_for": "2.61.0.37",
"locate": {
"method": "within",
"in": "avionics_damage",
"pattern": "48 81 c1 ?? ?? ?? ?? 89 d3 ba 01 00 00 00 41 b0 01 e8 ?? ?? ?? ??",
"captures": {
"call": { "offset": 18, "type": "rel32" }
}
}
}
]
},
// Unit::onEvent: receives hit events for every unit on a LocalMP host and falls through into
// enemy parts-list and hit-camera special-event delivery even when the attacker is an AI unit.
// 2.61.0.37: 0x103fbc0; 2.61.0.43: 0x1043fe0.
"unit_on_event": {
"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 c8 04 00 00 44 0f 29 bc 24 b0 04 00 00 44 0f 29 b4 24 a0 04 00 00 44 0f 29 ac 24 90 04 00 00 44 0f 29 a4 24 80 04 00 00 44 0f 29 9c 24 70 04 00 00 44 0f 29 94 24 60 04 00 00 44 0f 29 8c 24 50 04 00 00 44 0f 29 84 24 40 04 00 00 0f 29 bc 24 30 04 00 00 0f 29 b4 24 20 04 00 00 48 89 d7 49 89 cd 0f b7 42 20"
}
}
]
},
// Hit event attacker Unit* offset loaded before comparing against g_hero in Unit::onEvent.
// 2.61.0.37: 0x104495d (offender=0xd0); 2.61.0.43: 0x1048d7d (offender=0xd0).
"hit_event_offender": {
"variants": [
{
"written_for": "2.61.0.37",
"locate": {
"method": "within",
"in": "unit_on_event",
"pattern": "48 8b bf ?? ?? ?? ?? 48 8b 35 ?? ?? ?? ?? 48 85 f6 74 ?? 48 8b 8e ?? ?? ?? ??",
"captures": {
"offender": { "offset": 3, "type": "u32" }
}
}
}
]
},
// Watched hero cell used when spectating in Unit::onEvent.
// 2.61.0.37: 0x10449ab -> 0x7bad420; 2.61.0.43: 0x1048dcb -> 0x7bb9780.
"hit_watched_hero": {
"variants": [
{
"written_for": "2.61.0.37",
"locate": {
"method": "within",
"in": "unit_on_event",
"pattern": "40 84 ed 74 ?? 48 8b 15 ?? ?? ?? ?? 48 8b 0d ?? ?? ?? ?? 48 39 d7 75 ??",
"captures": {
"watched_hero": { "offset": 8, "type": "rel32" }
}
}
}
]
},
// Unconditional enemy parts-list, hit-camera important events and naval hit-state calls
// reached after the hit-camera attacker check in Unit::onEvent.
// 2.61.0.37: 0x1045fc3 -> 0x18977c0, 0x1897cc0, 0x1896a40;
// 2.61.0.43: 0x104a3d9 -> 0x189d140, 0x189d640, 0x189c3c0.
"hit_parts_feedback": {
"variants": [
{
"written_for": "2.61.0.37",
"locate": {
"method": "within",
"in": "unit_on_event",
"pattern": "48 8b 0d ?? ?? ?? ?? 4c 8d b4 24 00 01 00 00 4c 89 ea 4d 89 f0 e8 ?? ?? ?? ?? 48 8b 0d ?? ?? ?? ?? 4c 89 ea 4d 89 f0 e8 ?? ?? ?? ?? 66 41 83 bd 8c 00 00 00 05 75 ?? 48 8b 0d ?? ?? ?? ?? 4c 8d 84 24 00 01 00 00 4c 89 ea e8 ?? ?? ?? ??",
"captures": {
"enqueue_enemy_parts": { "offset": 22, "type": "rel32" },
"hit_cam_important": { "offset": 40, "type": "rel32" },
"naval_hit_state": { "offset": 74, "type": "rel32" }
}
}
}