Remove debug info
This commit is contained in:
@@ -1,45 +1,29 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Text;
|
||||||
using System.Runtime.InteropServices;
|
using Dalamud.Utility.Signatures;
|
||||||
using System.Text;
|
|
||||||
using Dalamud.Game;
|
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.String;
|
using FFXIVClientStructs.FFXIV.Client.System.String;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
|
|
||||||
namespace ChatTwo.GameFunctions;
|
namespace ChatTwo.GameFunctions;
|
||||||
|
|
||||||
// From: https://git.anna.lgbt/anna/XivCommon/src/branch/main/XivCommon/Functions/Chat.cs
|
// 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);
|
public void SendMessageUnsafe(byte[] message)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if (ProcessChatBox == null)
|
if (ProcessChatBox == null)
|
||||||
throw new InvalidOperationException("Could not find signature for chat sending");
|
throw new InvalidOperationException("Could not find signature for chat sending");
|
||||||
|
|
||||||
var uiModule = (IntPtr)UIModule.Instance();
|
var mes = Utf8String.FromSequence(message);
|
||||||
|
ProcessChatBox(UIModule.Instance(), mes, IntPtr.Zero, 0);
|
||||||
using var payload = new ChatPayload(message);
|
mes->Dtor(true);
|
||||||
var mem1 = Marshal.AllocHGlobal(400);
|
|
||||||
Marshal.StructureToPtr(payload, mem1, false);
|
|
||||||
|
|
||||||
ProcessChatBox(uiModule, mem1, IntPtr.Zero, 0);
|
|
||||||
|
|
||||||
Marshal.FreeHGlobal(mem1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendMessage(string message)
|
public void SendMessage(string message)
|
||||||
@@ -57,42 +41,14 @@ public class ChatCommon
|
|||||||
SendMessageUnsafe(bytes);
|
SendMessageUnsafe(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static unsafe string SanitiseText(string text)
|
private static string SanitiseText(string text)
|
||||||
{
|
{
|
||||||
var uText = Utf8String.FromString(text);
|
var uText = Utf8String.FromString(text);
|
||||||
|
|
||||||
uText->SanitizeString( 0x27F, Utf8String.CreateEmpty());
|
uText->SanitizeString( 0x27F, (Utf8String*)nint.Zero);
|
||||||
|
|
||||||
var sanitised = uText->ToString();
|
var sanitised = uText->ToString();
|
||||||
uText->Dtor();
|
uText->Dtor(true);
|
||||||
|
|
||||||
return sanitised;
|
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);
|
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))
|
if (!isFriend && ImGui.Selectable(Language.Context_SendFriendRequest))
|
||||||
LogWindow.Plugin.Functions.SendFriendRequest(player.PlayerName, (ushort) world.RowId);
|
LogWindow.Plugin.Functions.SendFriendRequest(player.PlayerName, (ushort) world.RowId);
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -6,7 +6,6 @@ using ChatTwo.Ipc;
|
|||||||
using ChatTwo.Resources;
|
using ChatTwo.Resources;
|
||||||
using ChatTwo.Ui;
|
using ChatTwo.Ui;
|
||||||
using ChatTwo.Util;
|
using ChatTwo.Util;
|
||||||
using Dalamud.Game;
|
|
||||||
using Dalamud.Game.ClientState.Conditions;
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
using Dalamud.Game.ClientState.Objects;
|
using Dalamud.Game.ClientState.Objects;
|
||||||
using Dalamud.Interface.Windowing;
|
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 IGameConfig GameConfig { get; private set; } = null!;
|
||||||
[PluginService] internal static INotificationManager Notification { 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 IAddonLifecycle AddonLifecycle { get; private set; } = null!;
|
||||||
[PluginService] internal static ISigScanner Scanner { get; private set; } = null!;
|
|
||||||
|
|
||||||
internal static Configuration Config = null!;
|
internal static Configuration Config = null!;
|
||||||
|
|
||||||
@@ -82,7 +80,7 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
ImGuiUtil.Initialize(this);
|
ImGuiUtil.Initialize(this);
|
||||||
|
|
||||||
Commands = new Commands(this);
|
Commands = new Commands(this);
|
||||||
Common = new ChatCommon(Scanner);
|
Common = new ChatCommon();
|
||||||
TextureCache = new TextureCache();
|
TextureCache = new TextureCache();
|
||||||
Functions = new GameFunctions.GameFunctions(this);
|
Functions = new GameFunctions.GameFunctions(this);
|
||||||
Ipc = new IpcManager();
|
Ipc = new IpcManager();
|
||||||
|
|||||||
Reference in New Issue
Block a user