Update radio prefix parsing (#13777)

This commit is contained in:
Leon Friedrich
2023-02-19 06:27:56 +13:00
committed by GitHub
parent 63a0c76ecc
commit 75a559fa55
32 changed files with 659 additions and 606 deletions

View File

@@ -65,7 +65,6 @@ public sealed partial class ChatSystem : SharedChatSystem
public override void Initialize()
{
base.Initialize();
InitializeRadio();
InitializeEmotes();
_configurationManager.OnValueChanged(CCVars.LoocEnabled, OnLoocEnabledChanged, true);
_configurationManager.OnValueChanged(CCVars.DeadLoocEnabled, OnDeadLoocEnabledChanged, true);
@@ -76,7 +75,6 @@ public sealed partial class ChatSystem : SharedChatSystem
public override void Shutdown()
{
base.Shutdown();
ShutdownRadio();
ShutdownEmotes();
_configurationManager.UnsubValueChanged(CCVars.LoocEnabled, OnLoocEnabledChanged);
}
@@ -140,6 +138,13 @@ public sealed partial class ChatSystem : SharedChatSystem
if (!CanSendInGame(message, shell, player))
return;
if (desiredType == InGameICChatType.Speak && message.StartsWith(LocalPrefix))
{
// prevent radios and remove prefix.
checkRadioPrefix = false;
message = message[1..];
}
hideGlobalGhostChat |= hideChat;
bool shouldCapitalize = (desiredType != InGameICChatType.Emote);
bool shouldPunctuate = _configurationManager.GetCVar(CCVars.ChatPunctuation);
@@ -159,10 +164,9 @@ public sealed partial class ChatSystem : SharedChatSystem
// This message may have a radio prefix, and should then be whispered to the resolved radio channel
if (checkRadioPrefix)
{
var (radioMessage, channel) = GetRadioPrefix(source, message);
if (channel != null)
if (TryProccessRadioMessage(source, message, out var modMessage, out var channel))
{
SendEntityWhisper(source, radioMessage, hideChat, hideGlobalGhostChat, channel, nameOverride);
SendEntityWhisper(source, modMessage, hideChat, hideGlobalGhostChat, channel, nameOverride);
return;
}
}
@@ -544,15 +548,6 @@ public sealed partial class ChatSystem : SharedChatSystem
.Select(p => p.ConnectedClient);
}
private string SanitizeMessageCapital(string message)
{
if (string.IsNullOrEmpty(message))
return message;
// Capitalize first letter
message = message[0].ToString().ToUpper() + message.Remove(0, 1);
return message;
}
private string SanitizeMessagePeriod(string message)
{
if (string.IsNullOrEmpty(message))