From d4423854eb647c64f5dfd6ec07ba55548535151f Mon Sep 17 00:00:00 2001 From: Anna Clemens Date: Tue, 13 Apr 2021 05:33:38 -0400 Subject: [PATCH] refactor: update for 5.5 --- XivCommon/Functions/PartyFinder.cs | 2 +- XivCommon/GameFunctions.cs | 26 ++++++++------------------ XivCommon/XivCommonBase.cs | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/XivCommon/Functions/PartyFinder.cs b/XivCommon/Functions/PartyFinder.cs index 4f579c9..fdc0616 100755 --- a/XivCommon/Functions/PartyFinder.cs +++ b/XivCommon/Functions/PartyFinder.cs @@ -55,7 +55,7 @@ namespace XivCommon.Functions { throw new InvalidOperationException("PartyFinder hooks are not enabled"); } - // Updated 5.41 + // Updated 5.5 const int categoryOffset = 10_655; if (this.PartyFinderAgent == IntPtr.Zero) { diff --git a/XivCommon/GameFunctions.cs b/XivCommon/GameFunctions.cs index 962a12c..f412790 100755 --- a/XivCommon/GameFunctions.cs +++ b/XivCommon/GameFunctions.cs @@ -1,7 +1,5 @@ using System; -using System.Runtime.InteropServices; -using Dalamud.Game; -using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Plugin; using XivCommon.Functions; namespace XivCommon { @@ -9,11 +7,7 @@ namespace XivCommon { /// A class containing game functions /// public class GameFunctions : IDisposable { - private IntPtr UiModulePtr { get; } - - private delegate IntPtr GetUiModuleDelegate(IntPtr basePtr); - - private GetUiModuleDelegate InternalGetUiModule { get; } + private DalamudPluginInterface Interface { get; } /// /// Chat functions @@ -30,15 +24,11 @@ namespace XivCommon { /// public BattleTalk BattleTalk { get; } - internal GameFunctions(Hooks hooks, SigScanner scanner, SeStringManager seStringManager) { - this.UiModulePtr = scanner.GetStaticAddressFromSig("48 8B 0D ?? ?? ?? ?? 48 8D 54 24 ?? 48 83 C1 10 E8 ?? ?? ?? ??"); - - var getUiModulePtr = scanner.ScanText("E8 ?? ?? ?? ?? 83 3B 01"); - this.InternalGetUiModule = Marshal.GetDelegateForFunctionPointer(getUiModulePtr); - - this.Chat = new Chat(this, scanner); - this.PartyFinder = new PartyFinder(scanner, hooks.HasFlag(Hooks.PartyFinder)); - this.BattleTalk = new BattleTalk(this, scanner, seStringManager, hooks.HasFlag(Hooks.BattleTalk)); + internal GameFunctions(Hooks hooks, DalamudPluginInterface @interface) { + this.Interface = @interface; + this.Chat = new Chat(this, @interface.TargetModuleScanner); + this.PartyFinder = new PartyFinder(@interface.TargetModuleScanner, hooks.HasFlag(Hooks.PartyFinder)); + this.BattleTalk = new BattleTalk(this, @interface.TargetModuleScanner, @interface.SeStringManager, hooks.HasFlag(Hooks.BattleTalk)); } /// @@ -52,7 +42,7 @@ namespace XivCommon { /// /// Pointer public IntPtr GetUiModule() { - return this.InternalGetUiModule(Marshal.ReadIntPtr(this.UiModulePtr)); + return this.Interface.Framework.Gui.GetUIModule(); } } } diff --git a/XivCommon/XivCommonBase.cs b/XivCommon/XivCommonBase.cs index 2353b12..cea1465 100755 --- a/XivCommon/XivCommonBase.cs +++ b/XivCommon/XivCommonBase.cs @@ -22,7 +22,7 @@ namespace XivCommon { /// The of the plugin constructing this base /// Flags indicating which hooks to enable public XivCommonBase(DalamudPluginInterface @interface, Hooks hooks = HooksExt.DefaultHooks) { - this.Functions = new GameFunctions(hooks, @interface.TargetModuleScanner, @interface.SeStringManager); + this.Functions = new GameFunctions(hooks, @interface); } ///