Remove debug info
This commit is contained in:
@@ -1,45 +1,29 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Dalamud.Game;
|
||||
using System.Text;
|
||||
using Dalamud.Utility.Signatures;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.String;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
|
||||
namespace ChatTwo.GameFunctions;
|
||||
|
||||
// From: https://git.anna.lgbt/anna/XivCommon/src/branch/main/XivCommon/Functions/Chat.cs
|
||||
public class ChatCommon
|
||||
public unsafe class ChatCommon
|
||||
{
|
||||
private static class Signatures
|
||||
[Signature("48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 45 84 C9")]
|
||||
private readonly delegate* unmanaged<UIModule*, Utf8String*, nint, byte, void> ProcessChatBox = null!;
|
||||
|
||||
internal ChatCommon()
|
||||
{
|
||||
internal const string SendChat = "48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 45 84 C9";
|
||||
Plugin.GameInteropProvider.InitializeFromAttributes(this);
|
||||
}
|
||||
|
||||
private delegate void ProcessChatBoxDelegate(IntPtr uiModule, IntPtr message, IntPtr unused, byte a4);
|
||||
private ProcessChatBoxDelegate? ProcessChatBox { get; }
|
||||
|
||||
internal ChatCommon(ISigScanner scanner)
|
||||
{
|
||||
if (scanner.TryScanText(Signatures.SendChat, out var processChatBoxPtr))
|
||||
{
|
||||
ProcessChatBox = Marshal.GetDelegateForFunctionPointer<ProcessChatBoxDelegate>(processChatBoxPtr);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void SendMessageUnsafe(byte[] message)
|
||||
public void SendMessageUnsafe(byte[] message)
|
||||
{
|
||||
if (ProcessChatBox == null)
|
||||
throw new InvalidOperationException("Could not find signature for chat sending");
|
||||
|
||||
var uiModule = (IntPtr)UIModule.Instance();
|
||||
|
||||
using var payload = new ChatPayload(message);
|
||||
var mem1 = Marshal.AllocHGlobal(400);
|
||||
Marshal.StructureToPtr(payload, mem1, false);
|
||||
|
||||
ProcessChatBox(uiModule, mem1, IntPtr.Zero, 0);
|
||||
|
||||
Marshal.FreeHGlobal(mem1);
|
||||
var mes = Utf8String.FromSequence(message);
|
||||
ProcessChatBox(UIModule.Instance(), mes, IntPtr.Zero, 0);
|
||||
mes->Dtor(true);
|
||||
}
|
||||
|
||||
public void SendMessage(string message)
|
||||
@@ -57,42 +41,14 @@ public class ChatCommon
|
||||
SendMessageUnsafe(bytes);
|
||||
}
|
||||
|
||||
private static unsafe string SanitiseText(string text)
|
||||
private static string SanitiseText(string text)
|
||||
{
|
||||
var uText = Utf8String.FromString(text);
|
||||
|
||||
uText->SanitizeString( 0x27F, Utf8String.CreateEmpty());
|
||||
|
||||
uText->SanitizeString( 0x27F, (Utf8String*)nint.Zero);
|
||||
var sanitised = uText->ToString();
|
||||
uText->Dtor();
|
||||
uText->Dtor(true);
|
||||
|
||||
return sanitised;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
[SuppressMessage("ReSharper", "PrivateFieldCanBeConvertedToLocalVariable")]
|
||||
private readonly struct ChatPayload : IDisposable
|
||||
{
|
||||
[FieldOffset(0)] private readonly IntPtr textPtr;
|
||||
[FieldOffset(16)] private readonly ulong textLen;
|
||||
[FieldOffset(8)] private readonly ulong unk1;
|
||||
[FieldOffset(24)] private readonly ulong unk2;
|
||||
|
||||
internal ChatPayload(byte[] stringBytes)
|
||||
{
|
||||
textPtr = Marshal.AllocHGlobal(stringBytes.Length + 30);
|
||||
Marshal.Copy(stringBytes, 0, textPtr, stringBytes.Length);
|
||||
Marshal.WriteByte(textPtr + stringBytes.Length, 0);
|
||||
|
||||
textLen = (ulong)(stringBytes.Length + 1);
|
||||
|
||||
unk1 = 64;
|
||||
unk2 = 0;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Marshal.FreeHGlobal(textPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -602,7 +602,6 @@ public sealed class PayloadHandler {
|
||||
}
|
||||
|
||||
var isFriend = GameFunctions.GameFunctions.GetFriends().Any(friend => friend.NameString == player.PlayerName && friend.HomeWorld == world.RowId);
|
||||
Plugin.Log.Information($"Is Friend? {isFriend}");
|
||||
if (!isFriend && ImGui.Selectable(Language.Context_SendFriendRequest))
|
||||
LogWindow.Plugin.Functions.SendFriendRequest(player.PlayerName, (ushort) world.RowId);
|
||||
|
||||
|
||||
+1
-3
@@ -6,7 +6,6 @@ using ChatTwo.Ipc;
|
||||
using ChatTwo.Resources;
|
||||
using ChatTwo.Ui;
|
||||
using ChatTwo.Util;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
using Dalamud.Interface.Windowing;
|
||||
@@ -40,7 +39,6 @@ public sealed class Plugin : IDalamudPlugin
|
||||
[PluginService] internal static IGameConfig GameConfig { get; private set; } = null!;
|
||||
[PluginService] internal static INotificationManager Notification { get; private set; } = null!;
|
||||
[PluginService] internal static IAddonLifecycle AddonLifecycle { get; private set; } = null!;
|
||||
[PluginService] internal static ISigScanner Scanner { get; private set; } = null!;
|
||||
|
||||
internal static Configuration Config = null!;
|
||||
|
||||
@@ -82,7 +80,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
ImGuiUtil.Initialize(this);
|
||||
|
||||
Commands = new Commands(this);
|
||||
Common = new ChatCommon(Scanner);
|
||||
Common = new ChatCommon();
|
||||
TextureCache = new TextureCache();
|
||||
Functions = new GameFunctions.GameFunctions(this);
|
||||
Ipc = new IpcManager();
|
||||
|
||||
Reference in New Issue
Block a user