feat(chat): Campaign CH slice CH1 — retail LogTextType color table

Retail colors chat lines by the 34-value wire LogTextType (ACE's
ChatMessageType), NOT by acdream's synthetic 9-value ChatKind. The old
ChatWindowController.RetailChatColor(ChatKind) collapsed distinct retail
colors onto one bucket per ChatKind — e.g. every Channel line rendered
colorLightBlue (Magic's slot) when retail's actual palette spans five
different colors across the Turbine rooms and legacy allegiance family.

Ports ChatInterface::BuildChatColorLookupTable @0x004F31C0 verbatim
(RetailChatColorTable, all 34 RGBA floats read from the PDB-paired
binary's .data section) and threads a new ChatEntry.LogTextType field
through every ingestion site to the correct retail wire value:
HearSpeech/Tell pass the wire chatType through verbatim; Emote/SoulEmote
hard-code 0x0C; the Tell self-echo hard-codes 0x04; legacy ChatChannel
broadcasts derive their type from the channel bit via the new
LegacyChannelChatType helper (ported from the decompiled
Handle_Communication__ChannelBroadcast dispatch, hear vs. own-send);
TurbineChat rooms map through TurbineChatDisplayNames.LogTextType;
CombatChatTranslator's hit/miss/evade lines map to ACE's CombatSelf/
CombatEnemy per Player_Combat.cs; kill/death lines use retail's
decompiled 0x00 Default (not a combat color). ChatWindowController's
transcript now folds LogTextType through RetailChatColorTable with
retail's exact "out-of-range keeps the previous line's color" carry
rule; ChatPanel's combat highlighting sources the same table.

Corrects HearSpeech.cs's doc-comment ChatType legend (4 of 6 entries
were wrong). Adds register row AP-175 for the pre-existing (unchanged)
Popup-renders-in-chat divergence and updates AP-39's stale per-ChatKind
description. Narrows ISSUES #139 — its chat-colors half is done.

Retail renders no chat timestamp prefix path exists in acdream today,
so the "timestamp is always colorGrey 0x0C" rule has nothing to attach
to; noted here per the research doc rather than left silent.

Research: docs/research/2026-08-09-chat-retail-color-table.md
Full Release suite: 11,833 passed / 4 skipped / 0 failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-09 15:23:31 +02:00
parent 8df35d1e18
commit 172c6f9aa3
26 changed files with 1360 additions and 85 deletions

View file

@ -240,7 +240,11 @@ internal sealed class LiveSessionCommandRouter : ILiveSessionCommandRouting
bindings.Chat.OnSelfSent(
ChatKind.Tell,
command.Text,
targetOrChannel: command.TargetName);
targetOrChannel: command.TargetName,
// Retail's own "You tell ..." echo is Speech_Direct_Send
// (0x04), distinct from an incoming Tell's 0x03 — see
// ChatMessageType.OutgoingTell's "You tell ..." comment.
logTextType: 0x04u);
return;
}
@ -283,7 +287,11 @@ internal sealed class LiveSessionCommandRouter : ILiveSessionCommandRouting
bindings.Chat.OnSelfSent(
ChatKind.Channel,
command.Text,
targetOrChannel: legacy.Value.DisplayName);
targetOrChannel: legacy.Value.DisplayName,
// Precise per-bit own-send type (LegacyChannelChatType.Resolve's
// ownSend:true branch) — e.g. Fellowship keeps 0x13, Patron/
// Vassal/Follower become 0x0B, the admin catch-all stays 0x0E.
logTextType: LegacyChannelChatType.Resolve(legacy.Value.ChannelId, ownSend: true));
}
private ClientCommandController.Bindings BuildGuardedClientCommands(

View file

@ -327,8 +327,10 @@ internal sealed class LiveSessionRuntimeFactory
ToggleUiLock: () =>
_interaction.Settings.SetUiLocked(
!_interaction.Settings.Gameplay.LockUI),
// Client-local text (never reaches the wire), 0x1A — same
// category as ChatVM.ShowSystemMessage.
ShowSystemMessage:
text => _domain.Communication.Chat.OnSystemMessage(text, 0u),
text => _domain.Communication.Chat.OnSystemMessage(text, 0x1Au),
ShowWeenieError:
code => _domain.Communication.Chat.OnWeenieError(code, null),
PlayerPublicWeenieBitfield: () =>

View file

@ -423,8 +423,9 @@ public sealed class ChatWindowController : IRetainedWindowStateController, IReta
/// <summary>
/// Convert the ChatVM's detailed lines to the transcript's
/// <see cref="UiText.Line"/> record format, applying retail-faithful
/// per-<see cref="ChatKind"/> colors.
/// <see cref="UiText.Line"/> record format, applying retail's exact
/// <see cref="RetailChatColorTable"/> colors keyed by each entry's
/// <see cref="ChatEntry.LogTextType"/> (NOT <see cref="ChatKind"/>).
/// </summary>
private IReadOnlyList<UiText.Line> GetTranscriptLines(ChatVM vm)
{
@ -456,12 +457,19 @@ public sealed class ChatWindowController : IRetainedWindowStateController, IReta
: debugFont is { } bf ? s => bf.MeasureWidth(s)
: static s => s.Length * 7f;
// Retail's font-color state (m_curFontColor) persists across every
// appended line — an out-of-range LogTextType leaves it unchanged
// rather than reverting to a default (research doc §3.2). Seed the
// carry with retail's own unfilled-slot default (colorGreen, index
// 0x00) and fold forward across the transcript in order.
RetailChatColorTable.TryGetColor(0x00u, out Vector4 currentColor);
var result = new List<UiText.Line>(detailed.Count);
foreach (var d in detailed)
{
var color = RetailChatColor(d.Kind);
if (RetailChatColorTable.TryGetColor(d.LogTextType, out Vector4 resolved))
currentColor = resolved;
foreach (var frag in WrapText(d.Text, maxW, measure))
result.Add(new UiText.Line(frag, color));
result.Add(new UiText.Line(frag, currentColor));
}
return StoreTranscriptLayout(result, revision, maxW, datFont, debugFont);
}
@ -531,28 +539,6 @@ public sealed class ChatWindowController : IRetainedWindowStateController, IReta
if (line.Length > 0) yield return line.ToString();
}
/// <summary>
/// Per-<see cref="ChatKind"/> text color — the EXACT retail RGBA values read from a
/// live retail client via cdb (the named <c>RGBAColor</c> constants at acclient
/// 0x81c4a8+, e.g. <c>colorWhite</c>/<c>colorBrightPurple</c>/<c>colorLightBlue</c>/
/// <c>colorGreen</c>, used by <c>ChatInterface::BuildChatColorLookupTable @0x4f31c0</c>).
/// The four common kinds (speech/tell/channel/system) are confirmed by the named
/// symbols + universal AC convention; the rarer kinds map to the nearest named color.
/// </summary>
private static Vector4 RetailChatColor(ChatKind kind) => kind switch
{
ChatKind.LocalSpeech => new(1f, 1f, 1f, 1f), // colorWhite
ChatKind.RangedSpeech => new(1f, 1f, 1f, 1f), // colorWhite (shout)
ChatKind.Channel => new(0.247f, 0.749f, 1f, 1f), // colorLightBlue
ChatKind.Tell => new(1f, 0.498f, 1f, 1f), // colorBrightPurple
ChatKind.System => new(0.5f, 1f, 0.498f, 1f), // colorGreen
ChatKind.Popup => new(0.5f, 1f, 0.498f, 1f), // colorGreen (server broadcast)
ChatKind.Emote => new(0.824f, 0.824f, 0.784f, 1f), // colorGrey
ChatKind.SoulEmote => new(0.824f, 0.824f, 0.784f, 1f), // colorGrey
ChatKind.Combat => new(0.96f, 0.459f, 0.447f, 1f), // colorLightRed
_ => new(0.824f, 0.824f, 0.784f, 1f), // colorGrey (fallback)
};
public void Dispose()
{
if (_disposed) return;

View file

@ -102,21 +102,28 @@ public static class GameEventWiring
registrar.Register(GameEventType.ChannelBroadcast, e =>
{
var p = GameEvents.ParseChannelBroadcast(e.Payload.Span);
// logTextType left unset — ChatLog.OnChannelBroadcast derives it
// from ChannelId via LegacyChannelChatType.Resolve(ownSend: false),
// the correct branch for this inbound (hear) 0x0147 handler.
if (p is not null) chat.OnChannelBroadcast(p.Value.ChannelId, p.Value.SenderName, p.Value.Message);
});
registrar.Register(GameEventType.Tell, e =>
{
var p = GameEvents.ParseTell(e.Payload.Span);
if (p is not null) chat.OnTellReceived(p.Value.SenderName, p.Value.Message, p.Value.SenderGuid);
// p.Value.ChatType is the wire LogTextType (normally 0x03 Tell) —
// passed through verbatim, matching HearSpeech's zero-remap rule.
if (p is not null)
chat.OnTellReceived(p.Value.SenderName, p.Value.Message, p.Value.SenderGuid, p.Value.ChatType);
});
registrar.Register(GameEventType.CommunicationTransientString, e =>
{
// 0x02EB carries no chat type on the wire (see ParseTransient).
// 0 is ACE's ChatMessageType.Broadcast, which its own
// LogTextTypeEnumMapper comment names "Default" — the right
// stand-in for a message the server sends untyped. The exact
// retail rendering style for transient strings belongs to the
// chat colour/text work, not to this parser.
// stand-in for a message the server sends untyped. Left at 0x00
// by Campaign CH slice CH1 (retail color table): this is
// server-driven text, not client-local, so it keeps the
// Default/green color rather than moving to 0x1A.
var s = GameEvents.ParseTransient(e.Payload.Span);
if (s is not null) chat.OnSystemMessage(s, chatType: 0u);
});
@ -132,6 +139,10 @@ public static class GameEventWiring
string text = string.IsNullOrEmpty(p.Value.Name)
? $"You have played for {p.Value.Age}."
: $"{p.Value.Name} has played for {p.Value.Age}.";
// Decomp-confirmed 0x00 Default:
// CM_Character::DispatchUI_QueryAgeResponse @0x006A2E40 ->
// Handle_Character__QueryAgeResponse @0x005711D0 ->
// AddTextToScroll(..., 0, 1, 0), pc:382186.
chat.OnSystemMessage(text, chatType: 0u);
});
if (onConfirmationRequest is not null)
@ -247,7 +258,12 @@ public static class GameEventWiring
registrar.Register(GameEventType.VictimNotification, e =>
{
var p = GameEvents.ParseVictimNotification(e.Payload.Span);
if (p is not null) chat.OnCombatLine(p.Value.DeathMessage, CombatLineKind.Error);
// VictimNotification (0x01AC) and KillerNotification (0x01AD)
// both dispatch through the SAME retail handler,
// ClientCombatSystem::HandleKillerNotificationEvent @0x0056C410
// (pc:359548-359559), which calls AddTextToScroll(..., 0, 1, 0)
// — LogTextType 0x00 Default, not a combat color.
if (p is not null) chat.OnCombatLine(p.Value.DeathMessage, CombatLineKind.Error, logTextType: 0x00u);
});
registrar.Register(GameEventType.DefenderNotification, e =>
{
@ -285,7 +301,8 @@ public static class GameEventWiring
registrar.Register(GameEventType.KillerNotification, e =>
{
var p = GameEvents.ParseKillerNotification(e.Payload.Span);
if (p is not null) chat.OnCombatLine(p.Value.DeathMessage, CombatLineKind.Info);
// Same handler/type as VictimNotification above — 0x00 Default.
if (p is not null) chat.OnCombatLine(p.Value.DeathMessage, CombatLineKind.Info, logTextType: 0x00u);
});
// ── Spells ────────────────────────────────────────────────
@ -526,6 +543,10 @@ public static class GameEventWiring
if (err is null) return;
Console.WriteLine($"[use-done] err=0x{err.Value:X4}");
onUseDone?.Invoke(err.Value);
// chatType 0x00 (Default): this text is client-formatted from a
// WeenieError CODE, the same shape as HandleFailureEvent's
// per-code switch (@0x00571990), whose majority case is 0x00 —
// see the identical reasoning on ChatLog.OnWeenieError.
if (err.Value != 0)
chat.OnSystemMessage(WeenieErrorText.For(err.Value), chatType: 0);
});

