diff --git a/Content.Client/Chat/Managers/ChatManager.cs b/Content.Client/Chat/Managers/ChatManager.cs index 78f3fd9269..ebe362bbdf 100644 --- a/Content.Client/Chat/Managers/ChatManager.cs +++ b/Content.Client/Chat/Managers/ChatManager.cs @@ -363,19 +363,22 @@ namespace Content.Client.Chat.Managers private void OnChatMessage(MsgChatMessage msg) { // Log all incoming chat to repopulate when filter is un-toggled - var storedMessage = new StoredChatMessage(msg); - _history.Add(storedMessage); - MessageAdded?.Invoke(storedMessage); - - if (!storedMessage.Read) + if (!msg.HideChat) { - Logger.Debug($"Message filtered: {storedMessage.Channel}: {storedMessage.Message}"); - if (!_unreadMessages.TryGetValue(msg.Channel, out var count)) - count = 0; + var storedMessage = new StoredChatMessage(msg); + _history.Add(storedMessage); + MessageAdded?.Invoke(storedMessage); - count += 1; - _unreadMessages[msg.Channel] = count; - UnreadMessageCountsUpdated?.Invoke(); + if (!storedMessage.Read) + { + Logger.Debug($"Message filtered: {storedMessage.Channel}: {storedMessage.Message}"); + if (!_unreadMessages.TryGetValue(msg.Channel, out var count)) + count = 0; + + count += 1; + _unreadMessages[msg.Channel] = count; + UnreadMessageCountsUpdated?.Invoke(); + } } // Local messages that have an entity attached get a speech bubble. diff --git a/Content.Server/Advertise/AdvertiseSystem.cs b/Content.Server/Advertise/AdvertiseSystem.cs index a7548a979d..1e8c483daa 100644 --- a/Content.Server/Advertise/AdvertiseSystem.cs +++ b/Content.Server/Advertise/AdvertiseSystem.cs @@ -61,7 +61,7 @@ namespace Content.Server.Advertise return; if (_prototypeManager.TryIndex(advertise.PackPrototypeId, out AdvertisementsPackPrototype? advertisements)) - _chatManager.EntitySay(advertise.Owner, Loc.GetString(_random.Pick(advertisements.Advertisements))); + _chatManager.EntitySay(advertise.Owner, Loc.GetString(_random.Pick(advertisements.Advertisements)), hideChat: true); if(refresh) RefreshTimer(uid, true, advertise); diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index 59953a32b3..8d1a8b7609 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -108,7 +108,7 @@ namespace Content.Server.Chat.Managers _netManager.ServerSendMessage(msg, player.ConnectedClient); } - public void EntitySay(IEntity source, string message) + public void EntitySay(IEntity source, string message, bool hideChat=false) { if (!EntitySystem.Get().CanSpeak(source.Uid)) { @@ -190,6 +190,7 @@ namespace Content.Server.Chat.Managers msg.Message = message; msg.MessageWrap = Loc.GetString("chat-manager-entity-say-wrap-message",("entityName", source.Name)); msg.SenderEntity = source.Uid; + msg.HideChat = hideChat; _netManager.ServerSendToMany(msg, clients); } diff --git a/Content.Server/Chat/Managers/IChatManager.cs b/Content.Server/Chat/Managers/IChatManager.cs index 0bc598020d..79f6c99dff 100644 --- a/Content.Server/Chat/Managers/IChatManager.cs +++ b/Content.Server/Chat/Managers/IChatManager.cs @@ -21,7 +21,8 @@ namespace Content.Server.Chat.Managers void DispatchServerMessage(IPlayerSession player, string message); - void EntitySay(IEntity source, string message); + /// If true, message will not be logged to chat boxes but will still produce a speech bubble. + void EntitySay(IEntity source, string message, bool hideChat=false); void EntityMe(IEntity source, string action); void SendOOC(IPlayerSession player, string message); diff --git a/Content.Shared/Chat/MsgChatMessage.cs b/Content.Shared/Chat/MsgChatMessage.cs index eae2733c76..77e39a1fe5 100644 --- a/Content.Shared/Chat/MsgChatMessage.cs +++ b/Content.Shared/Chat/MsgChatMessage.cs @@ -40,6 +40,8 @@ namespace Content.Shared.Chat /// public Color MessageColorOverride { get; set; } = Color.Transparent; + public bool HideChat { get; set; } + public override void ReadFromBuffer(NetIncomingMessage buffer) { @@ -57,6 +59,7 @@ namespace Content.Shared.Chat break; } MessageColorOverride = buffer.ReadColor(); + HideChat = buffer.ReadBoolean(); } public override void WriteToBuffer(NetOutgoingMessage buffer) @@ -75,6 +78,7 @@ namespace Content.Shared.Chat break; } buffer.Write(MessageColorOverride); + buffer.Write(HideChat); } } }