feat(chat): Campaign CH slice CH3 — side-channel membership, wire, and echo parity

Ports retail's SendTurbineChat (@0x0057db10) local pre-send membership gate
so Roleplay/Society/Olthoi stop silently swallowing outbound chat: a new
TurbineChatMembershipGate checks Turbine availability and the player's own
Hear*Chat option before sending, raising "Turbine chat is not available."
or the 0x0551 YouAreNotListeningTo_Channel refusal through the CH2 AddText
chokepoint instead. Wired into both the graphical (LiveSessionCommandRouter)
and headless (DirectGameRuntimeCommandAdapter) send paths so they can't
diverge. Retracts the 26-day-old false "ACE doesn't run a TurbineChat
server" claim from ISSUES.md, the roadmap, and project_chat_pipeline.md —
ACE's TurbineChat implementation is complete and on by default; the real
bug was treating Hear*Chat as a display filter instead of room membership.

Also: implements SetSingleCharacterOption (0x0005), the only wire message
that actually joins/leaves a Turbine room, and wires the five Settings Chat
toggles to it (publish on Save, changed bits only) plus seeds ChatSettings
from the server's own CharacterOptions2 on every PlayerDescription. Fixes
the legacy-channel double-print (Fellow/Vassals/Patron/Monarch/CoVassals
skip the local echo now that ChatChannelInfo.IsSelfEchoChannel is finally
consulted). Routes /a to Turbine unconditionally (retail's @a never falls
back to the legacy bitflag) and adds /ab for the legacy AllegianceBroadcast
verb retail actually has. Surfaces a nonzero TurbineChat ack HResult instead
of discarding it silently. Deletes the malformed, callerless SetCharacterOptions
(0x01A1) and AddChannel/RemoveChannel (0x0145/0x0146) builders.

Files every AC-specific algorithm change cites the named retail decomp
(SendTurbineChat 0x0057db10, StartupTurbineChatSystem 0x0057EFB0,
GameActionSetSingleCharacterOption) plus ACE/holtburger cross-checks.
Register rows AP-181 (no client-side spam throttle) and UN-9 (an
incidentally-discovered CharacterOptions1.Default literal mismatch, not
investigated further) filed per the divergence-register rule.

11,957 passed / 4 skipped / 0 failed (full Release suite, up from the
11,916/4/0 baseline).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-09 19:39:44 +02:00
parent fc9590e4fc
commit 614a1e055f
35 changed files with 1453 additions and 229 deletions

View file