View file

@ -36,16 +36,24 @@ namespace AcDream.Core.Net.Messages;
/// </para>
///
/// <para>
/// ChatType (from ACE):
/// ChatType (LogTextType — corrected 2026-08-09, Campaign CH slice CH1;
/// the previous legend here had 4 of 6 entries wrong, cf. research doc
/// <c>docs/research/2026-08-09-chat-retail-color-table.md</c> §5.4.1):
/// <list type="bullet">
/// <item><description>0x01 = Broadcast</description></item>
/// <item><description>0x02 = Combat</description></item>
/// <item><description>0x0B = Speech</description></item>
/// <item><description>0x0F = Emote</description></item>
/// <item><description>0x10 = Tell</description></item>
/// <item><description>0x11 = Syllables (spell casting)</description></item>
/// <item><description>0x01 = All (Broadcast/AllChannels)</description></item>
/// <item><description>0x02 = Speech</description></item>
/// <item><description>0x03 = Tell</description></item>
/// <item><description>0x0B = Social_Send</description></item>
/// <item><description>0x0C = Emote</description></item>
/// <item><description>0x0F = Help</description></item>
/// <item><description>0x10 = Appraisal</description></item>
/// <item><description>0x11 = Spellcasting (syllables)</description></item>
/// <item><description>other values in ACE ChatMessageType.cs</description></item>
/// </list>
/// This value is passed through VERBATIM as the chat line's
/// <c>LogTextType</c> — zero remapping (retail's
/// <c>Handle_Communication__HearSpeech @0x005712A0</c> feeds the raw
/// wire word straight into <c>AddTextToScroll</c>).
/// </para>
/// </summary>
public static class HearSpeech

