diff --git a/Content.Client/Chat/Managers/ChatManager.cs b/Content.Client/Chat/Managers/ChatManager.cs
index 4af4b111e4..6ec3cfffa7 100644
--- a/Content.Client/Chat/Managers/ChatManager.cs
+++ b/Content.Client/Chat/Managers/ChatManager.cs
@@ -4,12 +4,14 @@ using Content.Client.Administration.Managers;
using Content.Client.Chat.UI;
using Content.Client.Ghost;
using Content.Shared.Administration;
+using Content.Shared.CCVar;
using Content.Shared.Chat;
using Robust.Client.Console;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
+using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -52,7 +54,7 @@ namespace Content.Client.Chat.Managers
///
/// The max amount of characters an entity can send in one message
///
- private int _maxMessageLength = 1000;
+ private int MaxMessageLength => _cfg.GetCVar(CCVars.ChatMaxMessageLength);
public const char ConCmdSlash = '/';
public const char OOCAlias = '[';
@@ -100,6 +102,7 @@ namespace Content.Client.Chat.Managers
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IClientAdminManager _adminMgr = default!;
+ [Dependency] private readonly IConfigurationManager _cfg = default!;
///
/// Current chat box control. This can be modified, so do not depend on saving a reference to this.
@@ -128,15 +131,11 @@ namespace Content.Client.Chat.Managers
public void Initialize()
{
_netManager.RegisterNetMessage(OnChatMessage);
- _netManager.RegisterNetMessage(OnMaxLengthReceived);
_speechBubbleRoot = new LayoutContainer();
LayoutContainer.SetAnchorPreset(_speechBubbleRoot, LayoutContainer.LayoutPreset.Wide);
_userInterfaceManager.StateRoot.AddChild(_speechBubbleRoot);
_speechBubbleRoot.SetPositionFirst();
-
- // When connexion is achieved, request the max chat message length
- _netManager.Connected += RequestMaxLength;
}
public void PostInject()
@@ -383,12 +382,12 @@ namespace Content.Client.Chat.Managers
return;
// Check if message is longer than the character limit
- if (text.Length > _maxMessageLength)
+ if (text.Length > MaxMessageLength)
{
if (CurrentChatBox != null)
{
string locWarning = Loc.GetString("chat-manager-max-message-length",
- ("maxMessageLength", _maxMessageLength));
+ ("maxMessageLength", MaxMessageLength));
CurrentChatBox.AddLine(locWarning, ChatChannel.Server, Color.Orange);
CurrentChatBox.ClearOnEnter = false; // The text shouldn't be cleared if it hasn't been sent
}
@@ -510,17 +509,6 @@ namespace Content.Client.Chat.Managers
}
}
- private void OnMaxLengthReceived(ChatMaxMsgLengthMessage msg)
- {
- _maxMessageLength = msg.MaxMessageLength;
- }
-
- private void RequestMaxLength(object? sender, NetChannelArgs args)
- {
- ChatMaxMsgLengthMessage msg = _netManager.CreateNetMessage();
- _netManager.ClientSendMessage(msg);
- }
-
private void AddSpeechBubble(MsgChatMessage msg, SpeechBubble.SpeechType speechType)
{
if (!_entityManager.TryGetEntity(msg.SenderEntity, out var entity))
diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs
index 17e24a7078..8bc32991b4 100644
--- a/Content.Server/Chat/Managers/ChatManager.cs
+++ b/Content.Server/Chat/Managers/ChatManager.cs
@@ -12,10 +12,8 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Administration;
using Content.Shared.CCVar;
using Content.Shared.Chat;
-using Content.Shared.Emoting;
using Content.Shared.Inventory;
using Content.Shared.Notification.Managers;
-using Content.Shared.Speech;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Configuration;
@@ -52,7 +50,7 @@ namespace Content.Server.Chat.Managers
///
/// The maximum length a player-sent message can be sent
///
- public const int MaxMessageLength = 1000;
+ public int MaxMessageLength => _configurationManager.GetCVar(CCVars.ChatMaxMessageLength);
private const int VoiceRange = 7; // how far voice goes in world units
@@ -64,12 +62,6 @@ namespace Content.Server.Chat.Managers
public void Initialize()
{
_netManager.RegisterNetMessage();
- _netManager.RegisterNetMessage(OnMaxLengthRequest);
-
- // Tell all the connected players the chat's character limit
- var msg = _netManager.CreateNetMessage();
- msg.MaxMessageLength = MaxMessageLength;
- _netManager.ServerSendToAll(msg);
_configurationManager.OnValueChanged(CCVars.OocEnabled, OnOocEnabledChanged, true);
_configurationManager.OnValueChanged(CCVars.AdminOocEnabled, OnAdminOocEnabledChanged, true);
@@ -368,13 +360,6 @@ namespace Content.Server.Chat.Managers
_netManager.ServerSendToAll(msg);
}
- private void OnMaxLengthRequest(ChatMaxMsgLengthMessage msg)
- {
- var response = _netManager.CreateNetMessage();
- response.MaxMessageLength = MaxMessageLength;
- _netManager.ServerSendMessage(response, msg.MsgChannel);
- }
-
public void RegisterChatTransform(TransformChat handler)
{
_chatTransformHandlers.Add(handler);
diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs
index 2538e65852..6ba43c71e8 100644
--- a/Content.Shared/CCVar/CCVars.cs
+++ b/Content.Shared/CCVar/CCVars.cs
@@ -345,5 +345,12 @@ namespace Content.Shared.CCVar
public static readonly CVarDef ViewportScaleRender =
CVarDef.Create("viewport.scale_render", true, CVar.CLIENTONLY | CVar.ARCHIVE);
+
+ /*
+ * CHAT
+ */
+
+ public static readonly CVarDef ChatMaxMessageLength =
+ CVarDef.Create("chat.max_message_length", 1000, CVar.SERVER | CVar.REPLICATED);
}
}
diff --git a/Content.Shared/Chat/ChatMaxMsgLengthMessage.cs b/Content.Shared/Chat/ChatMaxMsgLengthMessage.cs
deleted file mode 100644
index f00062b21b..0000000000
--- a/Content.Shared/Chat/ChatMaxMsgLengthMessage.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using Lidgren.Network;
-using Robust.Shared.Network;
-
-namespace Content.Shared.Chat
-{
- ///
- /// This message is sent by the server to let clients know what is the chat's character limit for this server.
- /// It is first sent by the client as a request
- ///
- public sealed class ChatMaxMsgLengthMessage : NetMessage
- {
- public override MsgGroups MsgGroup => MsgGroups.Command;
-
- ///
- /// The max length a player-sent message can get
- ///
- public int MaxMessageLength { get; set; }
-
- public override void ReadFromBuffer(NetIncomingMessage buffer)
- {
- MaxMessageLength = buffer.ReadInt32();
- }
-
- public override void WriteToBuffer(NetOutgoingMessage buffer)
- {
- buffer.Write(MaxMessageLength);
- }
- }
-}