Applies the Opus review findings on CH1 (172c6f9a), the exact retail chat
color table. Two blockers plus should-fixes/nits, one commit:
BLOCKER 1 — LegacyChannelChatType.Resolve's channel-bit table was wrong.
Binary Ninja renders retail's `neg esi; sbb esi, esi` idiom (a branchless
select between Channel 0x08 and Channel_Send 0x09) as the trivial pseudo-C
`esi - esi` (always 0), hiding the real values. Corrected by decoding the
raw bytes at the PDB-paired binary: HEAR sbb site VA 0x00570F0A (mask -6 ->
0x08), SEND sbb site VA 0x00570D4F (mask -5 -> 0x09). The generic
admin/audit/sentinel catch-all is Channel/Channel_Send, NOT Abuse (0x0E) —
Abuse is retail's ONLY 0x0E producer (bit 0x0001). The unnamed
FellowBroadcast bit (0x4000000) is hear=Channel(0x08)/send=Fellowship(0x13),
not a flat 0x13. ACE's PDB-sourced Channel enum corroborates. Introduces
`RetailLogTextType`, the 34-value named enum for the wire LogTextType space
(values only, no color — Core stays presentation-free).
BLOCKER 2 — three ChatLog.OnSystemMessage sinks (ChatVM.ShowSystemMessage,
LiveSessionRuntimeFactory's ShowSystemMessage delegate,
HeadlessGameplayOperations.DisplayMessage) were typing ALL
ClientCommandController output 0x1A (bright red), including informational
command output (@version, /loc, friends list, usage lines). Retail types
the great majority of that output 0x00 Default (green) and reserves 0x1A
for genuine refusals/errors. Reverted to 0x00 with a comment noting the
refusal-vs-info split lands with CH2's SpewBox producer rewiring. The five
App composition sites that pass 0x1A for actual refusal text
(InteractionRetainedUiComposition, SessionPlayerComposition) were already
correct and are untouched (aside from converting the literal to the new
enum).
Also: AP-176 divergence-register row for OnWeenieError/OnCombatLine's
single-type approximation of retail's per-code/per-message dispatch; a
carry-forward test for the out-of-range LogTextType color fallback in
ChatWindowController; decomp-confirmed anchors replacing ACE-inferred
citations in CombatChatTranslator and ChatLog.OnPlayerKilled; required
(non-optional) logTextType parameters on OnLocalSpeech/OnTellReceived/
OnCombatLine/OnSelfSent since no production caller relied on a default;
LegacyChannelChatType.Resolve's parameter renamed channelBit -> channelId
with a doc note on multi-bit ids; corrections to the color-table research
doc's §3.3 wire tables; and issue #359 for the pre-existing (not
CH1-introduced) 0x019E PlayerKilled participant-suppression gap retail has
and acdream lacks.
dotnet build clean; full Release suite 11,835 passed / 4 skipped / 0 failed
(11,839 total), up from the CH1 baseline of 11,833/4/0.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
141 lines
4.3 KiB
C#
141 lines
4.3 KiB
C#
using System.Numerics;
|
|
using AcDream.Core.Chat;
|
|
using AcDream.UI.Abstractions.Panels.Chat;
|
|
|
|
namespace AcDream.UI.Abstractions.Tests.Panels.Chat;
|
|
|
|
/// <summary>
|
|
/// Phase J Tier 2: <see cref="ChatVM"/> tracks the last OUTGOING tell
|
|
/// target (for <c>/retell</c>) and exposes optional FpsProvider /
|
|
/// PositionProvider callbacks the panel uses to render
|
|
/// <c>/framerate</c> and <c>/loc</c> client-side commands without
|
|
/// reaching into render-loop state.
|
|
/// </summary>
|
|
public sealed class ChatVMRetellAndProvidersTests
|
|
{
|
|
[Fact]
|
|
public void BorrowedCommandTargetsRemainLiveAfterOneViewModelDisposes()
|
|
{
|
|
var log = new ChatLog();
|
|
using var targets = new ChatCommandTargetState(log);
|
|
var first = new ChatVM(log, commandTargets: targets);
|
|
using var second = new ChatVM(log, commandTargets: targets);
|
|
|
|
first.Dispose();
|
|
log.OnTellReceived("Bestie", "incoming", 0x50000001u, logTextType: 0x03u);
|
|
|
|
Assert.Equal("Bestie", second.LastIncomingTellSender);
|
|
}
|
|
|
|
[Fact]
|
|
public void ResetSessionTargets_ClearsReplyAndRetellWithoutClearingTranscript()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log);
|
|
log.OnTellReceived("Bestie", "incoming", 0x50000001u, logTextType: 0x03u);
|
|
log.OnSelfSent(ChatKind.Tell, "outgoing", logTextType: 0x04u, targetOrChannel: "Caith");
|
|
Assert.NotNull(vm.LastIncomingTellSender);
|
|
Assert.NotNull(vm.LastOutgoingTellTarget);
|
|
|
|
vm.ResetSessionTargets();
|
|
|
|
Assert.Null(vm.LastIncomingTellSender);
|
|
Assert.Null(vm.LastOutgoingTellTarget);
|
|
Assert.Equal(2, log.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void LastOutgoingTellTarget_StartsNull()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log);
|
|
Assert.Null(vm.LastOutgoingTellTarget);
|
|
}
|
|
|
|
[Fact]
|
|
public void OnSelfSentTell_PopulatesLastOutgoingTellTarget()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log);
|
|
|
|
log.OnSelfSent(ChatKind.Tell, "hi there", logTextType: 0x04u, targetOrChannel: "Caith");
|
|
|
|
Assert.Equal("Caith", vm.LastOutgoingTellTarget);
|
|
// Inbound-tell tracker must NOT pick up an outgoing echo —
|
|
// the SenderGuid==0 discriminator separates the two paths.
|
|
Assert.Null(vm.LastIncomingTellSender);
|
|
}
|
|
|
|
[Fact]
|
|
public void IncomingTell_DoesNotTouchOutgoingTarget()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log);
|
|
|
|
log.OnTellReceived("Bestie", "psst", senderGuid: 0x5000_0042, logTextType: 0x03u);
|
|
|
|
Assert.Equal("Bestie", vm.LastIncomingTellSender);
|
|
Assert.Null(vm.LastOutgoingTellTarget);
|
|
}
|
|
|
|
[Fact]
|
|
public void OutgoingThenIncoming_TracksBothIndependently()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log);
|
|
|
|
log.OnSelfSent(ChatKind.Tell, "hi", logTextType: 0x04u, targetOrChannel: "Caith");
|
|
log.OnTellReceived("Bestie", "psst", senderGuid: 0x5000_0042, logTextType: 0x03u);
|
|
|
|
Assert.Equal("Caith", vm.LastOutgoingTellTarget);
|
|
Assert.Equal("Bestie", vm.LastIncomingTellSender);
|
|
}
|
|
|
|
[Fact]
|
|
public void ShowFps_WithProvider_AppendsFormattedLine()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log) { FpsProvider = () => 144.2f };
|
|
|
|
vm.ShowFps();
|
|
|
|
var entry = Assert.Single(log.Snapshot());
|
|
Assert.Equal(ChatKind.System, entry.Kind);
|
|
Assert.Equal("Framerate: 144.2 FPS", entry.Text);
|
|
}
|
|
|
|
[Fact]
|
|
public void ShowFps_NoProvider_StillProducesDiagnosticLine()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log);
|
|
|
|
vm.ShowFps();
|
|
|
|
var entry = Assert.Single(log.Snapshot());
|
|
Assert.Contains("provider unavailable", entry.Text);
|
|
}
|
|
|
|
[Fact]
|
|
public void ShowLocation_WithProvider_AppendsFormattedLine()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log) { PositionProvider = () => new Vector3(123.4f, 567.8f, 60f) };
|
|
|
|
vm.ShowLocation();
|
|
|
|
var entry = Assert.Single(log.Snapshot());
|
|
Assert.Equal("Location: (123.4, 567.8, 60.0)", entry.Text);
|
|
}
|
|
|
|
[Fact]
|
|
public void ShowLocation_NoProvider_StillProducesDiagnosticLine()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log);
|
|
|
|
vm.ShowLocation();
|
|
|
|
Assert.Contains("provider unavailable", log.Snapshot()[0].Text);
|
|
}
|
|
}
|