mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
fix: correct FindAgentInterface
This commit is contained in:
parent
3f73e4f478
commit
0483840197
1 changed files with 17 additions and 16 deletions
|
|
@ -15,6 +15,8 @@ using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.String;
|
using FFXIVClientStructs.FFXIV.Client.System.String;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
|
|
@ -386,12 +388,12 @@ namespace Dalamud.Game.Gui
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="addon">The addon address.</param>
|
/// <param name="addon">The addon address.</param>
|
||||||
/// <returns>A pointer to the agent interface.</returns>
|
/// <returns>A pointer to the agent interface.</returns>
|
||||||
public unsafe IntPtr FindAgentInterface(IntPtr addon)
|
public unsafe IntPtr FindAgentInterface(IntPtr addonPtr)
|
||||||
{
|
{
|
||||||
if (addon == IntPtr.Zero)
|
if (addonPtr == IntPtr.Zero)
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
||||||
var uiModule = (FFXIVClientStructs.FFXIV.Client.UI.UIModule*)this.GetUIModule();
|
var uiModule = (UIModule*)this.GetUIModule();
|
||||||
if (uiModule == null)
|
if (uiModule == null)
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
||||||
|
|
@ -399,21 +401,20 @@ namespace Dalamud.Game.Gui
|
||||||
if (agentModule == null)
|
if (agentModule == null)
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
||||||
var unitBase = (FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)addon;
|
var addon = (AtkUnitBase*)addonPtr;
|
||||||
var id = unitBase->ParentID;
|
var addonId = addon->ParentID == 0 ? addon->ID : addon->ParentID;
|
||||||
if (id == 0)
|
|
||||||
{
|
|
||||||
id = unitBase->ID;
|
|
||||||
if (id == 0)
|
|
||||||
return IntPtr.Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch 6.1, 398 agents
|
if (addonId == 0)
|
||||||
for (var i = 0; i < 398; i++)
|
return IntPtr.Zero;
|
||||||
{
|
|
||||||
var agent = &agentModule->AgentArray[i];
|
|
||||||
|
|
||||||
if (agent->AddonId == id)
|
var index = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var agent = agentModule->GetAgentByInternalID((uint)index++);
|
||||||
|
if (agent == uiModule || agent == null)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (agent->AddonId == addonId)
|
||||||
return new IntPtr(agent);
|
return new IntPtr(agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue