From 9372ad35bcd861c5ac9b7e934abd8d5f7cab2ef2 Mon Sep 17 00:00:00 2001 From: Anna Date: Sun, 30 Jan 2022 22:11:03 -0500 Subject: [PATCH] refactor: rename InfoModule-related stuff --- ChatTwo/GameFunctions/Chat.cs | 13 +++++++++++++ ChatTwo/GameFunctions/Context.cs | 8 ++------ ChatTwo/GameFunctions/GameFunctions.cs | 13 ++++++++++++- ChatTwo/GameFunctions/Party.cs | 8 ++------ 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/ChatTwo/GameFunctions/Chat.cs b/ChatTwo/GameFunctions/Chat.cs index 2da2cb6..4ad6571 100755 --- a/ChatTwo/GameFunctions/Chat.cs +++ b/ChatTwo/GameFunctions/Chat.cs @@ -45,6 +45,9 @@ internal sealed unsafe class Chat : IDisposable { [Signature("E8 ?? ?? ?? ?? F6 43 0A 40")] private readonly delegate* unmanaged _getNetworkModule = null!; + [Signature("E8 ?? ?? ?? ?? 48 8B C8 E8 ?? ?? ?? ?? 45 8D 46 FB")] + private readonly delegate* unmanaged _getLinkshellName = null!; + // Hooks private delegate byte ChatLogRefreshDelegate(IntPtr log, ushort eventId, AtkValue* value); @@ -126,6 +129,16 @@ internal sealed unsafe class Chat : IDisposable { this.Activated = null; } + internal string? GetLinkshellName(uint idx) { + var infoProxy = this.Plugin.Functions.GetInfoProxyByIndex(26); + if (infoProxy == IntPtr.Zero) { + return null; + } + + var utf = this._getLinkshellName(infoProxy, idx); + return utf == null ? null : utf->ToString(); + } + private readonly Dictionary _keybinds = new(); internal IReadOnlyDictionary Keybinds => this._keybinds; diff --git a/ChatTwo/GameFunctions/Context.cs b/ChatTwo/GameFunctions/Context.cs index 839e589..8300c44 100755 --- a/ChatTwo/GameFunctions/Context.cs +++ b/ChatTwo/GameFunctions/Context.cs @@ -34,16 +34,12 @@ internal sealed unsafe class Context { } internal void InviteToNoviceNetwork(string name, ushort world) { - if (this._inviteToNoviceNetwork == null || this.Plugin.Functions.Indexer == null) { + if (this._inviteToNoviceNetwork == null) { return; } - var uiModule = Framework.Instance()->GetUiModule(); - // 6.05: 20D722 - var func = (delegate* unmanaged) uiModule->vfunc[33]; - var toIndex = func(uiModule); // 6.05: 20E4CB - var a1 = this.Plugin.Functions.Indexer(toIndex, 0x11); + var a1 = this.Plugin.Functions.GetInfoProxyByIndex(0x11); fixed (byte* namePtr = name.ToTerminatedBytes()) { // can specify content id if we have it, but there's no need diff --git a/ChatTwo/GameFunctions/GameFunctions.cs b/ChatTwo/GameFunctions/GameFunctions.cs index 208ef14..a159a5b 100755 --- a/ChatTwo/GameFunctions/GameFunctions.cs +++ b/ChatTwo/GameFunctions/GameFunctions.cs @@ -21,7 +21,7 @@ internal unsafe class GameFunctions : IDisposable { #region Functions [Signature("E8 ?? ?? ?? ?? 8B FD 8B CD", Fallibility = Fallibility.Fallible)] - internal readonly delegate* unmanaged Indexer = null!; + private readonly delegate* unmanaged _getInfoProxyByIndex = null!; [Signature("E8 ?? ?? ?? ?? 84 C0 74 0D B0 02", Fallibility = Fallibility.Fallible)] private readonly delegate* unmanaged _isMentor = null!; @@ -76,6 +76,17 @@ internal unsafe class GameFunctions : IDisposable { Marshal.FreeHGlobal(this._placeholderNamePtr); } + private static IntPtr GetInfoModule() { + var uiModule = Framework.Instance()->GetUiModule(); + var getInfoModule = (delegate* unmanaged) uiModule->vfunc[33]; + return getInfoModule(uiModule); + } + + internal IntPtr GetInfoProxyByIndex(uint idx) { + var infoModule = GetInfoModule(); + return infoModule == IntPtr.Zero ? IntPtr.Zero : this._getInfoProxyByIndex(infoModule, idx); + } + internal uint? GetCurrentChatLogEntryIndex() { if (this._currentChatEntryOffset == null) { return null; diff --git a/ChatTwo/GameFunctions/Party.cs b/ChatTwo/GameFunctions/Party.cs index 2e94ec2..02ae849 100755 --- a/ChatTwo/GameFunctions/Party.cs +++ b/ChatTwo/GameFunctions/Party.cs @@ -1,6 +1,5 @@ using ChatTwo.Util; using FFXIVClientStructs.FFXIV.Client.System.Framework; -using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Component.GUI; using Siggingway; @@ -28,15 +27,12 @@ internal sealed unsafe class Party { } internal void Invite(string name, ushort world, ulong contentId) { - if (this._inviteToParty == null || this.Plugin.Functions.Indexer == null) { + if (this._inviteToParty == null) { return; } - var uiModule = Framework.Instance()->GetUiModule(); // 6.05: 20D722 - var func = (delegate* unmanaged) uiModule->vfunc[33]; - var toIndex = func(uiModule); - var a1 = this.Plugin.Functions.Indexer(toIndex, 1); + var a1 = this.Plugin.Functions.GetInfoProxyByIndex(1); if (contentId != 0) { // third param is world, but it requires a specific world