View file

@ -93,7 +93,15 @@ public sealed class ChatLog
/// Port from holtburger
/// <c>references/holtburger/.../client/messages.rs</c> lines 476-487.
/// </remarks>
public void OnLocalSpeech(string sender, string text, uint senderGuid, bool isRanged)
/// <param name="logTextType">
/// The wire <c>chatType</c> carried by HearSpeech/HearRangedSpeech
/// (<c>speech.ChatType</c>) — passed through VERBATIM, with zero
/// remapping, matching retail's <c>Handle_Communication__HearSpeech
/// @0x005712A0</c> (the raw <c>arg5</c> feeds <c>AddTextToScroll</c>
/// directly). Defaults to <c>0x02</c> (Speech) for callers that
/// don't have a wire value in hand.
/// </param>
public void OnLocalSpeech(string sender, string text, uint senderGuid, bool isRanged, uint logTextType = 0x02u)
{
// Phase J: ACE's HandleActionTalk broadcasts a HearSpeech echo
// back to the sender too. Detect own echo by guid match and
@ -107,7 +115,10 @@ public sealed class ChatLog
Sender: effectiveSender,
Text: text,
SenderGuid: senderGuid,
ChannelId: 0));
ChannelId: 0)
{
LogTextType = logTextType,
});
}
/// <summary>EmoteText (0x01E0) — server-driven third-person emote.</summary>
@ -118,7 +129,13 @@ public sealed class ChatLog
Sender: senderName,
Text: text,
SenderGuid: senderGuid,
ChannelId: 0));
ChannelId: 0)
{
// Retail hard-codes Emote (0x0C) for every HearEmote line —
// ClientCommunicationSystem::HearEmote @0x0057CBE0, the
// literal constant at 0x0057CF94. Not a wire value.
LogTextType = 0x0Cu,
});
}
/// <summary>SoulEmote (0x01E2) — complex emote (chat + paired animation).</summary>
@ -129,7 +146,12 @@ public sealed class ChatLog
Sender: senderName,
Text: text,
SenderGuid: senderGuid,
ChannelId: 0));
ChannelId: 0)
{
// HearSoulEmote tail-calls HearEmote @0x0057D096 — same
// hard-coded 0x0C.
LogTextType = 0x0Cu,
});
}
/// <summary>PlayerKilled (0x019E) — death announcement.</summary>
@ -147,7 +169,18 @@ public sealed class ChatLog
Sender: "",
Text: deathMessage,
SenderGuid: victimGuid,
ChannelId: killerGuid));
ChannelId: killerGuid)
{
// Inferred by analogy from the sibling GameEvents this opcode
// shares a dispatch pattern with: VictimNotification (0x01AC)
// and KillerNotification (0x01AD) both route through the SAME
// retail handler, ClientCombatSystem::HandleKillerNotification
// Event @0x0056C410 (cases 0xa/0xb of the combat-envelope
// switch, pc:359548-359559), which calls
// AddTextToScroll(..., 0, 1, 0) — type 0x00 Default. No direct
// decomp citation was traced for 0x019E PlayerKilled itself.
LogTextType = 0x00u,
});
}
/// <summary>WeenieError (0x028A) / WeenieErrorWithString (0x028B).</summary>
@ -178,7 +211,15 @@ public sealed class ChatLog
Sender: "",
Text: text,
SenderGuid: 0,
ChannelId: errorId));
ChannelId: errorId)
{
// Retail's HandleFailureEvent @0x00571990 dispatches per ERROR
// CODE across an ~87-case switch, mostly AddTextToScroll(...,
// 0, ...) with a scattered handful at 0x1a (client-local red).
// A full per-code port is future work; 0x00 (Default) matches
// the switch's majority behavior and is the safe baseline.
LogTextType = 0x00u,
});
}
/// <summary>
@ -190,7 +231,21 @@ public sealed class ChatLog
/// <c>ChatVM</c> formatter renders entries as
/// <c>"[ChannelName] Sender says, \"text\""</c> when set.
/// </summary>
public void OnChannelBroadcast(uint channelId, string sender, string text, string channelName = "")
/// <param name="logTextType">
/// The retail <c>LogTextType</c> for this line. When
/// <see langword="null"/> (the legacy 0x0147 default), it is derived
/// from <paramref name="channelId"/> via
/// <see cref="LegacyChannelChatType.Resolve"/> as a HEARD (not
/// own-send) message — correct for this method's only production
/// caller, the inbound <c>ChannelBroadcast</c> GameEvent handler.
/// TurbineChat-sourced calls MUST pass an explicit value computed
/// from the room's <c>TurbineChat.ChatType</c> instead — the wire
/// <paramref name="channelId"/> there is an opaque per-session room
/// GUID, not a legacy channel bitflag, and the two id spaces must
/// never be conflated.
/// </param>
public void OnChannelBroadcast(
uint channelId, string sender, string text, uint? logTextType = null, string channelName = "")
{
Append(new ChatEntry(
Kind: ChatKind.Channel,
@ -200,18 +255,28 @@ public sealed class ChatLog
ChannelId: channelId)
{
ChannelName = channelName,
LogTextType = logTextType ?? LegacyChannelChatType.Resolve(channelId, ownSend: false),
});
}
/// <summary>GameEvent Tell (0x02BD) — whisper received.</summary>
public void OnTellReceived(string sender, string text, uint senderGuid)
/// <param name="logTextType">
/// The wire <c>chatType</c> from the Tell GameEvent payload
/// (<c>GameEvents.Tell.ChatType</c>) — retail's normal value is
/// <c>0x03</c> (Tell), which is also this parameter's default for
/// callers without a wire value in hand.
/// </param>
public void OnTellReceived(string sender, string text, uint senderGuid, uint logTextType = 0x03u)
{
Append(new ChatEntry(
Kind: ChatKind.Tell,
Sender: sender,
Text: text,
SenderGuid: senderGuid,
ChannelId: 0));
ChannelId: 0)
{
LogTextType = logTextType,
});
}
/// <summary>
@ -241,10 +306,28 @@ public sealed class ChatLog
Sender: "",
Text: text,
SenderGuid: 0,
ChannelId: chatType));
ChannelId: chatType)
{
// `chatType` IS the retail LogTextType here — every caller
// (ServerMessage.ChatType, GameEventWiring's transient/
// query-age/use-done sites, App's client-command echoes)
// already passes the wire/retail-correct value.
LogTextType = chatType,
});
}
/// <summary>GameEvent PopupString (0x0004) — modal dialog text.</summary>
/// <summary>
/// GameEvent PopupString (0x0004) — modal dialog text.
/// </summary>
/// <remarks>
/// Retail shows PopUpString as a MODAL DIALOG
/// (<c>Handle_Communication__PopUpString @0x0057FE80</c>), never as a
/// chat-log line — acdream's choice to render it in chat at all is a
/// registered divergence (register row AP-175). Fixed at LogTextType
/// <c>0x00</c> (Default/green) to preserve the color this entry has
/// always rendered with; retail has no chat color for this type since
/// it never reaches the chat log.
/// </remarks>
public void OnPopup(string text)
{
Append(new ChatEntry(
@ -252,7 +335,10 @@ public sealed class ChatLog
Sender: "",
Text: text,
SenderGuid: 0,
ChannelId: 0));
ChannelId: 0)
{
LogTextType = 0x00u,
});
}
/// <summary>
@ -266,7 +352,19 @@ public sealed class ChatLog
/// <c>warning().combat()</c> / <c>error().combat()</c> tag flow at
/// <c>chat.rs:221-308</c>.
/// </summary>
public void OnCombatLine(string text, Combat.CombatLineKind kind = Combat.CombatLineKind.Info)
/// <param name="logTextType">
/// The retail <c>LogTextType</c> for this combat line. Callers should
/// pass one of the ACE-cited combat types (<c>0x16</c> Combat_Self for
/// lines about the local player's OWN offensive action, <c>0x15</c>
/// Combat_Enemy for lines about an enemy's action against the local
/// player — see <see cref="CombatChatTranslator"/>) or <c>0x00</c>
/// Default for retail's decompiled kill/death-notification color
/// (<c>HandleKillerNotificationEvent @0x0056C410</c>). Defaults to
/// <c>0x06</c> (the generic Combat slot) for callers with no more
/// specific classification in hand.
/// </param>
public void OnCombatLine(
string text, Combat.CombatLineKind kind = Combat.CombatLineKind.Info, uint logTextType = 0x06u)
{
Append(new ChatEntry(
Kind: ChatKind.Combat,
@ -276,6 +374,7 @@ public sealed class ChatLog
ChannelId: 0)
{
CombatKind = kind,
LogTextType = logTextType,
});
}
@ -300,7 +399,18 @@ public sealed class ChatLog
/// discriminator the formatter uses to render outgoing-vs-incoming
/// (a real incoming Tell carries the sender's player guid).
/// </remarks>
public void OnSelfSent(ChatKind kind, string text, string targetOrChannel = "")
/// <param name="logTextType">
/// The retail <c>LogTextType</c> for this self-sent line. When
/// <see langword="null"/>, defaults to <c>0x04</c> Speech_Direct_Send
/// for Tell (retail's own-echo "You tell ..." type — cross-check
/// ACE's <c>ChatMessageType.OutgoingTell</c> comment "You tell ...") or
/// <c>0x0B</c> Social_Send for Channel (the simplified own-send default
/// research doc §3.3 records; the LiveSessionCommandRouter production
/// caller overrides this with the precise per-channel-bit value from
/// <see cref="LegacyChannelChatType.Resolve"/> instead of relying on
/// this fallback).
/// </param>
public void OnSelfSent(ChatKind kind, string text, string targetOrChannel = "", uint? logTextType = null)
{
Append(new ChatEntry(
Kind: kind,
@ -315,6 +425,7 @@ public sealed class ChatLog
ChannelId: 0)
{
ChannelName = kind == ChatKind.Channel ? targetOrChannel : "",
LogTextType = logTextType ?? (kind == ChatKind.Tell ? 0x04u : 0x0Bu),
});
}
@ -378,4 +489,17 @@ public readonly record struct ChatEntry(
/// Falls back to <c>"ch {ChannelId}"</c> if not populated.
/// </summary>
public string ChannelName { get; init; } = "";
/// <summary>
/// Campaign CH slice CH1: the retail wire <c>LogTextType</c>
/// (<c>0x00</c>-<c>0x21</c>) that keys
/// <c>RetailChatColorTable</c>/<c>ChatInterface::BuildChatColorLookupTable
/// @0x004F31C0</c>. This is the FULL 34-value retail index space, NOT
/// <see cref="Kind"/> — retail colors by this integer, never by our
/// synthetic 9-value <see cref="ChatKind"/>. Populated by every
/// <c>OnXxx</c> ingestion method above; defaults to <c>0x00</c>
/// (Default/green, retail's own unfilled-slot default) for any entry
/// constructed without setting it explicitly.
/// </summary>
public uint LogTextType { get; init; } = 0x00u;
}