@ -71,17 +71,16 @@ public sealed class LiveSessionCommandRouterTests
Assert.Equal([("Friend", "hello")], tells);
Assert.Equal([(0x00000800u, "group")], channels);
// CH3 (2026-08-09): Fellowship is one of the ACE server-echoing
// legacy channels (resends with an empty sender) — the router must
// NOT also emit a local optimistic echo, or the line double-prints.
// Only the Tell echo (which the server never resends) survives.
Assert.Collection(
chat.Snapshot(),
entry =>
{
Assert.Equal(ChatKind.Tell, entry.Kind);
Assert.Equal("Friend", entry.Sender);
},
entry =>
{
Assert.Equal(ChatKind.Channel, entry.Kind);
Assert.Equal("Fellowship", entry.ChannelName);
});
}
@ -124,6 +123,151 @@ public sealed class LiveSessionCommandRouterTests
Assert.Equal(0, chat.Count);
}
// ── Campaign CH slice CH3 (2026-08-09): Turbine membership gate ──
[Fact]
public void TurbineUnavailable_RaisesRetailStringThroughAddText_AndSendsNothing()
{
var communication = new RuntimeCommunicationState();
var sent = new List<string>();
var router = NewRouter(
chat: communication.Chat,
communication: communication,
turbine: new TurbineChatState(), // never received SetTurbineChatChannels
sendTurbine: (_, _, _, _, text, _) => sent.Add(text));
router.Activate();
router.Publish(new SendChatCmd(ChatChannelKind.General, null, "hello"));
Assert.Empty(sent);
Assert.Equal(1, communication.Chat.Count);
Assert.Equal(
"Turbine chat is not available.",
communication.Chat.Snapshot()[0].Text);
}
[Fact]
public void HearOptionOff_RaisesNotListeningRefusal_AndSendsNothing()
{
// Fresh RuntimeCharacterOptionsState defaults omit HearRoleplayChat
// (matches ACE CharacterOptions2.Default) — a populated Roleplay
// room must still refuse locally rather than send.
var turbine = new TurbineChatState();
turbine.OnChannelsReceived(
0u, 0u, 0u, 0u, roleplayRoom: 0x14u, 0u, 0u, 0u, 0u, 0u);
var communication = new RuntimeCommunicationState();
var sent = new List<string>();
var router = NewRouter(
chat: communication.Chat,
communication: communication,
turbine: turbine,
sendTurbine: (_, _, _, _, text, _) => sent.Add(text));
router.Activate();
router.Publish(new SendChatCmd(ChatChannelKind.Roleplay, null, "hi"));
Assert.Empty(sent);
Assert.Equal(1, communication.Chat.Count);
Assert.Equal(
"You are not listening to the Roleplay channel!",
communication.Chat.Snapshot()[0].Text);
}
[Fact]
public void AllegianceWithNoRoom_RefusesLocally_NeverDowngradesToLegacyChannel()
{
// The CH3 headline /a bug (research doc §5.3): retail's @a is bound
// unconditionally to Turbine — no allegiance must refuse locally,
// NOT silently fall through to the legacy AllegianceBroadcast
// bitflag.
var communication = new RuntimeCommunicationState();
var legacySent = new List<(uint Id, string Text)>();
var turbineSent = new List<string>();
var router = NewRouter(
chat: communication.Chat,
communication: communication,
turbine: new TurbineChatState(), // AllegianceRoom stays 0
sendChannel: (id, text) => legacySent.Add((id, text)),
sendTurbine: (_, _, _, _, text, _) => turbineSent.Add(text));
router.Activate();
router.Publish(new SendChatCmd(ChatChannelKind.Allegiance, null, "guild hi"));
Assert.Empty(legacySent);
Assert.Empty(turbineSent);
Assert.Equal(
"Turbine chat is not available.",
communication.Chat.Snapshot()[0].Text);
}
[Fact]
public void AllegianceBroadcast_AbVerbChannel_RoutesLegacyWithSelfEcho()
{
// /ab (retail DoAllegianceBroadcast) rides the legacy 0x0147 pipe —
// distinct from /a, which is always Turbine now.
var chat = new ChatLog();
var legacySent = new List<(uint Id, string Text)>();
var router = NewRouter(
chat: chat,
sendChannel: (id, text) => legacySent.Add((id, text)));
router.Activate();
router.Publish(new SendChatCmd(
ChatChannelKind.AllegianceBroadcast, null, "to the whole allegiance"));
Assert.Equal([(0x02000000u, "to the whole allegiance")], legacySent);
Assert.Collection(
chat.Snapshot(),
entry =>
{
Assert.Equal(ChatKind.Channel, entry.Kind);
Assert.Equal("Allegiance", entry.ChannelName);
});
}
// ── Campaign CH slice CH3: per-channel self-echo matrix ──
[Theory]
[InlineData(ChatChannelKind.Fellowship, 0x00000800u)]
[InlineData(ChatChannelKind.Vassals, 0x00001000u)]
[InlineData(ChatChannelKind.Patron, 0x00002000u)]
[InlineData(ChatChannelKind.Monarch, 0x00004000u)]
[InlineData(ChatChannelKind.CoVassals, 0x01000000u)]
public void ServerEchoingLegacyChannels_SkipLocalOptimisticEcho(
ChatChannelKind kind,
uint expectedId)
{
var chat = new ChatLog();
var legacySent = new List<(uint Id, string Text)>();
var router = NewRouter(
chat: chat,
sendChannel: (id, text) => legacySent.Add((id, text)));
router.Activate();
router.Publish(new SendChatCmd(kind, null, "hi"));
Assert.Equal([(expectedId, "hi")], legacySent);
Assert.Equal(0, chat.Count); // no local echo — the server's own
// "" -sender resend is the only echo.
}
[Fact]
public void AllegianceBroadcast_KeepsLocalOptimisticEcho()
{
var chat = new ChatLog();
var router = NewRouter(
chat: chat,
sendChannel: (_, _) => { });
router.Activate();
router.Publish(new SendChatCmd(
ChatChannelKind.AllegianceBroadcast, null, "hi"));
Assert.Equal(1, chat.Count); // real-name broadcast includes the
// sender — no separate "" echo, so the
// client keeps its own.
}
[Fact]
public void ActivateAfterDispose_IsRejected()
{
@ -226,17 +370,17 @@ public sealed class LiveSessionCommandRouterTests
public void RuntimeStateCommandsUseActiveGenerationRouteAndBecomeInert()
{
var shortcuts = new List<ShortcutEntry>();
var options = new List<uint>();
var options = new List<(uint OptionId, bool Value)>();
LiveSessionCommandRouter router = NewRouter(
addShortcut: shortcuts.Add,
setCharacterOptions: options.Add);
sendSingleCharacterOption: (id, value) => options.Add((id, value)));
router.Publish(new AddShortcutRuntimeCmd(
new ShortcutEntry(1, 0x80000001u, 0u)));
router.Activate();
router.Publish(new AddShortcutRuntimeCmd(
new ShortcutEntry(2, 0x80000002u, 0u)));
router.Publish(new SetCharacterOptionsRuntimeCmd(0x50C4A54Au));
router.Publish(new SetSingleCharacterOptionRuntimeCmd(0x26u, true));
router.Dispose();
router.Publish(new AddShortcutRuntimeCmd(
new ShortcutEntry(3, 0x80000003u, 0u)));
@ -248,7 +392,7 @@ public sealed class LiveSessionCommandRouterTests
Assert.Equal(2, entry.Index);
Assert.Equal(0x80000002u, entry.ObjectId);
});
Assert.Equal([0x50C4A54Au], options);
Assert.Equal([(0x26u, true)], options);
}
[Fact]
@ -308,9 +452,11 @@ public sealed class LiveSessionCommandRouterTests
Action<uint, string>? sendChannel = null,
Action<uint, uint, uint, uint, string, uint>? sendTurbine = null,
Action<ShortcutEntry>? addShortcut = null,
Action<uint>? setCharacterOptions = null,
Action<string>? log = null,
ClientCommandController.Bindings? clientBindings = null) => new(
ClientCommandController.Bindings? clientBindings = null,
RuntimeCommunicationState? communication = null,
RuntimeCharacterState? characterState = null,
Action<uint, bool>? sendSingleCharacterOption = null) => new(
new LiveSessionCommandBindings(
clientBindings ?? NewClientBindings(),
chat ?? new ChatLog(),
@ -332,7 +478,6 @@ public sealed class LiveSessionCommandRouterTests
RaiseVital: (_, _) => { },
RaiseSkill: (_, _) => { },
TrainSkill: (_, _) => { },
SetCharacterOptions: setCharacterOptions ?? (_ => { }),
AddFriend: _ => { },
RemoveFriend: _ => { },
ClearFriends: () => { },
@ -340,6 +485,9 @@ public sealed class LiveSessionCommandRouterTests
ModifyCharacterSquelch: (_, _, _, _) => { },
ModifyAccountSquelch: (_, _) => { },
ModifyGlobalSquelch: (_, _) => { },
Communication: communication ?? new RuntimeCommunicationState(),
CharacterState: characterState ?? new RuntimeCharacterState(),
SendSingleCharacterOption: sendSingleCharacterOption ?? ((_, _) => { }),
Log: log));
[MethodImpl(MethodImplOptions.NoInlining)]