fix(battle): preserve LocalMP state for the debriefing

This commit is contained in:
N0VAN0M4LY committed 2026-11-28 14:45:02 +08:00
1 parent 986ffb632d
commit 50676ae78f
11 files changed
+81 -21

No files matched your search

@@ -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()
}
@@ -0,0 +1 @@
let isSingleRow = visible < 3
@@ -18,6 +18,10 @@
{
"find": "find.nut",
"replace": "replace.nut"
},
{
"find": "find-summary-layout.nut",
"replace": "replace-summary-layout.nut"
}
]
}
@@ -0,0 +1 @@
let isSingleRow = this.debriefingResult?.wtoSettled == true || visible < 3
@@ -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) {
@@ -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()
@@ -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
})
@@ -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"
}
]
}
@@ -0,0 +1,4 @@
debriefingResult.haveTeamkills <- debriefingResultHaveTeamkills()
debriefingResult.activeBoosters <- getDebriefingActiveBoosters()
debriefingResult.activeWager <- getDebriefingActiveWager()
debriefingResult.eventId <- getDebriefingEventId()
@@ -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()
@@ -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() ?? {})