From 194417a3884126ed565bbf47b4a865450cf3d9e8 Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Fri, 4 Dec 2026 03:43:05 +0800 Subject: [PATCH] fix(battle): ignore non-player kills for firstKill and clamp assist loop Ignore HUD kill feed entries with killer == -1 (mission air defense SAM/AAA and NPC units, common in Nuclear Escalation) when awarding firstKill, matching avengeAwards. Also re-read the offenders vector count after orig_iground_award_assists in local_mp_events.c so the post-call scan never reads past a shrunk array. Verified with root typecheck, MSVC x64 wto_ws.dll rebuild (0 warnings in project C code), and a runnable streak check. --- apps/server/src/battle/battle-streaks.ts | 3 ++- native/wto-net/src/local_mp_events.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/server/src/battle/battle-streaks.ts b/apps/server/src/battle/battle-streaks.ts index f679894..9e79bcb 100644 --- a/apps/server/src/battle/battle-streaks.ts +++ b/apps/server/src/battle/battle-streaks.ts @@ -175,7 +175,8 @@ export function evaluateStreaks(definitions: readonly StreakDefinition[], facts: for (const time of facts.nuclearStrikes) award(def, time, 1); break; case 'firstKill': { - const first = facts.feed.find((k) => k.killerTeam !== k.victimTeam); + // Ignore non-player mission units (air defense SAM/AAA, NPCs) whose HUD feed killer id is -1. + const first = facts.feed.find((k) => k.killer >= 0 && k.killerTeam !== k.victimTeam); if (first && first.killer === facts.localPlayerId) award(def, first.time, 1); break; } diff --git a/native/wto-net/src/local_mp_events.c b/native/wto-net/src/local_mp_events.c index d48d898..2777b47 100644 --- a/native/wto-net/src/local_mp_events.c +++ b/native/wto-net/src/local_mp_events.c @@ -111,6 +111,9 @@ static void __fastcall hook_iground_award_assists(uint8_t *victim) orig_iground_award_assists(victim); if (local_mp_is_host() && victim != NULL && arr != NULL && count > 0) { + uint32_t post_count = *(uint32_t *)(victim + LMP_IGM_OFF_OFFENDERS_CNT); + if (post_count < count) + count = post_count; arr = *(uint8_t **)(victim + LMP_IGM_OFF_OFFENDERS_PTR); for (i = 0; arr != NULL && i < count; i++) { uint8_t *off = arr + i * LMP_OFFENDER_STRIDE;