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:
parent
b3ba4c6663
commit
e0e7888308
22 changed files with 1164 additions and 336 deletions
|
|
@ -4,6 +4,17 @@ using AcDream.UI.Abstractions.Panels.SpewBox;
|
|||
|
||||
namespace AcDream.App.Tests.UI;
|
||||
|
||||
/// <summary>
|
||||
/// CH2 REJECT-review rework, BLOCKER 1
|
||||
/// (<c>docs/research/2026-08-09-ch2-review-findings.md</c>): these tests
|
||||
/// drive the controller's frame hook (<c>UiRoot.Tick</c>, the global-message-3
|
||||
/// broadcast) rather than calling <c>UiText.LinesProvider</c> directly. The
|
||||
/// original tests invoked the provider straight through, bypassing the
|
||||
/// <c>Visible</c> gate that <c>UiText.OnDraw</c> checks before ever polling
|
||||
/// it — that is exactly why the original bug (start-invisible → provider
|
||||
/// never called by drawing → no line ever visible, pending queue never
|
||||
/// drains) was invisible to the original test suite.
|
||||
/// </summary>
|
||||
public sealed class SpewBoxControllerTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
@ -18,13 +29,18 @@ public sealed class SpewBoxControllerTests
|
|||
|
||||
using (var controller = new SpewBoxController(root, new SpewBoxVM(state)))
|
||||
{
|
||||
UiText text = Assert.IsType<UiText>(Assert.Single(root.Children));
|
||||
UiText text = Assert.IsType<UiText>(root.Children.OfType<UiText>().Single());
|
||||
Assert.False(text.Visible);
|
||||
Assert.True(text.ClickThrough);
|
||||
Assert.Equal(int.MaxValue, text.ZOrder);
|
||||
|
||||
state.Enqueue("You can't jump while in the air");
|
||||
|
||||
// Drive the frame hook, NOT the provider — this is the tick
|
||||
// that drains the pending queue in production, wired through
|
||||
// UiRoot.Tick's IUiGlobalTimeListener broadcast.
|
||||
root.Tick(dt: 0d, nowMs: 1000L);
|
||||
|
||||
UiText.Line line = Assert.Single(text.LinesProvider!());
|
||||
Assert.Equal("You can't jump while in the air", line.Text);
|
||||
Assert.True(text.Visible);
|
||||
|
|
@ -39,8 +55,92 @@ public sealed class SpewBoxControllerTests
|
|||
var root = new UiRoot { Width = 1280f, Height = 720f };
|
||||
using var controller = new SpewBoxController(root, new SpewBoxVM(new SpewBoxState()));
|
||||
|
||||
UiText text = Assert.IsType<UiText>(Assert.Single(root.Children));
|
||||
root.Tick(dt: 0d, nowMs: 1000L);
|
||||
|
||||
UiText text = Assert.IsType<UiText>(root.Children.OfType<UiText>().Single());
|
||||
Assert.Empty(text.LinesProvider!());
|
||||
Assert.False(text.Visible);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Controller_BecomesVisible_WithoutAnyDrawHavingHappenedFirst()
|
||||
{
|
||||
// BLOCKER 1 acceptance (a): the original bug was start-invisible →
|
||||
// LinesProvider only reachable through UiElement.DrawSelfAndChildren
|
||||
// (which returns early on !Visible) → provider never called → never
|
||||
// visible. This test never calls anything draw-shaped — no OnDraw,
|
||||
// no DrawSelfAndChildren, no UiRenderContext — only the tick.
|
||||
var root = new UiRoot { Width = 1280f, Height = 720f };
|
||||
var state = new SpewBoxState();
|
||||
using var controller = new SpewBoxController(root, new SpewBoxVM(state));
|
||||
|
||||
UiText text = Assert.IsType<UiText>(root.Children.OfType<UiText>().Single());
|
||||
Assert.False(text.Visible);
|
||||
|
||||
state.Enqueue("Out of Range!");
|
||||
root.Tick(dt: 0d, nowMs: 500L);
|
||||
|
||||
Assert.True(text.Visible);
|
||||
Assert.Equal("Out of Range!", Assert.Single(text.LinesProvider!()).Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Controller_PendingQueueDrains_WithoutAnyDrawPass()
|
||||
{
|
||||
// BLOCKER 1 acceptance (b): SpewBoxState.Tick is the only caller
|
||||
// that drains _pending (SpewBoxState.cs's Queue<string>). Before the
|
||||
// fix, that call only happened inside LinesProvider, which drawing
|
||||
// gated behind Visible — so the pending queue was an unbounded
|
||||
// per-session leak. Enqueue, tick the frame hook, and assert the
|
||||
// underlying state actually drained (Count reflects the visible
|
||||
// set, not the still-pending queue) — never touching drawing.
|
||||
var root = new UiRoot { Width = 1280f, Height = 720f };
|
||||
var state = new SpewBoxState();
|
||||
using var controller = new SpewBoxController(root, new SpewBoxVM(state));
|
||||
|
||||
state.Enqueue("first");
|
||||
Assert.Equal(0, state.Count); // still pending, not yet drained
|
||||
|
||||
root.Tick(dt: 0d, nowMs: 100L);
|
||||
|
||||
Assert.Equal(1, state.Count); // drained into the visible list
|
||||
Assert.Equal("first", state.Snapshot()[0].Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Controller_QueueStaysBounded_AcrossManyTicksWithoutADrawPass()
|
||||
{
|
||||
// BLOCKER 1 acceptance (c): repeated enqueue+tick cycles must never
|
||||
// let the visible set grow past SpewBoxState.MaxConcurrentItems
|
||||
// (retail's code default, 1) — this is what "unbounded per-session
|
||||
// leak" would have looked like if the drain never ran at all.
|
||||
var root = new UiRoot { Width = 1280f, Height = 720f };
|
||||
var state = new SpewBoxState();
|
||||
using var controller = new SpewBoxController(root, new SpewBoxVM(state));
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
state.Enqueue($"line {i}");
|
||||
root.Tick(dt: 0d, nowMs: 1000L + i);
|
||||
Assert.True(state.Count <= SpewBoxState.MaxConcurrentItems);
|
||||
}
|
||||
|
||||
UiText text = Assert.IsType<UiText>(root.Children.OfType<UiText>().Single());
|
||||
Assert.True(text.LinesProvider!().Count <= SpewBoxState.MaxConcurrentItems);
|
||||
// Newest-at-top, matching retail's InsertItem(item, 0).
|
||||
Assert.Equal("line 49", text.LinesProvider!()[0].Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Dispose_RemovesBothTheTextAndTheGlobalTimeSinkFromTheRoot()
|
||||
{
|
||||
var root = new UiRoot { Width = 1280f, Height = 720f };
|
||||
var controller = new SpewBoxController(root, new SpewBoxVM(new SpewBoxState()));
|
||||
|
||||
Assert.Equal(2, root.Children.Count); // UiText + the tick sink
|
||||
|
||||
controller.Dispose();
|
||||
|
||||
Assert.Empty(root.Children);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,14 +33,32 @@ namespace AcDream.App.Tests.UI;
|
|||
/// appears to reference — exists but has zero top-level elements (it is
|
||||
/// not the per-line template catalog; that id must resolve through a
|
||||
/// different mechanism than a direct <c>dats.Get<LayoutDesc></c> hit,
|
||||
/// which this slice did not crack). Conclusion: <c>gmSpewBoxUI</c> is
|
||||
/// mounted directly from C++ code in <c>gmClient</c>'s HUD registration
|
||||
/// block (research doc §1.1) rather than resolved from any authored
|
||||
/// LayoutDesc tree — its position/extent/font/color/max-items are NOT
|
||||
/// recoverable via this dump technique. Every value the SpewBox
|
||||
/// presentation uses below is therefore an invented placeholder with its
|
||||
/// own divergence-register row, exactly as the research doc's §3.2
|
||||
/// PRESENTATION-UNKNOWN section predicted.
|
||||
/// which this slice did not crack).
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// <b>RESULT 2, CH2 REJECT-review rework NIT 3
|
||||
/// (2026-08-09, docs/research/2026-08-09-ch2-review-findings.md):</b> the
|
||||
/// FIRST result above only ever swept <c>dats.Portal</c>. Extending the
|
||||
/// IDENTICAL sweep to <c>dats.Local</c> (<c>client_local_English.dat</c>)
|
||||
/// FINDS it: LayoutDesc <c>0x21000011</c>, element <c>0x10000048</c>
|
||||
/// (class <c>0x10000016</c>), position <c>(0,0)</c> relative to its parent,
|
||||
/// size <c>450×72</c>, one child — ListBox <c>0x10000049</c> (matching
|
||||
/// <c>gmSpewBoxUI::PostInit</c>'s <c>GetChildRecursive(0x10000049)</c> call
|
||||
/// verbatim, though its own widget-class <c>Type</c> is <c>0x00000005</c>,
|
||||
/// NOT the id <c>0x10000049</c> — <c>GetChildRecursive</c> searches by
|
||||
/// <c>ElementId</c>, not <c>Type</c>) — carrying <c>MaxConcurrentItems</c>
|
||||
/// (property <c>0x10000028</c>) = <c>4</c>. <c>gmSpewBoxUI</c> IS
|
||||
/// dat-authored after all; the earlier "mounted directly from C++ code...
|
||||
/// not resolved from any authored LayoutDesc tree" conclusion was an
|
||||
/// artifact of only having checked one of the two locale-bearing dats.
|
||||
/// Extent and <c>MaxConcurrentItems</c> are now AUTHORED, not invented —
|
||||
/// see <see cref="AcDream.Core.Chat.SpewBoxState.MaxConcurrentItems"/> and
|
||||
/// <c>SpewBoxController</c>'s own doc comments, and register row AP-178.
|
||||
/// Absolute screen position (the element's parent, hence its true screen
|
||||
/// offset, is still unidentified) and colour (no colour property surfaced
|
||||
/// in this element's direct-state dump; the per-<c>UIStateId</c>
|
||||
/// <c>States</c> dictionary was not walked) remain open.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public sealed class SpewBoxLayoutDumpDiagnostic
|
||||
|
|
@ -118,7 +136,7 @@ public sealed class SpewBoxLayoutDumpDiagnostic
|
|||
_out.WriteLine(
|
||||
$" ListBox child 0x{listBox.ElementId:X8} "
|
||||
+ $"pos=({listBox.X},{listBox.Y}) size=({listBox.Width}x{listBox.Height})");
|
||||
DumpProperties(listBox, " ");
|
||||
DumpProperties(listBox, " ", _out.WriteLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -139,7 +157,7 @@ public sealed class SpewBoxLayoutDumpDiagnostic
|
|||
_out.WriteLine(
|
||||
$" Line template 0x{LineTemplateElementId:X8}: type=0x{lineTemplate.Type:X8} "
|
||||
+ $"pos=({lineTemplate.X},{lineTemplate.Y}) size=({lineTemplate.Width}x{lineTemplate.Height})");
|
||||
DumpProperties(lineTemplate, " ");
|
||||
DumpProperties(lineTemplate, " ", _out.WriteLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -151,6 +169,95 @@ public sealed class SpewBoxLayoutDumpDiagnostic
|
|||
_out.WriteLine($"LayoutDesc 0x{LineTemplateLayoutEnum:X8} does not exist in the installed DAT.");
|
||||
}
|
||||
|
||||
// CH2 REJECT-review rework, NIT 3
|
||||
// (docs/research/2026-08-09-ch2-review-findings.md): the original
|
||||
// sweep above never consulted dats.Local (client_local_English.dat
|
||||
// — research doc §8.1 names this file, not client_portal.dat, as
|
||||
// the one that might carry locale-specific UI text/layout
|
||||
// resources). Repeat the exact same class-0x10000016 sweep against
|
||||
// Local's own LayoutDesc id space before trusting AP-178's
|
||||
// "not dat-authored, no LayoutDesc dump can recover this" wording.
|
||||
var localHits = new List<(uint LayoutId, ElementDesc Element)>();
|
||||
int localScanned = 0;
|
||||
List<uint> localIds = dats.Local.GetAllIdsOfType<LayoutDesc>().ToList();
|
||||
_out.WriteLine($"Local.GetAllIdsOfType<LayoutDesc> count: {localIds.Count}");
|
||||
if (localIds.Count > 0)
|
||||
_out.WriteLine($"Local min id: 0x{localIds.Min():X8} Local max id: 0x{localIds.Max():X8}");
|
||||
|
||||
foreach (uint layoutId in localIds)
|
||||
{
|
||||
localScanned++;
|
||||
if (!dats.Local.TryGet<LayoutDesc>(layoutId, out LayoutDesc? ld) || ld is null)
|
||||
continue;
|
||||
|
||||
foreach (var kv in ld.Elements)
|
||||
{
|
||||
var found = FindByType(kv.Value, SpewBoxElementClass);
|
||||
if (found is not null)
|
||||
localHits.Add((layoutId, found));
|
||||
}
|
||||
}
|
||||
|
||||
_out.WriteLine($"Scanned {localScanned} dats.Local LayoutDescs.");
|
||||
_out.WriteLine(
|
||||
$"dats.Local elements of class 0x{SpewBoxElementClass:X8} (gmSpewBoxUI): {localHits.Count}");
|
||||
|
||||
foreach (var (layoutId, element) in localHits)
|
||||
{
|
||||
_out.WriteLine(
|
||||
$" [Local] LayoutDesc 0x{layoutId:X8} -> element 0x{element.ElementId:X8} "
|
||||
+ $"pos=({element.X},{element.Y}) size=({element.Width}x{element.Height}) "
|
||||
+ $"zLevel={element.ZLevel} readOrder={element.ReadOrder} "
|
||||
+ $"leftEdge={element.LeftEdge} topEdge={element.TopEdge} "
|
||||
+ $"rightEdge={element.RightEdge} bottomEdge={element.BottomEdge} "
|
||||
+ $"baseElement=0x{element.BaseElement:X8} baseLayoutId=0x{element.BaseLayoutId:X8} "
|
||||
+ $"children={element.Children.Count}");
|
||||
DumpProperties(element, " ", _out.WriteLine);
|
||||
foreach (var (childId, child) in element.Children)
|
||||
{
|
||||
_out.WriteLine(
|
||||
$" child 0x{childId:X8}: type=0x{child.Type:X8} "
|
||||
+ $"pos=({child.X},{child.Y}) size=({child.Width}x{child.Height})");
|
||||
DumpProperties(child, " ", _out.WriteLine);
|
||||
}
|
||||
|
||||
// NIT 3 finding: gmSpewBoxUI::PostInit's GetChildRecursive(0x10000049)
|
||||
// searches by ELEMENT ID, not by the widget CLASS (Type) —
|
||||
// ListBoxElementClass below was the wrong axis to search on
|
||||
// (it collided with the decomp's 0x10000049 constant, which is
|
||||
// actually this instance's authored ElementId; the ListBox
|
||||
// widget's own Type turned out to be 0x00000005). Look the
|
||||
// child up directly by the ElementId the decomp names.
|
||||
if (element.Children.TryGetValue(ListBoxElementClass, out ElementDesc? listBoxById))
|
||||
{
|
||||
_out.WriteLine(
|
||||
$" [Local] ListBox-by-ElementId 0x{listBoxById.ElementId:X8} "
|
||||
+ $"(Type=0x{listBoxById.Type:X8}) "
|
||||
+ $"pos=({listBoxById.X},{listBoxById.Y}) size=({listBoxById.Width}x{listBoxById.Height})");
|
||||
}
|
||||
|
||||
var listBox = FindByType(element, ListBoxElementClass);
|
||||
if (listBox is not null)
|
||||
{
|
||||
_out.WriteLine(
|
||||
$" [Local] ListBox-by-Type child 0x{listBox.ElementId:X8} "
|
||||
+ $"pos=({listBox.X},{listBox.Y}) size=({listBox.Width}x{listBox.Height})");
|
||||
DumpProperties(listBox, " ", _out.WriteLine);
|
||||
}
|
||||
}
|
||||
|
||||
if (dats.Local.TryGet<LayoutDesc>(LineTemplateLayoutEnum, out LayoutDesc? localTemplateLd)
|
||||
&& localTemplateLd is not null)
|
||||
{
|
||||
_out.WriteLine(
|
||||
$"[Local] LayoutDesc 0x{LineTemplateLayoutEnum:X8} exists "
|
||||
+ $"({localTemplateLd.Elements.Count} top-level elements).");
|
||||
}
|
||||
else
|
||||
{
|
||||
_out.WriteLine($"[Local] LayoutDesc 0x{LineTemplateLayoutEnum:X8} does not exist.");
|
||||
}
|
||||
|
||||
// Informational only — this is a discovery sweep, not a pass/fail gate.
|
||||
// The findings are transcribed into WeenieErrorMessages/SpewBoxController
|
||||
// doc comments and the divergence register by hand after reading this
|
||||
|
|
@ -170,17 +277,24 @@ public sealed class SpewBoxLayoutDumpDiagnostic
|
|||
return null;
|
||||
}
|
||||
|
||||
private static void DumpProperties(ElementDesc d, string indent)
|
||||
private static void DumpProperties(ElementDesc d, string indent, Action<string> write)
|
||||
{
|
||||
// NIT 3 fix (docs/research/2026-08-09-ch2-review-findings.md): this
|
||||
// used to write to Console.WriteLine unconditionally, which xUnit's
|
||||
// "Standard Output Messages" capture does NOT show — a latent bug
|
||||
// that only mattered once a hit with an actual property to dump
|
||||
// existed (the original Portal-only sweep found none). Routed
|
||||
// through the caller's ITestOutputHelper.WriteLine so a future run
|
||||
// actually surfaces this.
|
||||
if (d.StateDesc?.Properties is null)
|
||||
{
|
||||
System.Console.WriteLine($"{indent}(no direct-state properties)");
|
||||
write($"{indent}(no direct-state properties)");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var (propertyId, property) in d.StateDesc.Properties)
|
||||
{
|
||||
System.Console.WriteLine($"{indent}property 0x{propertyId:X8} = {Describe(property)}"
|
||||
write($"{indent}property 0x{propertyId:X8} = {Describe(property)}"
|
||||
+ (propertyId == ListBoxMaxItemsProperty ? " <-- MaxConcurrentItems" : ""));
|
||||
}
|
||||
}
|
||||
|
|
@ -190,6 +304,12 @@ public sealed class SpewBoxLayoutDumpDiagnostic
|
|||
DatReaderWriter.Types.EnumBaseProperty e => $"Enum({e.Value})",
|
||||
DatReaderWriter.Types.DataIdBaseProperty did => $"DataId(0x{did.Value:X8})",
|
||||
DatReaderWriter.Types.ArrayBaseProperty arr => $"Array[{arr.Value.Count}]({string.Join(", ", arr.Value.Select(Describe))})",
|
||||
// NIT 3 fix: the original switch had no case for these two —
|
||||
// Integer is exactly the type MaxConcurrentItems (property
|
||||
// 0x10000028) uses, so without this case the diagnostic could
|
||||
// find the property but never print its actual authored value.
|
||||
DatReaderWriter.Types.IntegerBaseProperty i => $"Integer({i.Value})",
|
||||
DatReaderWriter.Types.BoolBaseProperty b => $"Bool({b.Value})",
|
||||
_ => property.ToString() ?? "?",
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -704,11 +704,15 @@ public sealed class GameEventWiringTests
|
|||
// Phase I.5: 0x028A previously had a parser
|
||||
// (GameEvents.ParseWeenieError) but no dispatcher registration. The
|
||||
// server fires this for plain game-logic failures (e.g. "you can't
|
||||
// pick that up"). Now wired → ChatLog.OnWeenieError.
|
||||
// pick that up"). Now wired → WeenieErrorMessages.Resolve +
|
||||
// ChatLog.OnSystemMessage (the legacy no-router fallback;
|
||||
// REJECT-review rework SHOULD-FIX 3 deleted the dedicated
|
||||
// ChatLog.OnWeenieError chokepoint-bypass — see
|
||||
// docs/research/2026-08-09-ch2-review-findings.md).
|
||||
var (d, _, _, _, chat) = MakeAll();
|
||||
|
||||
byte[] payload = new byte[4];
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(payload, 0x9C); // arbitrary error code
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(payload, 0x04Au); // Ack! You killed yourself! (Default)
|
||||
|
||||
var env = GameEventEnvelope.TryParse(WrapEnvelope(GameEventType.WeenieError, payload));
|
||||
d.Dispatch(env!.Value);
|
||||
|
|
@ -716,8 +720,29 @@ public sealed class GameEventWiringTests
|
|||
Assert.Equal(1, chat.Count);
|
||||
var e = chat.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.System, e.Kind);
|
||||
Assert.Equal(0x9Cu, e.ChannelId);
|
||||
Assert.Contains("0x009C", e.Text);
|
||||
Assert.Equal("Ack! You killed yourself!", e.Text);
|
||||
Assert.Equal(0x00u, e.LogTextType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WireAll_WeenieError_UnmappedCode_DoesNotReachChat()
|
||||
{
|
||||
// REJECT-review rework (SHOULD-FIX 4,
|
||||
// docs/research/2026-08-09-ch2-review-findings.md): retail's
|
||||
// HandleFailureEvent switch has no default case — an id it does not
|
||||
// recognize produces NO text at all, silently, toward the player.
|
||||
// The prior "WeenieError 0xNNNN" hex-fallback framing this test
|
||||
// used to pin was acdream's own invention with no retail
|
||||
// counterpart — an unregistered divergence, now retired.
|
||||
var (d, _, _, _, chat) = MakeAll();
|
||||
|
||||
byte[] payload = new byte[4];
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(payload, 0x9C); // arbitrary unmapped error code
|
||||
|
||||
var env = GameEventEnvelope.TryParse(WrapEnvelope(GameEventType.WeenieError, payload));
|
||||
d.Dispatch(env!.Value);
|
||||
|
||||
Assert.Equal(0, chat.Count);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -739,8 +764,29 @@ public sealed class GameEventWiringTests
|
|||
public void WireAll_WeenieErrorWithString_RoutesToChatLogWithInterpolation()
|
||||
{
|
||||
// Phase I.5: 0x028B carries an interpolated substring (e.g. the
|
||||
// target's name in "you can't pick up the {Mana Stone}"). Now
|
||||
// wired → ChatLog.OnWeenieError with the param.
|
||||
// target's name). Now wired → WeenieErrorMessages.Resolve +
|
||||
// ChatLog.OnSystemMessage (the legacy no-router fallback).
|
||||
var (d, _, _, _, chat) = MakeAll();
|
||||
|
||||
byte[] interpBytes = MakeString16L("Caith");
|
||||
byte[] payload = new byte[4 + interpBytes.Length];
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(payload, 0x0521u); // "%s has been added to the list of people you can hear."
|
||||
Array.Copy(interpBytes, 0, payload, 4, interpBytes.Length);
|
||||
|
||||
var env = GameEventEnvelope.TryParse(WrapEnvelope(GameEventType.WeenieErrorWithString, payload));
|
||||
d.Dispatch(env!.Value);
|
||||
|
||||
Assert.Equal(1, chat.Count);
|
||||
var e = chat.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.System, e.Kind);
|
||||
Assert.Equal("Caith has been added to the list of people you can hear.", e.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WireAll_WeenieErrorWithString_UnmappedCode_DoesNotReachChat()
|
||||
{
|
||||
// REJECT-review rework (SHOULD-FIX 4): same retail-faithful silence
|
||||
// as the plain WeenieError case above.
|
||||
var (d, _, _, _, chat) = MakeAll();
|
||||
|
||||
byte[] interpBytes = MakeString16L("Mana Stone");
|
||||
|
|
@ -751,11 +797,7 @@ public sealed class GameEventWiringTests
|
|||
var env = GameEventEnvelope.TryParse(WrapEnvelope(GameEventType.WeenieErrorWithString, payload));
|
||||
d.Dispatch(env!.Value);
|
||||
|
||||
Assert.Equal(1, chat.Count);
|
||||
var e = chat.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.System, e.Kind);
|
||||
Assert.Equal(0x42u, e.ChannelId);
|
||||
Assert.Contains("Mana Stone", e.Text);
|
||||
Assert.Equal(0, chat.Count);
|
||||
}
|
||||
|
||||
// ── Campaign CH slice CH2: onInterfaceText routing ───────────────────
|
||||
|
|
|
|||
|
|
@ -131,38 +131,14 @@ public sealed class ChatLogTests
|
|||
Assert.Equal(0x90ABCDEFu, e.ChannelId); // killer guid stashed here
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnWeenieError_PlainCode_AppendsSystemEntry()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
log.OnWeenieError(errorId: 0x1234, param: null);
|
||||
var e = log.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.System, e.Kind);
|
||||
Assert.Contains("0x1234", e.Text);
|
||||
Assert.Equal(0x1234u, e.ChannelId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnWeenieError_WithString_AppendsInterpolation()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
log.OnWeenieError(errorId: 0x5678, param: "Mana Stone");
|
||||
var e = log.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.System, e.Kind);
|
||||
Assert.Contains("Mana Stone", e.Text);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0x003Bu)] // ILeftTheWorld
|
||||
[InlineData(0x003Cu)] // ITeleported
|
||||
public void OnWeenieError_RetailSilentClientControlStatus_DoesNotAppend(uint code)
|
||||
{
|
||||
var log = new ChatLog();
|
||||
|
||||
log.OnWeenieError(code, param: null);
|
||||
|
||||
Assert.Empty(log.Snapshot());
|
||||
}
|
||||
// OnWeenieError-specific tests (plain code, interpolation, silent
|
||||
// client-control statuses) were removed here — REJECT-review rework
|
||||
// (SHOULD-FIX 3, docs/research/2026-08-09-ch2-review-findings.md)
|
||||
// deletes ChatLog.OnWeenieError itself; every producer now resolves via
|
||||
// WeenieErrorMessages and calls the AddText chokepoint / OnSystemMessage
|
||||
// directly. Equivalent coverage lives in GameEventWiringTests.cs (the
|
||||
// inbound wire path) and WeenieErrorMessagesTests.cs (the resolve
|
||||
// table), including the silent-client-control-status behavior.
|
||||
|
||||
[Fact]
|
||||
public void OnLocalSpeech_EmptySender_SubstitutesYou()
|
||||
|
|
@ -256,14 +232,6 @@ public sealed class ChatLogTests
|
|||
Assert.Equal(0x00u, log.Snapshot()[0].LogTextType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnWeenieError_LogTextType_IsDefault()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
log.OnWeenieError(errorId: 0x1234, param: null);
|
||||
Assert.Equal(0x00u, log.Snapshot()[0].LogTextType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnPopup_LogTextType_IsDefault()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,23 +37,22 @@ public sealed class SpewBoxStateTests
|
|||
[Fact]
|
||||
public void Tick_InsertsNewestAtIndexZero()
|
||||
{
|
||||
// Retail: InsertItem(item, 0) — with MaxConcurrentItems raised past
|
||||
// the code default of 1, newer entries must lead the visible list.
|
||||
// Retail: InsertItem(item, 0) — CH2 REJECT-review rework NIT 3
|
||||
// raised MaxConcurrentItems from the code default (1) to the
|
||||
// AUTHORED LayoutDesc value (4, see SpewBoxState.MaxConcurrentItems's
|
||||
// own doc comment), so two entries now comfortably coexist without
|
||||
// triggering the overflow rule — this test can assert the ordering
|
||||
// guarantee directly instead of relying on eviction as a side effect.
|
||||
var state = new SpewBoxState();
|
||||
state.Enqueue("first");
|
||||
state.Tick(0d);
|
||||
state.Enqueue("second");
|
||||
state.Tick(0d);
|
||||
|
||||
// MaxConcurrentItems == 1 (retail code default) means "first" was
|
||||
// already evicted by the overflow rule — assert directly on the
|
||||
// ordering guarantee instead by forcing a raised cap via reflection
|
||||
// is out of scope; the dedupe/overflow tests below cover that
|
||||
// interaction precisely. Here we only need the single surviving
|
||||
// entry to be "second" (the newest), proving insert-at-front beat
|
||||
// whatever eviction order a stack (insert-at-back) would produce.
|
||||
SpewBoxEntry entry = Assert.Single(state.Snapshot());
|
||||
Assert.Equal("second", entry.Text);
|
||||
Assert.Equal(2, state.Count);
|
||||
SpewBoxEntry[] snapshot = state.Snapshot();
|
||||
Assert.Equal("second", snapshot[0].Text);
|
||||
Assert.Equal("first", snapshot[1].Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -78,33 +77,43 @@ public sealed class SpewBoxStateTests
|
|||
[Fact]
|
||||
public void Tick_DifferentText_DoesNotDedupe()
|
||||
{
|
||||
// CH2 REJECT-review rework NIT 3: with the AUTHORED
|
||||
// MaxConcurrentItems == 4, two distinct messages both fit without
|
||||
// any eviction — dedupe (index-0-only) is the only thing that could
|
||||
// collapse them, and it correctly does not apply to different text.
|
||||
var state = new SpewBoxState();
|
||||
state.Enqueue("first message");
|
||||
state.Tick(0d);
|
||||
state.Enqueue("second message");
|
||||
state.Tick(0d);
|
||||
|
||||
// With MaxConcurrentItems == 1, "second message" evicts "first
|
||||
// message" via overflow, not dedupe — either way only one survives,
|
||||
// and it must be the newest.
|
||||
SpewBoxEntry entry = Assert.Single(state.Snapshot());
|
||||
Assert.Equal("second message", entry.Text);
|
||||
Assert.Equal(2, state.Count);
|
||||
SpewBoxEntry[] snapshot = state.Snapshot();
|
||||
Assert.Equal("second message", snapshot[0].Text);
|
||||
Assert.Equal("first message", snapshot[1].Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tick_Overflow_DropsOldest_RespectingMaxConcurrentItems()
|
||||
{
|
||||
// CH2 REJECT-review rework NIT 3: MaxConcurrentItems is the
|
||||
// AUTHORED LayoutDesc value (4), not retail's code default (1) —
|
||||
// enqueue past the cap to actually exercise the overflow rule.
|
||||
var state = new SpewBoxState();
|
||||
Assert.Equal(1, SpewBoxState.MaxConcurrentItems);
|
||||
Assert.Equal(4, SpewBoxState.MaxConcurrentItems);
|
||||
|
||||
state.Enqueue("oldest");
|
||||
state.Tick(0d);
|
||||
state.Enqueue("newer");
|
||||
state.Tick(0d);
|
||||
for (int i = 0; i < SpewBoxState.MaxConcurrentItems + 1; i++)
|
||||
{
|
||||
state.Enqueue($"line {i}");
|
||||
state.Tick(0d);
|
||||
}
|
||||
|
||||
Assert.Equal(SpewBoxState.MaxConcurrentItems, state.Count);
|
||||
SpewBoxEntry entry = Assert.Single(state.Snapshot());
|
||||
Assert.Equal("newer", entry.Text);
|
||||
SpewBoxEntry[] snapshot = state.Snapshot();
|
||||
// Newest at index 0; "line 0" (the oldest) dropped by overflow.
|
||||
Assert.Equal("line 4", snapshot[0].Text);
|
||||
Assert.Equal("line 1", snapshot[3].Text);
|
||||
Assert.DoesNotContain(snapshot, e => e.Text == "line 0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -42,18 +42,22 @@ public sealed class WeenieErrorMessagesTests
|
|||
// ── known codes — informational, no parameter ────────────────────
|
||||
|
||||
[Fact]
|
||||
public void Format_0x051D_FallsBackToHex_NoRetailCaseExists()
|
||||
public void Format_0x051D_ReturnsNull_NoRetailCaseExists()
|
||||
{
|
||||
// Campaign CH slice CH2: the pre-CH2 "Turbine Chat is enabled."
|
||||
// text for 0x051D was an ACE-derived guess, never decomp-confirmed.
|
||||
// The full HandleFailureEvent port found NO case for 0x51D anywhere
|
||||
// in the switch (only 0x51C has one — case 0x51c: at raw line
|
||||
// 383115-383118 of acclient_2013_pseudo_c.txt) — retail's own
|
||||
// client simply has no display text for this id. Falling back to
|
||||
// the generic form is now the retail-faithful answer, not a gap.
|
||||
Assert.Equal(
|
||||
"WeenieError 0x051D",
|
||||
WeenieErrorMessages.Format(0x051D, param: null));
|
||||
// client simply has no display text for this id.
|
||||
//
|
||||
// REJECT-review rework (SHOULD-FIX 4,
|
||||
// docs/research/2026-08-09-ch2-review-findings.md): retail's switch
|
||||
// has no default case — an unhandled id produces NO text, silently,
|
||||
// toward the player. Format now returns null rather than inventing
|
||||
// a "WeenieError 0xNNNN" hex fallback that has no retail
|
||||
// counterpart.
|
||||
Assert.Null(WeenieErrorMessages.Format(0x051D, param: null));
|
||||
}
|
||||
|
||||
// ── known codes — error-level ────────────────────────────────────
|
||||
|
|
@ -167,27 +171,31 @@ public sealed class WeenieErrorMessagesTests
|
|||
WeenieErrorMessages.Format(0x04EE, null));
|
||||
}
|
||||
|
||||
// ── unknown codes — graceful fallback preserves debug info ───────
|
||||
// ── unknown codes — retail-faithful silence (SHOULD-FIX 4) ───────
|
||||
//
|
||||
// docs/research/2026-08-09-ch2-review-findings.md SHOULD-FIX 4: retail's
|
||||
// HandleFailureEvent switch has no default case — an id it does not
|
||||
// recognize produces NO text at all, toward the player. The prior
|
||||
// "WeenieError 0xNNNN[: param]" hex fallback was acdream's own
|
||||
// invention with no retail counterpart. These three tests are flipped
|
||||
// (not deleted) to pin the new null-means-silence contract.
|
||||
|
||||
[Fact]
|
||||
public void Format_UnknownCode_NoParam_FallsBackToHexForm()
|
||||
public void Format_UnknownCode_NoParam_ReturnsNull()
|
||||
{
|
||||
Assert.Equal("WeenieError 0xABCD", WeenieErrorMessages.Format(0xABCD, null));
|
||||
Assert.Null(WeenieErrorMessages.Format(0xABCD, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Format_UnknownCode_WithParam_FallsBackToColonForm()
|
||||
public void Format_UnknownCode_WithParam_ReturnsNull()
|
||||
{
|
||||
Assert.Equal(
|
||||
"WeenieError 0xDEAD: Mana Stone",
|
||||
WeenieErrorMessages.Format(0xDEAD, "Mana Stone"));
|
||||
Assert.Null(WeenieErrorMessages.Format(0xDEAD, "Mana Stone"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Format_UnknownCode_EmptyParam_StaysAsHexOnly()
|
||||
public void Format_UnknownCode_EmptyParam_ReturnsNull()
|
||||
{
|
||||
// Empty string param shouldn't add a stray colon.
|
||||
Assert.Equal("WeenieError 0xCAFE", WeenieErrorMessages.Format(0xCAFE, ""));
|
||||
Assert.Null(WeenieErrorMessages.Format(0xCAFE, ""));
|
||||
}
|
||||
|
||||
// ── parameterised templates with non-trivial params ──────────────
|
||||
|
|
@ -201,17 +209,18 @@ public sealed class WeenieErrorMessagesTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Format_0x004F_FallsBackToHex_NoRetailCaseExists()
|
||||
public void Format_0x004F_ResolvesToRetailText()
|
||||
{
|
||||
// Campaign CH slice CH2: the pre-CH2 "You fail to affect _ because
|
||||
// they cannot be harmed!" text for 0x004F was an ACE-derived guess.
|
||||
// Direct decomp verification (grepping every "case 0x4f:" in
|
||||
// ClientCommunicationSystem::HandleFailureEvent's whole body) found
|
||||
// NONE — only 0x4E, 0x50, 0x51, 0x52, 0x53, 0x54 have cases; 0x4F is
|
||||
// skipped entirely, same as the many other gaps in that switch's
|
||||
// sparse jump table. Retail has no display text for this id.
|
||||
// REJECT-review rework (BLOCKER 2,
|
||||
// docs/research/2026-08-09-ch2-review-findings.md): the prior
|
||||
// "grep for a case label" transcription missed 0x04F because it
|
||||
// dispatches via `else if (arg2 == 0x4f)`, not a switch case label.
|
||||
// The binary sweep found its sprintf format string directly
|
||||
// (VA 0x00571e23, in ClientCommunicationSystem::HandleFailureEvent's
|
||||
// else-if chain). Retail preserves its own $s typo (only the first
|
||||
// %s substitutes), same pattern as 0x4F4.
|
||||
Assert.Equal(
|
||||
"WeenieError 0x004F: Drudge",
|
||||
"You fail to affect Drudge because $s cannot be harmed!",
|
||||
WeenieErrorMessages.Format(0x004F, "Drudge"));
|
||||
}
|
||||
|
||||
|
|
@ -226,34 +235,87 @@ public sealed class WeenieErrorMessagesTests
|
|||
// ── Campaign CH slice CH2: the full HandleFailureEvent table port ────
|
||||
|
||||
/// <summary>
|
||||
/// Pins the table's size: 338 rows (Appendix A's 339 minus the one
|
||||
/// deliberately-excluded 0x4F8, see the class doc comment on
|
||||
/// <see cref="WeenieErrorMessages"/>). A change to this number without
|
||||
/// a matching research/commit citation is a red flag, not a routine
|
||||
/// edit.
|
||||
/// Pins the table's size: 344 rows. REJECT-review rework (BLOCKER 2,
|
||||
/// docs/research/2026-08-09-ch2-review-findings.md) added the 5 ids the
|
||||
/// prior pass's case-label enumeration missed (dispatched via
|
||||
/// <c>else if</c> chains, not switch cases) plus <c>0x4F8</c>, which now
|
||||
/// resolves for real instead of being deliberately excluded: 338 + 5 + 1
|
||||
/// = 344. A change to this number without a matching research/commit
|
||||
/// citation is a red flag, not a routine edit.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Resolve_FullTable_HasExactly338Rows()
|
||||
public void Resolve_FullTable_HasExactly344Rows()
|
||||
{
|
||||
int count = 0;
|
||||
for (uint id = 0; id <= 0x600u; id++)
|
||||
{
|
||||
var (text, _) = WeenieErrorMessages.Resolve(id, null);
|
||||
if (!text.StartsWith("WeenieError 0x", StringComparison.Ordinal))
|
||||
if (text is not null)
|
||||
count++;
|
||||
}
|
||||
Assert.Equal(338, count);
|
||||
Assert.Equal(344, count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Resolve_0x4F8_IsDeliberatelyExcluded_FallsBackToHex()
|
||||
public void Resolve_0x4F8_NowResolvesForReal()
|
||||
{
|
||||
// See the class doc comment: 0x4F8's case body is a tangled
|
||||
// multi-operator+ decompiler artifact that could not be resolved
|
||||
// with confidence — excluded rather than guessed.
|
||||
// REJECT-review rework (BLOCKER 2): the prior pass excluded 0x4F8
|
||||
// because its case body's 3-operator+ concatenation chain has
|
||||
// confusing BN-generated self-referential operand names. The binary
|
||||
// sweep dereferenced both literal data pointers directly
|
||||
// (data_7d2ee8, data_7d2f80), sidestepping the naming confusion.
|
||||
// Both %s placeholders substitute the SAME parameter (retail only
|
||||
// has one arg3 to concatenate twice).
|
||||
var (text, type) = WeenieErrorMessages.Resolve(0x4F8, "Someone");
|
||||
Assert.Equal("WeenieError 0x04F8: Someone", text);
|
||||
Assert.Equal(RetailLogTextType.Default, type);
|
||||
Assert.Equal(
|
||||
"Someone fails to affect you because you are not the same sort of player killer as Someone!",
|
||||
text);
|
||||
Assert.Equal(RetailLogTextType.Magic, type);
|
||||
}
|
||||
|
||||
// ── REJECT-review rework (BLOCKER 2): every corrected/added row ──────
|
||||
//
|
||||
// docs/research/2026-08-09-ch2-review-findings.md — pins the exact text
|
||||
// for every id the binary sweep + ACE cross-check corrected or added
|
||||
// this pass, so a future regression to the wrong (previously-landed)
|
||||
// text fails loudly instead of silently.
|
||||
|
||||
[Theory]
|
||||
// 5 ids added — missed by the prior case-label enumeration because
|
||||
// they dispatch via `else if (arg2 == N)`, not a switch case.
|
||||
[InlineData(0x04Fu, "You fail to affect %s because $s cannot be harmed!", RetailLogTextType.Magic)]
|
||||
[InlineData(0x3EEu, "The container is closed!", RetailLogTextType.ClientLocal)]
|
||||
[InlineData(0x408u, "Your spell cannot be cast inside", RetailLogTextType.ClientLocal)]
|
||||
[InlineData(0x48Au, "You must be a monarch to purchase this dwelling.", RetailLogTextType.Default)]
|
||||
[InlineData(0x4E8u, "The %s cannot be used while on a hook and only the owner may open the hook.", RetailLogTextType.Default)]
|
||||
// 16 ids corrected per the review's own flagged list.
|
||||
[InlineData(0x051u, "You fail to affect %s because you are not a player killer!", RetailLogTextType.Magic)]
|
||||
[InlineData(0x053u, "You fail to affect %s because you are not the same sort of player killer as %s!", RetailLogTextType.Magic)]
|
||||
[InlineData(0x054u, "You fail to affect %s because you are acting across a house boundary!", RetailLogTextType.Magic)]
|
||||
[InlineData(0x466u, "You must purchase Asheron's Call: Dark Majesty to interact with that portal.", RetailLogTextType.Magic)]
|
||||
[InlineData(0x4A3u, "You must have linked with a portal in order to recall to it!", RetailLogTextType.Magic)]
|
||||
[InlineData(0x4B5u, "You must specify a character to query.", RetailLogTextType.ClientLocal)]
|
||||
[InlineData(0x4E0u, "You are currently wielding items which require a certain level of skill. Your attributes cannot be transferred while you are wielding these items. Please remove these items and try again.", RetailLogTextType.Default)]
|
||||
[InlineData(0x4F7u, "%s fails to affect you because you are not a player killer!", RetailLogTextType.Magic)]
|
||||
[InlineData(0x544u, "An unspecified error occurred while attempting to remove %s as an allegiance officer.", RetailLogTextType.Default)]
|
||||
[InlineData(0x54Eu, "The hook does not contain a usable item. You cannot open the hook because you do not own the house to which it belongs.", RetailLogTextType.Default)]
|
||||
[InlineData(0x552u, "You must purchase Asheron's Call -- Throne of Destiny to use this function.", RetailLogTextType.ClientLocal)]
|
||||
[InlineData(0x553u, "You must purchase Asheron's Call -- Throne of Destiny to use this item.", RetailLogTextType.ClientLocal)]
|
||||
[InlineData(0x554u, "You must purchase Asheron's Call -- Throne of Destiny to use this portal.", RetailLogTextType.ClientLocal)]
|
||||
[InlineData(0x555u, "You must purchase Asheron's Call -- Throne of Destiny to access this quest.", RetailLogTextType.ClientLocal)]
|
||||
[InlineData(0x57Fu, "Your allegiance chat privileges have been temporarily removed by %s. Until they are restored, you may not view or speak in the allegiance chat channel.", RetailLogTextType.Default)]
|
||||
[InlineData(0x582u, "Your allegiance chat privileges have been restored by %s.", RetailLogTextType.Default)]
|
||||
// 2 ids corrected that were NOT in the review's flagged list — found by
|
||||
// an automated diff between the swept binary literals and the landed
|
||||
// table (the review's own "sweep may find more" prediction).
|
||||
[InlineData(0x4E9u, "The %s cannot be used while on a hook, use the '@house hooks on' command to make the hook openable.", RetailLogTextType.Default)]
|
||||
[InlineData(0x518u, "This fellowship is locked; %s cannot be recruited into the fellowship.", RetailLogTextType.Default)]
|
||||
public void Resolve_Blocker2CorrectedRows_MatchTheSweptBinaryLiteral(
|
||||
uint id, string expectedTemplate, RetailLogTextType expectedType)
|
||||
{
|
||||
var (text, type) = WeenieErrorMessages.Resolve(id, param: null);
|
||||
Assert.Equal(expectedTemplate, text);
|
||||
Assert.Equal(expectedType, type);
|
||||
}
|
||||
|
||||
// ── spot pins across all three retail routing destinations ──────────
|
||||
|
|
|
|||
|
|
@ -207,27 +207,38 @@ public sealed class RuntimeCommunicationStateTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void AddText_TrimsTrailingWhitespace_LikeRetailAddTextToScroll()
|
||||
public void AddText_TrimsBothEnds_LikeRetailAddTextToScroll()
|
||||
{
|
||||
// CH2 REJECT-review rework (SHOULD-FIX 2,
|
||||
// docs/research/2026-08-09-ch2-review-findings.md): retail's
|
||||
// AddTextToScroll @0x00563C50 calls trim(&str, 1, 1, ws) — BOTH
|
||||
// ends, not trailing-only.
|
||||
using var state = new RuntimeCommunicationState();
|
||||
|
||||
state.AddText("Out of Range! ", RetailLogTextType.ClientLocal);
|
||||
state.AddText(" Out of Range! ", RetailLogTextType.ClientLocal);
|
||||
|
||||
state.SpewBox.Tick(0d);
|
||||
Assert.Equal("Out of Range!", state.SpewBox.Snapshot()[0].Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddText_EmptyAfterTrim_IsDropped()
|
||||
public void AddText_EmptyAfterTrim_StillBroadcasts_LikeRetail()
|
||||
{
|
||||
// CH2 REJECT-review rework (SHOULD-FIX 2): retail's
|
||||
// AddTextToScroll has no empty-string guard — the previous
|
||||
// early-return was an unregistered acdream-only divergence, now
|
||||
// retired. An all-whitespace message still reaches its destination
|
||||
// as an empty string.
|
||||
using var state = new RuntimeCommunicationState();
|
||||
|
||||
state.AddText(" ", RetailLogTextType.ClientLocal);
|
||||
state.AddText(" ", RetailLogTextType.Default);
|
||||
|
||||
state.SpewBox.Tick(0d);
|
||||
Assert.Equal(0, state.SpewBox.Count);
|
||||
Assert.Equal(0, state.Chat.Count);
|
||||
Assert.Equal(1, state.SpewBox.Count);
|
||||
Assert.Equal("", state.SpewBox.Snapshot()[0].Text);
|
||||
Assert.Equal(1, state.Chat.Count);
|
||||
Assert.Equal("", state.Chat.Snapshot()[0].Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public sealed class RuntimeGenerationResetTests
|
|||
runtime.ActionOwner.Combat.SetCombatMode(CombatMode.Missile);
|
||||
runtime.CommunicationOwner.Chat.SetLocalPlayerGuid(player);
|
||||
runtime.CommunicationOwner.Chat.OnSystemMessage("retained", 1u);
|
||||
runtime.CommunicationOwner.SpewBox.Enqueue("about to be torn down");
|
||||
_ = runtime.MovementOwner.Execute(
|
||||
RuntimeMovementCommand.ToggleRunLock);
|
||||
var observer = new RecordingObserver();
|
||||
|
|
@ -81,6 +82,13 @@ public sealed class RuntimeGenerationResetTests
|
|||
Assert.Equal(CombatMode.NonCombat, runtime.Actions.Snapshot.CombatMode);
|
||||
Assert.False(runtime.MovementOwner.AutoRunActive);
|
||||
Assert.Equal(1, runtime.CommunicationOwner.Chat.Count);
|
||||
// SHOULD-FIX 1 (docs/research/2026-08-09-ch2-review-findings.md):
|
||||
// ResetSpewBox was dead code — a fresh generation must not
|
||||
// resurrect a stale refusal line. Assert BOTH that the pending
|
||||
// enqueue never surfaces (no leftover Tick drains it into
|
||||
// visibility) and that Reset itself converges Count to zero.
|
||||
runtime.CommunicationOwner.SpewBox.Tick(0d);
|
||||
Assert.Equal(0, runtime.CommunicationOwner.SpewBox.Count);
|
||||
Assert.Null(
|
||||
runtime.CommunicationOwner.CommandTargets.LastIncomingTellSender);
|
||||
Assert.False(runtime.GenerationReset.CaptureSnapshot().IsActive);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ public sealed class SpewBoxVMTests
|
|||
[Fact]
|
||||
public void Lines_NewestFirst_MatchesRetailInsertAtZero()
|
||||
{
|
||||
// CH2 REJECT-review rework NIT 3: MaxConcurrentItems is the
|
||||
// AUTHORED LayoutDesc value (4, see SpewBoxState.MaxConcurrentItems's
|
||||
// own doc comment), not retail's code default (1) — both entries
|
||||
// now survive, so assert the ordering directly.
|
||||
var state = new SpewBoxState();
|
||||
var vm = new SpewBoxVM(state);
|
||||
state.Enqueue("older");
|
||||
|
|
@ -56,11 +60,9 @@ public sealed class SpewBoxVMTests
|
|||
|
||||
IReadOnlyList<SpewBoxLine> lines = vm.Lines(0d);
|
||||
|
||||
// MaxConcurrentItems == 1 means only the newest survives, which is
|
||||
// itself proof insertion happens at the front (retail's overflow
|
||||
// rule drops the OLDEST / highest index, not the newest).
|
||||
SpewBoxLine line = Assert.Single(lines);
|
||||
Assert.Equal("newer", line.Text);
|
||||
Assert.Equal(2, lines.Count);
|
||||
Assert.Equal("newer", lines[0].Text);
|
||||
Assert.Equal("older", lines[1].Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue