From 50676ae78f2f6d7bd09379730c71f3c09e12b5e8 Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Sat, 28 Nov 2026 14:45:02 +0800 Subject: [PATCH] fix(battle): preserve LocalMP state for the debriefing --- .../quit-local-host-to-debriefing/replace.nut | 4 ++- .../find-summary-layout.nut | 1 + .../patch.jsonc | 4 +++ .../replace-summary-layout.nut | 1 + .../replace.nut | 26 ++++++++++--------- .../find-after-exp.nut | 9 +++++++ .../find-gather.nut | 10 +++++++ .../use-settled-debriefing-stats/patch.jsonc | 6 ++++- .../replace-after-exp.nut | 4 +++ .../replace-gather.nut | 16 ++++++++---- .../use-settled-debriefing-stats/replace.nut | 21 +++++++++++++-- 11 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 gui-patches/battle/report-local-battle-settlement/find-summary-layout.nut create mode 100644 gui-patches/battle/report-local-battle-settlement/replace-summary-layout.nut create mode 100644 gui-patches/battle/use-settled-debriefing-stats/find-after-exp.nut create mode 100644 gui-patches/battle/use-settled-debriefing-stats/replace-after-exp.nut diff --git a/gui-patches/battle/quit-local-host-to-debriefing/replace.nut b/gui-patches/battle/quit-local-host-to-debriefing/replace.nut index a0b7d5e..6253e39 100644 --- a/gui-patches/battle/quit-local-host-to-debriefing/replace.nut +++ b/gui-patches/battle/quit-local-host-to-debriefing/replace.nut @@ -12,7 +12,9 @@ disableOrders() quit_to_debriefing() interrupt_multiplayer(true) - HudBattleLog.reset() + // The LocalMP debriefing can still show this log after the host has stopped. + if (require("nestdb").ndbTryRead(["wto", "activeBattle"]) == null) + HudBattleLog.reset() this.onResumeRaw() } diff --git a/gui-patches/battle/report-local-battle-settlement/find-summary-layout.nut b/gui-patches/battle/report-local-battle-settlement/find-summary-layout.nut new file mode 100644 index 0000000..be772d5 --- /dev/null +++ b/gui-patches/battle/report-local-battle-settlement/find-summary-layout.nut @@ -0,0 +1 @@ + let isSingleRow = visible < 3 diff --git a/gui-patches/battle/report-local-battle-settlement/patch.jsonc b/gui-patches/battle/report-local-battle-settlement/patch.jsonc index dfd6efa..3eba1c4 100644 --- a/gui-patches/battle/report-local-battle-settlement/patch.jsonc +++ b/gui-patches/battle/report-local-battle-settlement/patch.jsonc @@ -18,6 +18,10 @@ { "find": "find.nut", "replace": "replace.nut" + }, + { + "find": "find-summary-layout.nut", + "replace": "replace-summary-layout.nut" } ] } diff --git a/gui-patches/battle/report-local-battle-settlement/replace-summary-layout.nut b/gui-patches/battle/report-local-battle-settlement/replace-summary-layout.nut new file mode 100644 index 0000000..8cedcb5 --- /dev/null +++ b/gui-patches/battle/report-local-battle-settlement/replace-summary-layout.nut @@ -0,0 +1 @@ + let isSingleRow = this.debriefingResult?.wtoSettled == true || visible < 3 diff --git a/gui-patches/battle/report-local-battle-settlement/replace.nut b/gui-patches/battle/report-local-battle-settlement/replace.nut index 54cf023..d82d8eb 100644 --- a/gui-patches/battle/report-local-battle-settlement/replace.nut +++ b/gui-patches/battle/report-local-battle-settlement/replace.nut @@ -71,20 +71,22 @@ function applyWtoSettledDebriefing(wtoBattle) { .findvalue(@(l) l?.wtoSessionId == wtoBattle.sessionId) if (sessionLog?.wtoDebriefing == null) return - ndbWrite(["wto", "settled"], { exp = sessionLog.wtoDebriefing, roomId = sessionLog.roomId }) + let evObj = events.getEvent(wtoBattle?.modeName ?? "") + let roomEvent = evObj == null ? null : { + name = evObj?.name + economicName = evObj?.economicName + difficulty = evObj?.difficulty + chapter = evObj?.chapter + gameModeId = evObj?.gameModeId + } + ndbWrite(["wto", "settled"], { + exp = sessionLog.wtoDebriefing + roomId = sessionLog.roomId + win = sessionLog?.win ?? false + roomEvent + }) gatherDebriefingResult() ndbDelete(["wto", "settled"]) - let cur = getDebriefingResult() - cur.isSucceed = sessionLog?.win ?? false - let evObj = events.getEvent(wtoBattle?.modeName ?? "") - if (evObj != null && cur.roomEvent == null) - cur.roomEvent = { - name = evObj?.name - economicName = evObj?.economicName - difficulty = evObj?.difficulty - chapter = evObj?.chapter - gameModeId = evObj?.gameModeId - } } function settleWtoBattleAndOpen(wtoBattle, params) { diff --git a/gui-patches/battle/use-settled-debriefing-stats/find-after-exp.nut b/gui-patches/battle/use-settled-debriefing-stats/find-after-exp.nut new file mode 100644 index 0000000..a77da89 --- /dev/null +++ b/gui-patches/battle/use-settled-debriefing-stats/find-after-exp.nut @@ -0,0 +1,9 @@ + debriefingResult.country <- get_local_player_country() + debriefingResult.localTeam <- get_mp_local_team() + debriefingResult.friendlyTeam <- get_player_army_for_hud() + debriefingResult.haveTeamkills <- debriefingResultHaveTeamkills() + debriefingResult.activeBoosters <- getDebriefingActiveBoosters() + debriefingResult.activeWager <- getDebriefingActiveWager() + debriefingResult.eventId <- getDebriefingEventId() + debriefingResult.chatLog <- getGameChatLogText() + debriefingResult.logForBanhammer <- getLogForBanhammer() diff --git a/gui-patches/battle/use-settled-debriefing-stats/find-gather.nut b/gui-patches/battle/use-settled-debriefing-stats/find-gather.nut index d2947b9..3f6a610 100644 --- a/gui-patches/battle/use-settled-debriefing-stats/find-gather.nut +++ b/gui-patches/battle/use-settled-debriefing-stats/find-gather.nut @@ -1,2 +1,12 @@ function gatherDebriefingResult() { let gm = get_game_mode() + let gameType = get_game_type() + if (gm == GM_DYNAMIC) + dynamicResult = dynamicApplyStatus() + + debriefingResult = { + roomUserlogs = getUserLogsList({ + currentRoomOnly = true + needStackItems = false + disableVisible = true + }) diff --git a/gui-patches/battle/use-settled-debriefing-stats/patch.jsonc b/gui-patches/battle/use-settled-debriefing-stats/patch.jsonc index d3d041d..5ea47f5 100644 --- a/gui-patches/battle/use-settled-debriefing-stats/patch.jsonc +++ b/gui-patches/battle/use-settled-debriefing-stats/patch.jsonc @@ -1,5 +1,5 @@ // Build the debriefing of a settled LocalMP battle from the statistics table the local service -// settled (its logs are matched by match-settled-battle-room-logs). +// settled, using the multiplayer state captured while leaving the battle. // Why the client: the debriefing reads stat_get_exp() (aces.exe 0x1053b70, the battle's // SessionStatsNet), which online the battle server fills; a LocalMP host has no battle server. // Without it: the debriefing shows no rewards or activity. @@ -21,6 +21,10 @@ { "find": "find.nut", "replace": "replace.nut" + }, + { + "find": "find-after-exp.nut", + "replace": "replace-after-exp.nut" } ] } diff --git a/gui-patches/battle/use-settled-debriefing-stats/replace-after-exp.nut b/gui-patches/battle/use-settled-debriefing-stats/replace-after-exp.nut new file mode 100644 index 0000000..92f1099 --- /dev/null +++ b/gui-patches/battle/use-settled-debriefing-stats/replace-after-exp.nut @@ -0,0 +1,4 @@ + debriefingResult.haveTeamkills <- debriefingResultHaveTeamkills() + debriefingResult.activeBoosters <- getDebriefingActiveBoosters() + debriefingResult.activeWager <- getDebriefingActiveWager() + debriefingResult.eventId <- getDebriefingEventId() diff --git a/gui-patches/battle/use-settled-debriefing-stats/replace-gather.nut b/gui-patches/battle/use-settled-debriefing-stats/replace-gather.nut index dd24d26..764f23f 100644 --- a/gui-patches/battle/use-settled-debriefing-stats/replace-gather.nut +++ b/gui-patches/battle/use-settled-debriefing-stats/replace-gather.nut @@ -1,6 +1,12 @@ -function gatherDebriefingResult() { - // WTOffline: while a LocalMP battle is being settled, nestdb wto.settled holds what the local - // service settled: { exp = the debriefing table, roomId = the battle's room id } - // (written by report-local-battle-settlement; the room id is read by match-settled-battle-room-logs). - let wtoSettled = require("nestdb").ndbTryRead(["wto", "settled"]) +function getDebriefingRoomLogs() { + return getUserLogsList({ currentRoomOnly = true, needStackItems = false, disableVisible = true }) +} + +function gatherDebriefingFlightState() { let gm = get_game_mode() + let gameType = get_game_type() + if (gm == GM_DYNAMIC) + dynamicResult = dynamicApplyStatus() + + debriefingResult = { + roomUserlogs = getDebriefingRoomLogs() diff --git a/gui-patches/battle/use-settled-debriefing-stats/replace.nut b/gui-patches/battle/use-settled-debriefing-stats/replace.nut index ad4cc9d..de72537 100644 --- a/gui-patches/battle/use-settled-debriefing-stats/replace.nut +++ b/gui-patches/battle/use-settled-debriefing-stats/replace.nut @@ -1,3 +1,20 @@ - // WTOffline: the settled statistics replace the local SessionStatsNet, which no battle server - // fills on a LocalMP host. + debriefingResult.country <- get_local_player_country() + debriefingResult.localTeam <- get_mp_local_team() + debriefingResult.friendlyTeam <- get_player_army_for_hud() + debriefingResult.chatLog <- getGameChatLogText() + debriefingResult.logForBanhammer <- getLogForBanhammer() +} + +function gatherDebriefingResult() { + let wtoSettled = require("nestdb").ndbTryRead(["wto", "settled"]) + if (wtoSettled == null || debriefingResult == null) + gatherDebriefingFlightState() + if (wtoSettled != null) { + // The LocalMP host and its player table are gone by the time the service replies. + debriefingResult.roomUserlogs = getDebriefingRoomLogs() + debriefingResult.roomEvent = debriefingResult.roomEvent ?? wtoSettled.roomEvent + debriefingResult.isSucceed = wtoSettled.win + debriefingResult.wtoSettled <- true + } + let gameType = debriefingResult.gameType let exp = wtoSettled != null ? u.copy(wtoSettled.exp) : (stat_get_exp() ?? {})