View file

@ -115,7 +115,11 @@ public sealed class CombatChatTranslator : IDisposable
// grows that field, append " Critical hit." here.
"",
FormatAttackConditionsSuffix(0));
_chat.OnCombatLine(line, CombatLineKind.Info);
// Combat_Self (0x16): retail squelch-checks the attacker's OWN
// outgoing-hit notification against ChatMessageType.CombatSelf —
// references/ACE/Source/ACE.Server/WorldObjects/Player_Combat.cs:162-163
// (GameEventAttackerNotification, "You hit X...").
_chat.OnCombatLine(line, CombatLineKind.Info, logTextType: 0x16u);
}
private void HandleDamageTaken(CombatState.DamageIncoming e)
@ -138,21 +142,33 @@ public sealed class CombatChatTranslator : IDisposable
sb.Append('.');
if (e.Critical) sb.Append(" Critical hit.");
sb.Append(FormatAttackConditionsSuffix(0));
_chat.OnCombatLine(sb.ToString(), CombatLineKind.Warning);
// Combat_Enemy (0x15): retail squelch-checks the defender's
// incoming-hit notification against ChatMessageType.CombatEnemy —
// references/ACE/Source/ACE.Server/WorldObjects/Player_Combat.cs:541
// (GameEventDefenderNotification, "X hit you...").
_chat.OnCombatLine(sb.ToString(), CombatLineKind.Warning, logTextType: 0x15u);
}
private void HandleMissedOutgoing(string defenderName)
{
// chat.rs:286-291 — EvasionAttackerNotification:
// "{} evaded your attack."
_chat.OnCombatLine($"{defenderName} evaded your attack.", CombatLineKind.Info);
// Combat_Self (0x16): this is about the LOCAL PLAYER'S OWN attack
// missing — retail squelch-checks GameEventEvasionAttackerNotification
// against CombatSelf, same family as the hit-dealt line above —
// references/ACE/Source/ACE.Server/WorldObjects/Player_Combat.cs:150.
_chat.OnCombatLine($"{defenderName} evaded your attack.", CombatLineKind.Info, logTextType: 0x16u);
}
private void HandleEvadedIncoming(string attackerName)
{
// chat.rs:292-297 — EvasionDefenderNotification:
// "You evaded {}'s attack."
_chat.OnCombatLine($"You evaded {attackerName}'s attack.", CombatLineKind.Info);
// Combat_Enemy (0x15): this is about an ENEMY'S attack (that the
// local player evaded) — retail squelch-checks
// GameEventEvasionDefenderNotification against CombatEnemy —
// references/ACE/Source/ACE.Server/WorldObjects/Player_Combat.cs:345.
_chat.OnCombatLine($"You evaded {attackerName}'s attack.", CombatLineKind.Info, logTextType: 0x15u);
}
private void HandleKillLanded(string victimName, uint victimGuid)
@ -164,7 +180,12 @@ public sealed class CombatChatTranslator : IDisposable
// synthesize a minimal "You killed Foo." line here. The
// detailed sentence (used by retail) arrives separately via
// ChatLog.OnPlayerKilled and is rendered as ChatKind.System.
_chat.OnCombatLine($"You killed {victimName}.", CombatLineKind.Info);
// LogTextType 0x00 Default: retail's own kill/death notification
// handler (VictimNotification 0x01AC + KillerNotification 0x01AD,
// both via ClientCombatSystem::HandleKillerNotificationEvent
// @0x0056C410) calls AddTextToScroll(..., 0, 1, 0) — see
// ChatLog.OnPlayerKilled's identical citation.
_chat.OnCombatLine($"You killed {victimName}.", CombatLineKind.Info, logTextType: 0x00u);
}
// ── Formatters (ported VERBATIM from chat.rs:561-595) ───────────────────

View file

@ -0,0 +1,77 @@
namespace AcDream.Core.Chat;
/// <summary>
/// Maps a legacy <c>ChatChannel (0x0147)</c> bitflag id to retail's wire
/// <c>LogTextType</c> for the chat color table.
///
/// <para>
/// Faithful port of <c>ClientCommunicationSystem::Handle_Communication__
/// ChannelBroadcast @0x00570B90</c> (Sept 2013 EoR build). Retail branches
/// on the channel bit AND on whether the sender-name buffer is the
/// single-char "self" sentinel (<c>m_buffer-&gt;m_len == 1</c>) — i.e.
/// whether this is the local player's OWN outgoing message
/// ("You say to your patron, ...") vs. hearing someone else
/// ("Your patron X tells you, ..."). <see cref="Resolve"/>'s
/// <paramref name="ownSend"/> models that same branch.
/// </para>
///
/// <para>
/// Per-bit findings from the decompiled dispatch (not all bits behave
/// the same for own-send — only Patron/Vassal/Follower get a distinct
/// send-color; Fellowship, Co-Vassals, Allegiance Broadcast, and the
/// generic/admin catch-all use the SAME type for hear and send):
/// </para>
/// </summary>
public static class LegacyChannelChatType
{
/// <summary>
/// Resolve <paramref name="channelBit"/> (the <c>ChannelBroadcast</c>
/// wire channel id, a single flag bit) to a <c>LogTextType</c>.
/// </summary>
/// <param name="channelBit">The wire channel id / bitflag.</param>
/// <param name="ownSend">
/// <see langword="true"/> when this is the local player's own outgoing
/// message (retail's <c>m_buffer-&gt;m_len == 1</c> self-sentinel
/// branch); <see langword="false"/> when hearing another sender.
/// </param>
public static uint Resolve(uint channelBit, bool ownSend) => channelBit switch
{
// Fellowship: same type ("[Fellowship] ...") for hear and send.
// pc:00570e48 (hear, m_buffer_5=0x13) / pc:00570d08 (send, 0x13).
0x0800u => 0x13u,
// Patron / Vassal / Follower(Monarch): hear = Social (0xA,
// "Your patron/vassal/follower X tells you..."); OWN send =
// Social_Send (0xB, "You say to your patron/vassal/follower...").
// pc:00570e50/00570e58 (Patron/Vassal hear, 0xa) + pc:00570e40
// (Follower hear, 0xa); pc:00570c07/00570c21 (all three own-send
// via the shared label_570c21, 0xb).
0x1000u => ownSend ? 0x0Bu : 0x0Au, // Patron
0x2000u => ownSend ? 0x0Bu : 0x0Au, // Vassal
0x4000u => ownSend ? 0x0Bu : 0x0Au, // Follower / Monarch
// Co-Vassals / Allegiance Broadcast: same type for hear and send.
// pc:00571025/00571014 (hear, 0xa) / pc:00570e17/00570df7 (send, 0xa).
0x1000000u => 0x0Au, // Co-Vassals
0x2000000u => 0x0Au, // Allegiance Broadcast
// Unnamed bit — no producer traced, but retail's own dispatch
// assigns it 0x13 (Fellowship's slot) for both hear and send.
// pc:00570d43 (send, 0x13); the hear branch mirrors it via the
// same ebp==0x4000000 special case one level up in the dispatch.
0x4000000u => 0x13u,
// The single named non-family bit inside the generic catch-all:
// 0x400 gets its OWN color (Help, 0xF) where every other
// unmatched bit gets the catch-all (Abuse, 0xE). Both branches
// (hear label_570f0a and send label_570d4f) test `ebp != 0x400`
// with the identical 0xe/0xf split.
0x0400u => 0x0Fu,
// Generic/admin/audit/sentinel catch-all: retail's
// "<Tell> says on the X channel" / "You say on the X channel"
// template, color 0xE (Abuse). pc:00570f1d (hear) / pc:00570d62
// (send) — both compute the same constant 0xe.
_ => 0x0Eu,
};
}

