fix(chat): CH2 rework — SpewBox tick-driven visibility + binary-derived error table

Reworks Campaign CH slice CH2 per the REJECT-review findings doc
(docs/research/2026-08-09-ch2-review-findings.md).

BLOCKER 1 — SpewBoxController never rendered a line and leaked its
pending queue. LinesProvider only ran through UiText.OnDraw, which
gates on Visible — and the box started invisible, so the provider (the
sole caller of SpewBoxState.Tick) never ran. Gave the controller an
explicit per-frame Tick(now) driven by UiRoot's global-message-3
broadcast (a zero-size GlobalTimeSink child, the same pattern
VendorUiController.DragOverGlobalTimeSink already uses), matching
retail's gmSpewBoxUI::Update. LinesProvider now only returns the
cache. Tests rewritten to drive root.Tick(...) instead of calling the
provider directly, plus new coverage for visibility-without-a-draw,
queue-drain-without-a-draw, and bounded-queue-across-many-ticks.

BLOCKER 2 — re-derived the HandleFailureEvent routing table from the
PDB-paired binary instead of the pseudo-C's ~33-char string previews.
tools/pdb-extract/sweep_weenie_strings.py sweeps every push imm32 in
VA 0x571990-0x575480, dereferences into .rdata/.data, and decodes the
full UTF-16LE literal. Added the 5 ids dispatched via else-if (missed
by case-label enumeration), resolved 0x4F8 (previously excluded),
fixed 18 wrong strings (16 the review flagged + 2 more — 0x4E9 and
0x518 — an automated diff between every swept literal and the landed
table found). Every changed row cross-checked against ACE's
WeenieError/WeenieErrorWithString enum doc comments; both oracles
agreed on every row, including a case where the review's own proposed
text for the new 0x4E8 row was itself wrong (it was 0x4E9's text) —
corrected via the else-if block's own instruction address plus the ACE
cross-check. Pinned table count: 344 (338 + 5 + 0x4F8).

SHOULD-FIX 1 — RuntimeCommunicationState.ResetSpewBox was dead code;
folded into the ChatIdentity generation-reset stage (same lifetime
boundary), with a reset assertion added to the existing populated-reset
test.

SHOULD-FIX 2 — AddText trimmed only the trailing end and invented an
empty-string early return; retail's AddTextToScroll trims both ends
(trim(&str, 1, 1, ws)) and has no empty guard. Both retired.

SHOULD-FIX 3 — ShowWeenieError bypassed the AddText chokepoint via
ChatLog.OnWeenieError (hardcoded LogTextType 0x00); routed through
Communication.AddText(Resolve(code, param)) instead, and
ChatLog.OnWeenieError is deleted — GameEventWiring's legacy no-router
fallback now resolves + calls OnSystemMessage directly.

SHOULD-FIX 4 — retail's HandleFailureEvent switch has no default case;
an unmapped id now resolves to a null Text (silence toward the
player) instead of the invented "WeenieError 0xNNNN" hex fallback,
with a diagnostics-only console log line for the id.

NITs — AP-TBD placeholders corrected to their real register rows
(AP-178, not the unrelated AP-177 lifetime row); filed AP-180 for the
windowId dual-destination gap and corrected three stale "lands with
CH2" comments; extended SpewBoxLayoutDumpDiagnostic from dats.Portal
to dats.Local and found the SpewBox element for real — LayoutDesc
0x21000011, element 0x10000048, size 450x72, MaxConcurrentItems
(ListBox property 0x10000028) = 4, not retail's code default of 1.
AP-178 narrowed accordingly; SpewBoxState.MaxConcurrentItems and
SpewBoxController's extent/anchor/OneLine are now authored rather than
placeholder (absolute screen position and colour remain open); fixed
the "19 ids... lists 18" miscount by retiring the stale paragraph in
the class doc rewrite; aligned the UseDone handler's silent-status
check with the other two WeenieError handlers.

Full Release suite: 11,914 passed / 4 skipped / 0 failed (build 0
errors).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-09 18:14:08 +02:00
parent b3ba4c6663
commit e0e7888308
22 changed files with 1164 additions and 336 deletions

View file

@ -248,39 +248,53 @@ public static class GameEventWiring
// Campaign CH slice CH2: retail resolves BOTH the display text and
// the AddTextToScroll destination type from the SAME per-id switch
// (ClientCommunicationSystem::HandleFailureEvent @0x00571990 — see
// WeenieErrorMessages' full 338-row port). When a router is wired
// WeenieErrorMessages' full 344-row port). When a router is wired
// (the production path), the resolved type decides chat vs SpewBox;
// otherwise this falls back to the legacy chat-only path so callers
// that don't wire the router (older tests) keep their prior shape.
// otherwise this falls back to a direct chat append so callers that
// don't wire the router (older tests) keep a working, if
// SpewBox-less, path.
//
// REJECT-review rework (SHOULD-FIX 3/4,
// docs/research/2026-08-09-ch2-review-findings.md): the legacy
// fallback no longer routes through the deleted ChatLog.OnWeenieError
// (SHOULD-FIX 3 — that chokepoint bypass is retired everywhere, not
// just at the ShowWeenieError call site) and an unmapped id resolves
// to a null Text — retail's switch has no default case, so it
// produces NO text toward the player (SHOULD-FIX 4). Both branches
// below skip display for a null Text and log the raw id instead, so
// an unmapped code stays visible to US without ever reaching chat.
registrar.Register(GameEventType.WeenieError, e =>
{
var code = GameEvents.ParseWeenieError(e.Payload.Span);
if (code is null) return;
if (WeenieErrorMessages.IsSilentClientControlStatus(code.Value)) return;
var (text, type) = WeenieErrorMessages.Resolve(code.Value, null);
if (text is null)
{
Console.WriteLine($"[weenie-error] unmapped code=0x{code.Value:X4}");
return;
}
if (onInterfaceText is not null)
{
if (WeenieErrorMessages.IsSilentClientControlStatus(code.Value)) return;
var (text, type) = WeenieErrorMessages.Resolve(code.Value, null);
onInterfaceText(text, type);
}
else
{
chat.OnWeenieError(code.Value, param: null);
}
chat.OnSystemMessage(text, chatType: (uint)type);
});
registrar.Register(GameEventType.WeenieErrorWithString, e =>
{
var p = GameEvents.ParseWeenieErrorWithString(e.Payload.Span);
if (p is null) return;
if (WeenieErrorMessages.IsSilentClientControlStatus(p.Value.ErrorCode)) return;
var (text, type) = WeenieErrorMessages.Resolve(p.Value.ErrorCode, p.Value.Interpolation);
if (text is null)
{
Console.WriteLine(
$"[weenie-error] unmapped code=0x{p.Value.ErrorCode:X4} param={p.Value.Interpolation}");
return;
}
if (onInterfaceText is not null)
{
if (WeenieErrorMessages.IsSilentClientControlStatus(p.Value.ErrorCode)) return;
var (text, type) = WeenieErrorMessages.Resolve(p.Value.ErrorCode, p.Value.Interpolation);
onInterfaceText(text, type);
}
else
{
chat.OnWeenieError(p.Value.ErrorCode, p.Value.Interpolation);
}
chat.OnSystemMessage(text, chatType: (uint)type);
});
// ── Combat ────────────────────────────────────────────────
@ -590,11 +604,27 @@ public static class GameEventWiring
+ $"err={(err is null ? "n/a" : $"0x{err.Value:X4}")}");
}
if (err is null) return;
// Already the diagnostics-only log line SHOULD-FIX 4 asks for —
// it fires unconditionally, so an unmapped code below stays
// visible to US even though it produces no player-facing text.
Console.WriteLine($"[use-done] err=0x{err.Value:X4}");
onUseDone?.Invoke(err.Value);
if (err.Value == 0) return;
// NIT 6 (docs/research/2026-08-09-ch2-review-findings.md):
// aligned with the WeenieError/WeenieErrorWithString handlers
// above, which check this before resolving. Harmless either
// way today — 0x3B/0x3C have no HandleFailureEvent case, so
// WeenieErrorMessages.Resolve already returns a null Text for
// them — but an explicit early-out here is more direct than
// relying on that coincidence, and guards against a future
// table addition accidentally making one of these two
// resolvable when retail's own switch genuinely has no case
// for either.
if (WeenieErrorMessages.IsSilentClientControlStatus(err.Value)) return;
var (text, type) = WeenieErrorMessages.Resolve(err.Value, null);
if (text is null) return;
if (onInterfaceText is not null)
onInterfaceText(text, type);
else