From c75d36f34fb081c6bc2dd05df8d8072cd0856e38 Mon Sep 17 00:00:00 2001 From: Dirius Date: Thu, 30 Jul 2026 03:17:48 -0400 Subject: [PATCH 1/2] Fix handling of language formatting with auto-formatter. --- .../_DEN/Denu/Modules/Chat/FormatterModule.cs | 2 +- .../Radio/EntitySystems/RadioSystem.cs | 2 ++ .../_DEN/Chat/Systems/ChatSystem.Language.cs | 24 ++++++++++++------- .../_DEN/Chat/SharedChatSystem.Language.cs | 15 ++++++------ 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Content.Client/_DEN/Denu/Modules/Chat/FormatterModule.cs b/Content.Client/_DEN/Denu/Modules/Chat/FormatterModule.cs index a53496d51c..d8640cdd88 100644 --- a/Content.Client/_DEN/Denu/Modules/Chat/FormatterModule.cs +++ b/Content.Client/_DEN/Denu/Modules/Chat/FormatterModule.cs @@ -166,7 +166,7 @@ private static MessageFormatter.FormatterConfig CreateFormatterConfig() { new("***", "[bolditalic]", "[/bolditalic]", false, false), new("**", "[bold]", "[/bold]", false, false), - new("\"", "[color={DialogueColor}]\"", "\"[/color]", false, true), + new("\"", "\"[color={DialogueColor}]", "[/color]\"", false, true), new("*", "[italic]", "[/italic]", true, false), new("*", "[italic][color={EmoteColor}]*", "*[/color][/italic]", false, false), }, diff --git a/Content.Server/Radio/EntitySystems/RadioSystem.cs b/Content.Server/Radio/EntitySystems/RadioSystem.cs index 833d2bac6a..b6dddec04a 100644 --- a/Content.Server/Radio/EntitySystems/RadioSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioSystem.cs @@ -179,6 +179,8 @@ public void SendRadioMessage(EntityUid messageSource, channel.LocalizedName, channel.Color); + Log.Debug("Radio: " + wrappedMessage); + if (name != Name(messageSource)) _adminLogger.Add(LogType.Chat, LogImpact.Low, $"Radio message from {ToPrettyString(messageSource):user} as {name} on {channel.LocalizedName}: {unwrappedMessage}"); else diff --git a/Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs b/Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs index b1ec651892..42a9f5ef38 100644 --- a/Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs +++ b/Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs @@ -393,19 +393,18 @@ public void SendComplexMessageToEntity(EntityUid source, // Combine tags back into emotes and dialog so they can be formatted. List<(ChatPart, string)> mergedParts = []; var workingSet = message.Parts; + Log.Debug("====== BEFORE ======"); + foreach (var (kind, part) in workingSet) + { + Log.Debug("Got " + kind + ": [" + part + "]"); + } var lastSeen = workingSet[0]; - for (int i = 0; i < workingSet.Count; i++) + for (int i = 1; i < workingSet.Count; i++) { - if (i == 0) - { - lastSeen = workingSet[0]; - continue; - } - var current = workingSet[i]; // Matching Dialog or Emote. if ((lastSeen.Item1 is ChatPart.Dialog or ChatPart.DialogTag - && current.Item1 is ChatPart.Dialog or ChatPart.DialogTag) + && current.Item1 is ChatPart.Dialog or ChatPart.DialogTag) || (lastSeen.Item1 is ChatPart.Emote or ChatPart.EmoteTag && current.Item1 is ChatPart.Emote or ChatPart.EmoteTag)) { @@ -424,11 +423,18 @@ public void SendComplexMessageToEntity(EntityUid source, } mergedParts.Add(lastSeen); + Log.Debug("------ AFTER ------"); + foreach (var (kind, part) in mergedParts) + { + Log.Debug("Got " + kind + ": [" + part + "]"); + } + Log.Debug("-------------------"); + // Loop over the parts of the complex speech. // Dialog gets a lot of special formatting where as emotes just get default action formatting. foreach (var (kind, part) in mergedParts) { - if (kind == ChatPart.Dialog) + if (kind == ChatPart.Dialog || kind == ChatPart.DialogTag) { unwrappedBuilder.Append(message.Delimiter + part + message.Delimiter); wrappedBuilder.Append(message.Delimiter); diff --git a/Content.Shared/_DEN/Chat/SharedChatSystem.Language.cs b/Content.Shared/_DEN/Chat/SharedChatSystem.Language.cs index 15a72f3cdf..164e6ac9f1 100644 --- a/Content.Shared/_DEN/Chat/SharedChatSystem.Language.cs +++ b/Content.Shared/_DEN/Chat/SharedChatSystem.Language.cs @@ -1,7 +1,6 @@ using System.Linq; using Content.Shared._DEN.CCVar; using Content.Shared._DEN.Language; -using Content.Shared._DEN.Utility; using Content.Shared.Speech; using Robust.Shared.Configuration; using Robust.Shared.Prototypes; @@ -53,7 +52,7 @@ public ComplexChatMessage ObfuscateComplexChatMessage(ComplexChatMessage message /// The correct speech verb prototype to use. public SpeechVerbPrototype GetComplexSpeechVerb(EntityUid source, ComplexChatMessage message, LanguagePrototype language, ChatChannel channel) { - var lastDialog = message.Parts.LastOrDefault(p => p.Item1 == ChatPart.Dialog).Item2; + var lastDialog = message.Parts.LastOrDefault(p => p.Item1 == ChatPart.Dialog).Item2 ?? ""; SpeechVerbPrototype? current = null; Dictionary>? currentSuffixVerbs = null; @@ -178,12 +177,12 @@ public ComplexChatMessage(string message, string delimiter, bool isDetailed, boo return; } - var outside = false; + var outside = true; foreach (var hunk in parsedMsg.Nodes) { if (!hunk.IsPlainText) { - parts.Add((outside ? ChatPart.DialogTag : ChatPart.EmoteTag, hunk.ToString())); + parts.Add((outside ? ChatPart.EmoteTag : ChatPart.DialogTag, hunk.ToString())); continue; } @@ -191,15 +190,17 @@ public ComplexChatMessage(string message, string delimiter, bool isDetailed, boo var pieces = hunk.ToString().Split(Delimiter); if (pieces.Length == 1 && !string.IsNullOrEmpty(pieces[0])) { - parts.Add((outside ? ChatPart.Dialog : ChatPart.Emote, pieces[0])); + parts.Add((outside ? ChatPart.Emote : ChatPart.Dialog, pieces[0])); continue; } foreach (var msgChunk in pieces) { if (!string.IsNullOrEmpty(msgChunk)) - parts.Add((outside ? ChatPart.Dialog : ChatPart.Emote, msgChunk)); - outside = !outside; + { + parts.Add((outside ? ChatPart.Emote : ChatPart.Dialog, msgChunk)); + outside = !outside; + } } } From ba221ae40187a1a309d15680bf6b3d7ae5b7ab69 Mon Sep 17 00:00:00 2001 From: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Date: Tue, 4 Aug 2026 05:14:37 -0300 Subject: [PATCH 2/2] Update Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs --- Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs b/Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs index 42a9f5ef38..0403c22052 100644 --- a/Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs +++ b/Content.Server/_DEN/Chat/Systems/ChatSystem.Language.cs @@ -422,14 +422,7 @@ public void SendComplexMessageToEntity(EntityUid source, } } mergedParts.Add(lastSeen); - - Log.Debug("------ AFTER ------"); - foreach (var (kind, part) in mergedParts) - { - Log.Debug("Got " + kind + ": [" + part + "]"); - } - Log.Debug("-------------------"); - + // Loop over the parts of the complex speech. // Dialog gets a lot of special formatting where as emotes just get default action formatting. foreach (var (kind, part) in mergedParts)