Use replicated CVars for max chat message length.

This commit is contained in:
Pieter-Jan Briers
2021-07-17 14:34:18 +02:00
parent b7dc3c81ae
commit 97a3866a40
4 changed files with 14 additions and 63 deletions

View File

@@ -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
/// <summary>
/// The maximum length a player-sent message can be sent
/// </summary>
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<MsgChatMessage>();
_netManager.RegisterNetMessage<ChatMaxMsgLengthMessage>(OnMaxLengthRequest);
// Tell all the connected players the chat's character limit
var msg = _netManager.CreateNetMessage<ChatMaxMsgLengthMessage>();
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<ChatMaxMsgLengthMessage>();
response.MaxMessageLength = MaxMessageLength;
_netManager.ServerSendMessage(response, msg.MsgChannel);
}
public void RegisterChatTransform(TransformChat handler)
{
_chatTransformHandlers.Add(handler);