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

@ -2,6 +2,7 @@ using AcDream.Core.Player;
using AcDream.Core.Net.Messages;
using AcDream.Core.Spells;
using AcDream.Core.Items;
using AcDream.Core.Properties;
namespace AcDream.Runtime.Gameplay;
@ -107,6 +108,27 @@ public sealed class RuntimeCharacterState : IDisposable
public IRuntimeCharacterView View { get; }
public bool IsDisposed => _disposed;
/// <summary>
/// Campaign CH slice CH3 (2026-08-09): retail
/// <c>PlayerModule::IsOlthoi</c> / ACE <c>Player.IsOlthoiPlayer</c>
/// (<c>Player.cs:169</c>, <c>HeritageGroup == Olthoi ||
/// HeritageGroup == OlthoiAcid</c>) — the gate
/// <c>TurbineChatMembershipGate</c> consults for the Olthoi room instead
/// of a <c>Hear*Chat</c> option (there is no such toggle; only heritage
/// gates that room). Reads the already-parsed
/// <c>PropertyInt.HeritageGroup (188)</c> off the local player's own
/// property bundle — 0 (unparsed/unknown) reads as "not Olthoi", matching
/// every other heritage-gated check in this codebase.
/// </summary>
public bool IsOlthoiPlayer
{
get
{
int heritage = LocalPlayer.Properties.GetInt((uint)PropertyInt.HeritageGroup, 0);
return heritage == 12 || heritage == 13; // HeritageGroup.Olthoi / OlthoiAcid
}
}
/// <summary>Retail <c>CommandInterpreter::GetAutonomyLevel</c>.</summary>
public uint AutonomyLevel => Volatile.Read(ref _autonomyLevel);

View file

@ -0,0 +1,143 @@
using AcDream.Core.Chat;
using AcDream.Core.Net.Messages;
namespace AcDream.Runtime.Gameplay;
/// <summary>
/// Outcome of <see cref="TurbineChatMembershipGate.Evaluate"/>.
/// </summary>
public enum TurbineChatGateStatus
{
/// <summary>The send may proceed to the wire.</summary>
Allowed,
/// <summary>
/// Turbine chat is disabled, or this room's id is still 0 (not
/// populated by <c>SetTurbineChatChannels</c> — e.g. no allegiance, no
/// society). Retail: <c>"Turbine chat is not available."</c>
/// (<see cref="ClientTextRefusals.TurbineChatUnavailable"/>), raised
/// locally with NOTHING sent.
/// </summary>
Unavailable,
/// <summary>
/// The room exists and Turbine chat is enabled, but the player's own
/// <c>Hear*Chat</c> option (or, for Olthoi, heritage) is off. Retail:
/// <c>WeenieErrorWithString 0x0551 YouAreNotListeningTo_Channel</c>,
/// raised locally with NOTHING sent.
/// </summary>
NotListening,
}
/// <summary>One evaluated gate decision, carrying the room/chatType/display
/// name a caller needs whether the send proceeds or gets refused.</summary>
public readonly record struct TurbineChatGateResult(
TurbineChatGateStatus Status,
uint RoomId,
uint ChatType,
string DisplayName);
/// <summary>
/// Retail's local pre-send membership gate for a Turbine-room chat channel,
/// ported from <c>ClientCommunicationSystem::SendTurbineChat @0x0057db10</c>
/// (Sept 2013 EoR build; research doc
/// <c>docs/research/2026-08-09-chat-side-channels-vs-ace.md</c> §4.2/§6.2).
///
/// <para>
/// Both the graphical (<c>LiveSessionCommandRouter</c>) and headless
/// (<c>DirectGameRuntimeCommandAdapter</c>) outbound chat paths call this
/// SAME chokepoint so the two hosts can never diverge on which channels are
/// joined and which local refusal a blocked send produces. Retail refuses
/// LOCALLY (nothing reaches the wire) in exactly two cases — Turbine chat
/// off / room id 0, or the player's own <c>Hear*Chat</c> option off — before
/// ever building a <c>TurbineChatBlob</c>.
/// </para>
/// </summary>
public static class TurbineChatMembershipGate
{
public static TurbineChatGateResult Evaluate(
ChatChannelKindLite kind,
TurbineChatState turbineChat,
RuntimeCharacterOptionsState options,
bool isOlthoiPlayer)
{
ArgumentNullException.ThrowIfNull(turbineChat);
ArgumentNullException.ThrowIfNull(options);
(uint room, uint chatType, string name) = kind switch
{
ChatChannelKindLite.Allegiance => (
turbineChat.AllegianceRoom,
(uint)TurbineChat.ChatType.Allegiance,
"Allegiance"),
ChatChannelKindLite.General => (
turbineChat.GeneralRoom,
(uint)TurbineChat.ChatType.General,
"General"),
ChatChannelKindLite.Trade => (
turbineChat.TradeRoom,
(uint)TurbineChat.ChatType.Trade,
"Trade"),
ChatChannelKindLite.Lfg => (
turbineChat.LfgRoom,
(uint)TurbineChat.ChatType.Lfg,
"LFG"),
ChatChannelKindLite.Roleplay => (
turbineChat.RoleplayRoom,
(uint)TurbineChat.ChatType.Roleplay,
"Roleplay"),
ChatChannelKindLite.Society => (
turbineChat.SocietyRoom,
(uint)TurbineChat.ChatType.Society,
"Society"),
ChatChannelKindLite.Olthoi => (
turbineChat.OlthoiRoom,
(uint)TurbineChat.ChatType.Olthoi,
"Olthoi"),
_ => (0u, 0u, string.Empty),
};
if (!turbineChat.Enabled || room == 0u)
{
return new TurbineChatGateResult(
TurbineChatGateStatus.Unavailable, room, chatType, name);
}
bool hearOption = kind switch
{
ChatChannelKindLite.Allegiance =>
(options.Options1
& (uint)PlayerDescriptionParser.CharacterOptions1.HearAllegianceChat)
!= 0u,
ChatChannelKindLite.General =>
(options.Options2
& (uint)PlayerDescriptionParser.CharacterOptions2.HearGeneralChat)
!= 0u,
ChatChannelKindLite.Trade =>
(options.Options2
& (uint)PlayerDescriptionParser.CharacterOptions2.HearTradeChat)
!= 0u,
ChatChannelKindLite.Lfg =>
(options.Options2
& (uint)PlayerDescriptionParser.CharacterOptions2.HearLFGChat)
!= 0u,
ChatChannelKindLite.Roleplay =>
(options.Options2
& (uint)PlayerDescriptionParser.CharacterOptions2.HearRoleplayChat)
!= 0u,
ChatChannelKindLite.Society =>
(options.Options2
& (uint)PlayerDescriptionParser.CharacterOptions2.HearSocietyChat)
!= 0u,
// Retail's Olthoi entry point passes CPlayerSystem::IsOlthoi()
// as its hearOption argument instead of a PlayerModule flag —
// there is no "Hear Olthoi chat" toggle, only heritage.
ChatChannelKindLite.Olthoi => isOlthoiPlayer,
_ => true,
};
return hearOption
? new TurbineChatGateResult(TurbineChatGateStatus.Allowed, room, chatType, name)
: new TurbineChatGateResult(TurbineChatGateStatus.NotListening, room, chatType, name);
}
}