View file

@ -223,10 +223,12 @@ internal sealed class HeadlessGameplayOperations
session!.SendCastTargetedSpell(targetId, spellId);
}
// Client-local text (a bot script's own injected message, never
// reaches the wire), 0x1A — same category as ChatVM.ShowSystemMessage.
public void DisplayMessage(string message) =>
RequireRuntime().CommunicationOwner.Chat.OnSystemMessage(
message,
chatType: 0u);
chatType: 0x1Au);
public void IncrementBusy() =>
RequireRuntime().ActionOwner.Transactions

View file

@ -261,7 +261,12 @@ public sealed class LiveSessionEventRouter : ILiveSessionEventRouting
speech.SenderName,
speech.Text,
speech.SenderGuid,
speech.IsRanged));
speech.IsRanged,
// speech.ChatType is passed through VERBATIM — retail's
// Handle_Communication__HearSpeech @0x005712A0 feeds the
// raw wire word straight into AddTextToScroll with zero
// remapping (research doc §3.3 / HearSpeech.cs doc).
speech.ChatType));
Subscribe<ServerMessage.Parsed>(
h => session.ServerMessageReceived += h,
h => session.ServerMessageReceived -= h,
@ -481,11 +486,16 @@ public sealed class LiveSessionEventRouter : ILiveSessionEventRouting
if (parsed.Body is not TurbineChat.Payload.EventSendToRoom message)
return;
// message.RoomId is an opaque per-session Turbine room GUID, not a
// legacy channel bitflag — ChatLog.OnChannelBroadcast's default
// (legacy-bit) LogTextType derivation would misclassify it, so the
// room's own ChatType maps to LogTextType explicitly here instead.
chat.OnChannelBroadcast(
message.RoomId,
message.SenderName,
message.Message,
TurbineChatDisplayNames.Resolve(message.RoomId, message.ChatType));
logTextType: TurbineChatDisplayNames.LogTextType(message.ChatType),
channelName: TurbineChatDisplayNames.Resolve(message.RoomId, message.ChatType));
}
private static void Validate(

View file

@ -19,4 +19,31 @@ internal static class TurbineChatDisplayNames
TurbineChat.ChatType.Olthoi => "Olthoi",
_ => $"Room 0x{roomId:X8}",
};
/// <summary>
/// Map a Turbine room's <c>TurbineChat.ChatType</c> to retail's wire
/// <c>LogTextType</c> for the chat color table. Faithful port of
/// <c>ChatRoomTracker::GetChatFormat @0x005CD7C0</c>, which writes
/// <c>ChatDisplayInfo::m_ltt</c> directly per room field (research doc
/// <c>docs/research/2026-08-09-chat-retail-color-table.md</c> §2.2):
/// General/Trade/LFG/Roleplay each get their OWN dedicated slot
/// (<c>0x1B</c>-<c>0x1E</c>); every Society variant collapses to the
/// SAME slot (<c>0x20</c>); Allegiance and Olthoi both reuse the
/// Allegiance slot (<c>0x12</c>) rather than getting their own.
/// </summary>
public static uint LogTextType(uint chatType) =>
(TurbineChat.ChatType)chatType switch
{
TurbineChat.ChatType.Allegiance => 0x12u,
TurbineChat.ChatType.General => 0x1Bu,
TurbineChat.ChatType.Trade => 0x1Cu,
TurbineChat.ChatType.Lfg => 0x1Du,
TurbineChat.ChatType.Roleplay => 0x1Eu,
TurbineChat.ChatType.Society => 0x20u,
TurbineChat.ChatType.SocietyCelHan => 0x20u,
TurbineChat.ChatType.SocietyEldWeb => 0x20u,
TurbineChat.ChatType.SocietyRadBlo => 0x20u,
TurbineChat.ChatType.Olthoi => 0x12u,
_ => 0x00u,
};
}

