From d95befe96efbff100c9f9c0ceedb6b8de335d7a7 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Fri, 28 Jun 2024 10:09:24 -0700 Subject: [PATCH] use CS TargetSystem for TargetManager service - Remove address from service, as it's no longer necessary --- .../ClientState/ClientStateAddressResolver.cs | 9 +-------- Dalamud/Game/ClientState/Objects/TargetManager.cs | 15 ++++----------- Dalamud/Plugin/Services/ITargetManager.cs | 5 ----- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/Dalamud/Game/ClientState/ClientStateAddressResolver.cs b/Dalamud/Game/ClientState/ClientStateAddressResolver.cs index 694f46a47..5a5351a38 100644 --- a/Dalamud/Game/ClientState/ClientStateAddressResolver.cs +++ b/Dalamud/Game/ClientState/ClientStateAddressResolver.cs @@ -50,11 +50,6 @@ internal sealed class ClientStateAddressResolver : BaseAddressResolver /// public IntPtr KeyboardStateIndexArray { get; private set; } - /// - /// Gets the address of the target manager. - /// - public IntPtr TargetManager { get; private set; } - /// /// Gets the address of the condition flag array. /// @@ -99,9 +94,7 @@ internal sealed class ClientStateAddressResolver : BaseAddressResolver this.KeyboardStateIndexArray = sig.ScanText("0F B6 94 33 ?? ?? ?? ?? 84 D2") + 0x4; this.ConditionFlags = sig.GetStaticAddressFromSig("48 8D 0D ?? ?? ?? ?? 8B D3 E8 ?? ?? ?? ?? 32 C0 48 83 C4 20"); - - this.TargetManager = sig.GetStaticAddressFromSig("41 89 44 24 ?? 48 8B 05 ?? ?? ?? ??", 8); - + this.GamepadPoll = sig.ScanText("40 55 53 57 41 54 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 44 0F 29 B4 24"); } } diff --git a/Dalamud/Game/ClientState/Objects/TargetManager.cs b/Dalamud/Game/ClientState/Objects/TargetManager.cs index 2b892694e..97a736566 100644 --- a/Dalamud/Game/ClientState/Objects/TargetManager.cs +++ b/Dalamud/Game/ClientState/Objects/TargetManager.cs @@ -2,6 +2,8 @@ using Dalamud.Game.ClientState.Objects.Types; using Dalamud.IoC; using Dalamud.IoC.Internal; +using FFXIVClientStructs.FFXIV.Client.Game.Control; + #pragma warning disable CS0618 namespace Dalamud.Game.ClientState.Objects; @@ -16,23 +18,14 @@ namespace Dalamud.Game.ClientState.Objects; #pragma warning restore SA1015 internal sealed unsafe class TargetManager : IServiceType, ITargetManager { - [ServiceManager.ServiceDependency] - private readonly ClientState clientState = Service.Get(); - [ServiceManager.ServiceDependency] private readonly ObjectTable objectTable = Service.Get(); - - private readonly ClientStateAddressResolver address; - + [ServiceManager.ServiceConstructor] private TargetManager() { - this.address = this.clientState.AddressResolver; } - /// - public IntPtr Address => this.address.TargetManager; - /// public GameObject? Target { @@ -82,5 +75,5 @@ internal sealed unsafe class TargetManager : IServiceType, ITargetManager set => Struct->MouseOverNameplateTarget = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)value?.Address; } - private FFXIVClientStructs.FFXIV.Client.Game.Control.TargetSystem* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Control.TargetSystem*)this.Address; + private TargetSystem* Struct => TargetSystem.Instance(); } diff --git a/Dalamud/Plugin/Services/ITargetManager.cs b/Dalamud/Plugin/Services/ITargetManager.cs index 99a9d8dfb..8b7d78262 100644 --- a/Dalamud/Plugin/Services/ITargetManager.cs +++ b/Dalamud/Plugin/Services/ITargetManager.cs @@ -7,11 +7,6 @@ namespace Dalamud.Game.ClientState.Objects; /// public interface ITargetManager { - /// - /// Gets the address of the target manager. - /// - public nint Address { get; } - /// /// Gets or sets the current target. /// Set to null to clear the target.