mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
Review fixes: party close-out, member soft-lock, supply race, elite loot, season crown
Five bugs found reviewing n1-restoration end to end. beginCombatTurn settles any phase the engine owes before reading whose turn it is. That settle can end the fight — and the old code then answered "you're not in a fight" and returned. The terminal status was already persisted, so nothing ever paid the party out: no XP, no loot, no death recorded, no run teardown. The reaper cannot recover it either, because listExpiredCombatSessions filters on status='active'. Close the fight out there, the way the !fight start path and the reaper already do. A party member was permanently soft-locked when their leader extracted and never resumed. seatedExpeditionFor (the guard) spans 'extracting'; expeditionForMember (what !expedition leave resolved through) saw only 'active'. So the member was refused any new adventure by the guard and told "No active expedition" by the command the guard points them at, with nothing sweeping stale rows and only the leader able to clear one. Resolve the exit through the same lookup as the gate. updateSupplies overwrites supplies_json wholesale, and expeditionCmdAccept folded a member's packs onto a snapshot read before the coin debit, unlocked. Handlers run one goroutine per event, so two invitees accepting genuinely interleave and one member's packs vanish. advUserLock cannot help — it is keyed by sender, so racing members take different mutexes. Add advExpeditionLock and re-read the pool under it. Closes accept-vs-accept; the six other updateSupplies callers still race and are written up separately. runHarvestInterrupt picked an elite enemy and elite narration off a local `elite` flag, then passed a hardcoded false as isElite to closeOutZoneWin. dropZoneLoot gates masterwork on isBoss||isElite, so beating an elite interrupt skipped the masterwork roll and took standard treasure weight — while the same elite fought via !zone paid out correctly. arenaSeasonRollover marked its job complete even when recordArenaSeasonTitle failed, and JobCompleted short-circuits every later run for that quarter, so a transient SQLite BUSY lost the crown forever. Defer completion on failure; the insert is ON CONFLICT DO NOTHING against PRIMARY KEY (season, kind) and a past season's data is frozen, so the retry is safe. Also: drop dead partySurvivors, collapse the zoneCombatRoster alias into fightRoster, route partyCasualtyLine through joinNames, fold four copies of the expedition column projection into expeditionSelectCols, stop replyDM sending a blank DM, and correct two doc comments describing a path that no longer exists. Deliberately not fixed, with reasons, in gogobee_code_review_followups.md — most notably that both turn-based close-outs skip grantCombatAchievements and persistDnDPostCombatSubclass, which the auto-resolve paths run.
This commit is contained in:
@@ -186,6 +186,7 @@ func (p *AdventurePlugin) arenaSeasonRollover(now time.Time) {
|
||||
}
|
||||
|
||||
var lines []string
|
||||
failed := false
|
||||
for _, kind := range []string{arenaTitleEarnings, arenaTitleStreak} {
|
||||
uid, value, ok := arenaSeasonChampion(kind, start, end)
|
||||
if !ok {
|
||||
@@ -193,6 +194,7 @@ func (p *AdventurePlugin) arenaSeasonRollover(now time.Time) {
|
||||
}
|
||||
if err := recordArenaSeasonTitle(season, kind, uid, value, now); err != nil {
|
||||
slog.Error("arena season: record title failed", "season", season, "kind", kind, "err", err)
|
||||
failed = true
|
||||
continue // don't announce a crown we failed to persist
|
||||
}
|
||||
name, _ := loadDisplayName(uid)
|
||||
@@ -206,6 +208,14 @@ func (p *AdventurePlugin) arenaSeasonRollover(now time.Time) {
|
||||
}
|
||||
}
|
||||
|
||||
// Marking the job done is what stops the next midnight from retrying, so a
|
||||
// crown we failed to persist must not mark it. recordArenaSeasonTitle is
|
||||
// idempotent on (season, kind), and a past season's data is frozen, so the
|
||||
// retry re-derives the same champions and no-ops the ones already stored.
|
||||
if failed {
|
||||
slog.Warn("arena season: deferring completion after title failure", "season", season)
|
||||
return
|
||||
}
|
||||
db.MarkJobCompleted(jobName, season)
|
||||
if len(lines) == 0 {
|
||||
slog.Info("arena season: closed with no entrants", "season", season)
|
||||
|
||||
Reference in New Issue
Block a user