View file

@ -153,9 +153,19 @@ public sealed class ChatPanel : IPanel
for (int i = 0; i < lines.Count; i++)
{
var line = lines[i];
if (line.Kind == ChatKind.Combat && line.CombatKind is { } ck)
if (line.Kind == ChatKind.Combat)
{
renderer.TextColored(ColorForCombat(ck), line.Text);
// Campaign CH slice CH1: color combat lines from the
// retail LogTextType table (Combat_Self/Combat_Enemy/
// Default per CombatChatTranslator's ACE-cited
// mapping) instead of the CombatLineKind info/
// warning/error severity bucket. Every LogTextType
// CombatChatTranslator emits is in-range (<0x22), so
// the fallback below is defensive only.
Vector4 color = RetailChatColorTable.TryGetColor(line.LogTextType, out var resolved)
? resolved
: ColorForCombat(line.CombatKind ?? CombatLineKind.Info);
renderer.TextColored(color, line.Text);
}
else
{

View file

@ -112,7 +112,13 @@ public sealed class ChatVM : IDisposable
/// client-handled commands (/help, /clear, future) to surface
/// local feedback without round-tripping the server.
/// </summary>
public void ShowSystemMessage(string text) => _log.OnSystemMessage(text, chatType: 0);
/// <remarks>
/// LogTextType <c>0x1A</c>: this text never reaches the wire — the
/// same "client-local text" category as retail's own command-parser
/// errors and <c>cant_jump_*</c> strings (research doc
/// <c>docs/research/2026-08-09-chat-retail-color-table.md</c> §2.2).
/// </remarks>
public void ShowSystemMessage(string text) => _log.OnSystemMessage(text, chatType: 0x1Au);
/// <summary>
/// Drain the chat log. Used by the /clear client-side command.
@ -256,7 +262,9 @@ public sealed class ChatVM : IDisposable
/// <see cref="ChatPanel"/> can pick the right rendering primitive
/// per entry (plain <c>Text</c> for most kinds; <c>TextColored</c>
/// for combat lines, with the rgba chosen from
/// <see cref="ChatEntry.CombatKind"/>).
/// <see cref="ChatEntry.CombatKind"/>). Campaign CH slice CH1 also
/// carries <see cref="ChatEntry.LogTextType"/> through — the retail
/// color key, keyed independently of <see cref="ChatKind"/>.
/// </summary>
public IReadOnlyList<FormattedLine> RecentLinesDetailed()
{
@ -272,7 +280,8 @@ public sealed class ChatVM : IDisposable
lines[i] = new FormattedLine(
Text: FormatEntry(entry),
Kind: entry.Kind,
CombatKind: entry.CombatKind);
CombatKind: entry.CombatKind,
LogTextType: entry.LogTextType);
}
return lines;
}
@ -284,7 +293,12 @@ public sealed class ChatVM : IDisposable
/// <see cref="CombatKind"/> to pick a rendering primitive
/// (<c>Text</c> vs <c>TextColored(rgba)</c>).
/// </summary>
/// <param name="LogTextType">
/// Campaign CH slice CH1: the retail wire <c>LogTextType</c> that keys
/// <see cref="RetailChatColorTable"/> — see <see cref="ChatEntry.LogTextType"/>.
/// </param>
public readonly record struct FormattedLine(
string Text,
ChatKind Kind,
CombatLineKind? CombatKind);
CombatLineKind? CombatKind,
uint LogTextType);

View file

