Files
HellionChat/ChatTwo/GameFunctions/ChatBox.cs
T
JonKazama-Hellion 7d5496e959 refactor(namespace): rename ChatTwo.* to HellionChat.* across all source files
81 namespace declarations and 100 using directives converted via sed,
plus two FQN-aliases (ChatTwoPartyFinderPayload in PayloadHandler.cs and
ModifierFlag in KeybindManager.cs) updated. Critical: Language.Designer.cs
and HellionStrings.Designer.cs ResourceManager string arguments updated
synchronously — these are runtime reflection lookups not caught by the
C# compiler.

Two intentional ChatTwo references remain: the legacy migration path
'ChatTwo.json' in Plugin.cs (still points to upstream Chat 2's config
file by design) and the InternalsVisibleTo declaration in
AssemblyInfo.cs (handled in the upcoming repo-folder rename task).

The local alias names 'ChatTwoPartyFinderPayload' and 'ChatTwoConflictDetector'
are preserved as local symbols; only their target namespaces and references
changed.
2026-05-03 21:23:28 +02:00

43 lines
1.2 KiB
C#

using System.Text;
using HellionChat.Resources;
using Dalamud.Memory;
using FFXIVClientStructs.FFXIV.Client.System.String;
using FFXIVClientStructs.FFXIV.Client.UI;
namespace HellionChat.GameFunctions;
public unsafe class ChatBox
{
public static void SendMessageUnsafe(byte[] message)
{
var mes = Utf8String.FromSequence(message.NullTerminate());
UIModule.Instance()->ProcessChatBoxEntry(mes);
mes->Dtor(true);
}
public static void SendMessage(string message)
{
var bytes = Encoding.UTF8.GetBytes(message);
if (bytes.Length == 0)
throw new ArgumentException(Language.ChatBox_Error_Empty, nameof(message));
if (bytes.Length > 500)
throw new ArgumentException(Language.ChatBox_Error_Too_Long, nameof(message));
if (message.Length != SanitiseText(message).Length)
throw new ArgumentException(Language.ChatBox_Error_Invalid, nameof(message));
SendMessageUnsafe(bytes);
}
private static string SanitiseText(string text)
{
var uText = Utf8String.FromString(text);
uText->SanitizeString((AllowedEntities) 0x27F);
var sanitised = uText->ToString();
uText->Dtor(true);
return sanitised;
}
}