@ -0,0 +1,109 @@
using System.Numerics;
namespace AcDream.UI.Abstractions.Panels.Chat;
/// <summary>
/// The exact retail chat font-color lookup table, indexed by the wire
/// <c>LogTextType</c> (the same integer ACE calls <c>ChatMessageType</c>).
///
/// <para>
/// Faithful port of <c>ChatInterface::BuildChatColorLookupTable @0x004F31C0</c>
/// (Sept 2013 EoR build; verified against the PDB-paired binary's <c>.data</c>
/// section, image base <c>0x400000</c>, RGBAColor constants at <c>0x0081C4A8</c>+).
/// Retail default-fills all 34 slots (indices <c>0x00</c>-<c>0x21</c>, 34 loop
/// iterations) with <c>colorGreen</c>, then overwrites 27 of them with 13 named
/// colors; the 7 slots retail never overwrites (<c>0x00, 0x01, 0x10, 0x14, 0x17,
/// 0x18, 0x19</c>) stay green. Every color's alpha is 1.0 in the source data.
/// Full derivation: <c>docs/research/2026-08-09-chat-retail-color-table.md</c> §1-2.
/// </para>
///
/// <para>
/// <b>Out-of-range rule.</b> Retail's consumer,
/// <c>UIElement_Text::SetFontColorHelper @0x00466AC0</c>, reads the list's
/// element count and only applies a new color when the index is IN range;
/// an index &gt;= 34 falls through leaving <c>m_curFontColor</c> untouched — the
/// line inherits whatever color the PREVIOUS line resolved to, not a default.
/// <see cref="TryGetColor"/> models this: it returns <see langword="false"/>
/// for an out-of-range index instead of substituting a fallback color, so
/// callers can implement the same "keep the last color" carry-forward.
/// </para>
/// </summary>
public static class RetailChatColorTable
{
// Named RGBAColor constants (retail .data, 0x0081C4A8-0x0081C578).
private static readonly Vector4 ColorWhite = new(1f, 1f, 1f, 1f);
private static readonly Vector4 Yellow = new(1f, 1f, 0.247f, 1f);
private static readonly Vector4 DarkYellow = new(0.824f, 0.824f, 0.392f, 1f);
private static readonly Vector4 ColorBrightPurple = new(1f, 0.498f, 1f, 1f);
private static readonly Vector4 ColorDarkRed = new(1f, 0.247f, 0.247f, 1f);
private static readonly Vector4 ColorLightRed = new(0.96f, 0.459f, 0.447f, 1f);
private static readonly Vector4 ColorLightBlue = new(0.247f, 0.749f, 1f, 1f);
private static readonly Vector4 ColorPink = new(1f, 0.588f, 0.588f, 1f);
private static readonly Vector4 ColorCyan = new(0.247f, 0.863f, 0.863f, 1f);
private static readonly Vector4 ColorBlueGrey = new(0.706f, 0.863f, 0.941f, 1f);
private static readonly Vector4 ColorGrey = new(0.824f, 0.824f, 0.784f, 1f);
private static readonly Vector4 Orange = new(0.933f, 0.573f, 0.118f, 1f);
private static readonly Vector4 ColorGreen = new(0.5f, 1f, 0.498f, 1f);
private static readonly Vector4 ColorBrightRed = new(1f, 0f, 0f, 1f);
/// <summary>
/// The 34-entry table, index == <c>LogTextType</c> (<c>0x00</c>-<c>0x21</c>).
/// Default-fill is <c>colorGreen</c>; explicit overrides match the builder's
/// <c>SetValue</c> calls verbatim.
/// </summary>
public static readonly IReadOnlyList<Vector4> Colors = new[]
{
/* 0x00 Default */ ColorGreen,
/* 0x01 All */ ColorGreen,
/* 0x02 Speech */ ColorWhite,
/* 0x03 Tell */ Yellow,
/* 0x04 Speech_Direct_Send */ DarkYellow,
/* 0x05 System */ ColorBrightPurple,
/* 0x06 Combat */ ColorDarkRed,
/* 0x07 Magic */ ColorLightBlue,
/* 0x08 Channel */ ColorPink,
/* 0x09 Channel_Send */ ColorPink,
/* 0x0A Social */ Yellow,
/* 0x0B Social_Send */ DarkYellow,
/* 0x0C Emote */ ColorGrey,
/* 0x0D Advancement */ ColorCyan,
/* 0x0E Abuse */ ColorBlueGrey,
/* 0x0F Help */ ColorDarkRed,
/* 0x10 Appraisal */ ColorGreen,
/* 0x11 Spellcasting */ ColorLightBlue,
/* 0x12 Allegiance */ Orange,
/* 0x13 Fellowship */ Yellow,
/* 0x14 World_Broadcast */ ColorGreen,
/* 0x15 Combat_Enemy */ ColorDarkRed,
/* 0x16 Combat_Self */ ColorLightRed,
/* 0x17 Recall */ ColorGreen,
/* 0x18 Craft */ ColorGreen,
/* 0x19 Salvaging */ ColorGreen,
/* 0x1A (client-local text) */ ColorBrightRed,
/* 0x1B (Turbine General) */ ColorBlueGrey,
/* 0x1C (Turbine Trade) */ ColorBlueGrey,
/* 0x1D (Turbine LFG) */ ColorBlueGrey,
/* 0x1E (Turbine Roleplay) */ ColorBlueGrey,
/* 0x1F Admin_Tell */ Yellow,
/* 0x20 (Turbine Society) */ ColorBlueGrey,
/* 0x21 (reserved) */ Orange,
};
/// <summary>
/// Resolve <paramref name="logTextType"/> to its retail color.
/// Returns <see langword="false"/> for an out-of-range index (&gt;=
/// <see cref="Colors"/>.Count) — per retail's <c>SetFontColorHelper</c>,
/// the caller should keep whatever color the previous line resolved to
/// rather than substitute a default.
/// </summary>
public static bool TryGetColor(uint logTextType, out Vector4 color)
{
if (logTextType < (uint)Colors.Count)
{
color = Colors[(int)logTextType];
return true;
}
color = default;
return false;
}
}