Apply breaking changes

This commit is contained in:
MidoriKami 2025-11-30 12:37:51 -08:00
parent 08c1768286
commit 386828005b
15 changed files with 114 additions and 261 deletions

View file

@ -5,19 +5,24 @@ namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
/// <summary>
/// Base class for AddonLifecycle AddonArgTypes.
/// </summary>
public abstract class AddonArgs
public class AddonArgs
{
/// <summary>
/// Constant string representing the name of an addon that is invalid.
/// </summary>
public const string InvalidAddon = "NullAddon";
private string? addonName;
/// <summary>
/// Initializes a new instance of the <see cref="AddonArgs"/> class.
/// </summary>
internal AddonArgs()
{
}
/// <summary>
/// Gets the name of the addon this args referrers to.
/// </summary>
public string AddonName => this.GetAddonName();
public string AddonName { get; private set; } = InvalidAddon;
/// <summary>
/// Gets the pointer to the addons AtkUnitBase.
@ -25,28 +30,17 @@ public abstract class AddonArgs
public AtkUnitBasePtr Addon
{
get;
internal set;
internal set
{
field = value;
if (!this.Addon.IsNull && !string.IsNullOrEmpty(value.Name))
this.AddonName = value.Name;
}
}
/// <summary>
/// Gets the type of these args.
/// </summary>
public abstract AddonArgsType Type { get; }
/// <summary>
/// Helper method for ensuring the name of the addon is valid.
/// </summary>
/// <returns>The name of the addon for this object. <see cref="InvalidAddon"/> when invalid.</returns>
private string GetAddonName()
{
if (this.Addon.IsNull)
return InvalidAddon;
var name = this.Addon.Name;
if (string.IsNullOrEmpty(name))
return InvalidAddon;
return this.addonName ??= name;
}
public virtual AddonArgsType Type => AddonArgsType.Generic;
}

View file

@ -1,21 +0,0 @@
using Dalamud.Utility;
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
/// <summary>
/// Addon argument data for Draw events.
/// </summary>
[Obsolete("Use AddonGenericArgs instead.")]
[Api15ToDo("Remove this")]
public class AddonDrawArgs : AddonArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="AddonDrawArgs"/> class.
/// </summary>
internal AddonDrawArgs()
{
}
/// <inheritdoc/>
public override AddonArgsType Type => AddonArgsType.Draw;
}

View file

@ -1,21 +0,0 @@
using Dalamud.Utility;
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
/// <summary>
/// Addon argument data for ReceiveEvent events.
/// </summary>
[Obsolete("Use AddonGenericArgs instead.")]
[Api15ToDo("Remove this")]
public class AddonFinalizeArgs : AddonArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="AddonFinalizeArgs"/> class.
/// </summary>
internal AddonFinalizeArgs()
{
}
/// <inheritdoc/>
public override AddonArgsType Type => AddonArgsType.Finalize;
}

View file

@ -1,17 +0,0 @@
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
/// <summary>
/// Addon argument data for Draw events.
/// </summary>
public class AddonGenericArgs : AddonArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="AddonGenericArgs"/> class.
/// </summary>
internal AddonGenericArgs()
{
}
/// <inheritdoc/>
public override AddonArgsType Type => AddonArgsType.Generic;
}

View file

@ -1,5 +1,3 @@
using Dalamud.Utility;
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
/// <summary>
@ -35,6 +33,5 @@ public class AddonReceiveEventArgs : AddonArgs
/// <summary>
/// Gets or sets the pointer to an AtkEventData for this event message.
/// </summary>
[Api14ToDo("Rename to AtkEventData")]
public nint Data { get; set; }
public nint AtkEventData { get; set; }
}

View file

@ -1,35 +0,0 @@
using Dalamud.Utility;
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
/// <summary>
/// Addon argument data for Update events.
/// </summary>
[Obsolete("Use AddonGenericArgs instead.")]
[Api15ToDo("Remove this")]
public class AddonUpdateArgs : AddonArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="AddonUpdateArgs"/> class.
/// </summary>
internal AddonUpdateArgs()
{
}
/// <inheritdoc/>
public override AddonArgsType Type => AddonArgsType.Update;
/// <summary>
/// Gets or sets the time since the last update.
/// </summary>
internal float TimeDeltaInternal { get; set; }
/// <summary>
/// Gets the time since the last update.
/// </summary>
private float TimeDelta
{
get => this.TimeDeltaInternal;
init => this.TimeDeltaInternal = value;
}
}

View file

@ -5,26 +5,16 @@
/// </summary>
public enum AddonArgsType
{
/// <summary>
/// Generic arg type that contains no meaningful data.
/// </summary>
Generic,
/// <summary>
/// Contains argument data for Setup.
/// </summary>
Setup,
/// <summary>
/// Contains argument data for Update.
/// </summary>
Update,
/// <summary>
/// Contains argument data for Draw.
/// </summary>
Draw,
/// <summary>
/// Contains argument data for Finalize.
/// </summary>
Finalize,
/// <summary>
/// Contains argument data for RequestedUpdate.
/// </summary>
@ -39,9 +29,4 @@ public enum AddonArgsType
/// Contains argument data for ReceiveEvent.
/// </summary>
ReceiveEvent,
/// <summary>
/// Generic arg type that contains no meaningful data.
/// </summary>
Generic,
}

View file

@ -29,7 +29,6 @@ public enum AddonEvent
/// An event that is fired before an addon begins its update cycle via <see cref="AtkUnitBase.Update"/>. This event
/// is fired every frame that an addon is loaded, regardless of visibility.
/// </summary>
/// <seealso cref="AddonUpdateArgs"/>
PreUpdate,
/// <summary>
@ -42,7 +41,6 @@ public enum AddonEvent
/// An event that is fired before an addon begins drawing to screen via <see cref="AtkUnitBase.Draw"/>. Unlike
/// <see cref="PreUpdate"/>, this event is only fired if an addon is visible or otherwise drawing to screen.
/// </summary>
/// <seealso cref="AddonDrawArgs"/>
PreDraw,
/// <summary>
@ -62,7 +60,6 @@ public enum AddonEvent
/// <br />
/// As this is part of the destruction process for an addon, this event does not have an associated Post event.
/// </remarks>
/// <seealso cref="AddonFinalizeArgs"/>
PreFinalize,
/// <summary>

View file

@ -59,13 +59,15 @@ internal unsafe class AddonLifecycle : IInternalDisposableService
{
if (!this.EventListeners.ContainsKey(listener.EventType))
{
this.EventListeners.TryAdd(listener.EventType, []);
if (!this.EventListeners.TryAdd(listener.EventType, []))
return;
}
// Note: string.Empty is a valid addon name, as that will trigger on any addon for this event type
if (!this.EventListeners[listener.EventType].ContainsKey(listener.AddonName))
{
this.EventListeners[listener.EventType].TryAdd(listener.AddonName, []);
if (!this.EventListeners[listener.EventType].TryAdd(listener.AddonName, []))
return;
}
this.EventListeners[listener.EventType][listener.AddonName].Add(listener);

View file

@ -1,24 +0,0 @@
using Dalamud.Utility;
namespace Dalamud.Game.Addon.Lifecycle;
/// <summary>
/// AddonLifecycleService memory address resolver.
/// </summary>
[Api14ToDo("Remove this class entirely, its not used by AddonLifecycle anymore, also need to use something else for HookWidget")]
internal class AddonLifecycleAddressResolver : BaseAddressResolver
{
/// <summary>
/// Gets the address of the addon finalize hook invoked by the AtkUnitManager.
/// </summary>
public nint AddonFinalize { get; private set; }
/// <summary>
/// Scan for and setup any configured address pointers.
/// </summary>
/// <param name="sig">The signature scanner to facilitate setup.</param>
protected override void Setup64Bit(ISigScanner sig)
{
this.AddonFinalize = sig.ScanText("E8 ?? ?? ?? ?? 48 83 EF 01 75 D5");
}
}

View file

@ -25,17 +25,12 @@ internal class AddonLifecycleEventListener
/// string.Empty if it wants to be called for any addon.
/// </summary>
public string AddonName { get; init; }
/// <summary>
/// Gets or sets a value indicating whether this event has been unregistered.
/// </summary>
public bool Removed { get; set; }
/// <summary>
/// Gets the event type this listener is looking for.
/// </summary>
public AddonEvent EventType { get; init; }
/// <summary>
/// Gets the delegate this listener invokes.
/// </summary>

View file

@ -26,14 +26,18 @@ internal unsafe class AddonVirtualTable : IDisposable
private readonly AddonLifecycle lifecycleService;
private readonly AddonSetupArgs addonSetupArg = new();
private readonly AddonFinalizeArgs addonFinalizeArg = new();
private readonly AddonDrawArgs addonDrawArg = new();
private readonly AddonUpdateArgs addonUpdateArg = new();
private readonly AddonRefreshArgs addonRefreshArg = new();
private readonly AddonRequestedUpdateArgs addonRequestedUpdateArg = new();
private readonly AddonReceiveEventArgs addonReceiveEventArg = new();
private readonly AddonGenericArgs addonGenericArg = new();
// Each addon gets its own set of args that are used to mutate the original call when used in pre-calls
private readonly AddonSetupArgs setupArgs = new();
private readonly AddonArgs finalizeArgs = new();
private readonly AddonArgs drawArgs = new();
private readonly AddonArgs updateArgs = new();
private readonly AddonRefreshArgs refreshArgs = new();
private readonly AddonRequestedUpdateArgs requestedUpdateArgs = new();
private readonly AddonReceiveEventArgs receiveEventArgs = new();
private readonly AddonArgs openArgs = new();
private readonly AddonArgs closeArgs = new();
private readonly AddonArgs showArgs = new();
private readonly AddonArgs hideArgs = new();
private readonly AtkUnitBase* atkUnitBase;
@ -133,12 +137,13 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonSetupArg.Addon = addon;
this.addonSetupArg.AtkValueCount = valueCount;
this.addonSetupArg.AtkValues = (nint)values;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreSetup, this.addonSetupArg);
valueCount = this.addonSetupArg.AtkValueCount;
values = (AtkValue*)this.addonSetupArg.AtkValues;
this.setupArgs.Addon = addon;
this.setupArgs.AtkValueCount = valueCount;
this.setupArgs.AtkValues = (nint)values;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreSetup, this.setupArgs);
valueCount = this.setupArgs.AtkValueCount;
values = (AtkValue*)this.setupArgs.AtkValues;
try
{
@ -149,15 +154,15 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonSetup. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostSetup, this.addonSetupArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostSetup, this.setupArgs);
}
private void OnAddonFinalize(AtkUnitBase* thisPtr)
{
this.LogEvent(EnableLogging);
this.addonFinalizeArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreFinalize, this.addonFinalizeArg);
this.finalizeArgs.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreFinalize, this.finalizeArgs);
try
{
@ -173,8 +178,8 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonDrawArg.Addon = addon;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreDraw, this.addonDrawArg);
this.drawArgs.Addon = addon;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreDraw, this.drawArgs);
try
{
@ -185,16 +190,15 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonDraw. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostDraw, this.addonDrawArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostDraw, this.drawArgs);
}
private void OnAddonUpdate(AtkUnitBase* addon, float delta)
{
this.LogEvent(EnableLogging);
this.addonUpdateArg.Addon = addon;
this.addonUpdateArg.TimeDeltaInternal = delta;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreUpdate, this.addonUpdateArg);
this.updateArgs.Addon = addon;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreUpdate, this.updateArgs);
try
{
@ -205,7 +209,7 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonUpdate. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostUpdate, this.addonUpdateArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostUpdate, this.updateArgs);
}
private bool OnAddonRefresh(AtkUnitBase* addon, uint valueCount, AtkValue* values)
@ -214,12 +218,13 @@ internal unsafe class AddonVirtualTable : IDisposable
var result = false;
this.addonRefreshArg.Addon = addon;
this.addonRefreshArg.AtkValueCount = valueCount;
this.addonRefreshArg.AtkValues = (nint)values;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreRefresh, this.addonRefreshArg);
valueCount = this.addonRefreshArg.AtkValueCount;
values = (AtkValue*)this.addonRefreshArg.AtkValues;
this.refreshArgs.Addon = addon;
this.refreshArgs.AtkValueCount = valueCount;
this.refreshArgs.AtkValues = (nint)values;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreRefresh, this.refreshArgs);
valueCount = this.refreshArgs.AtkValueCount;
values = (AtkValue*)this.refreshArgs.AtkValues;
try
{
@ -230,7 +235,7 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonRefresh. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostRefresh, this.addonRefreshArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostRefresh, this.refreshArgs);
return result;
}
@ -238,12 +243,13 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonRequestedUpdateArg.Addon = addon;
this.addonRequestedUpdateArg.NumberArrayData = (nint)numberArrayData;
this.addonRequestedUpdateArg.StringArrayData = (nint)stringArrayData;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreRequestedUpdate, this.addonRequestedUpdateArg);
numberArrayData = (NumberArrayData**)this.addonRequestedUpdateArg.NumberArrayData;
stringArrayData = (StringArrayData**)this.addonRequestedUpdateArg.StringArrayData;
this.requestedUpdateArgs.Addon = addon;
this.requestedUpdateArgs.NumberArrayData = (nint)numberArrayData;
this.requestedUpdateArgs.StringArrayData = (nint)stringArrayData;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreRequestedUpdate, this.requestedUpdateArgs);
numberArrayData = (NumberArrayData**)this.requestedUpdateArgs.NumberArrayData;
stringArrayData = (StringArrayData**)this.requestedUpdateArgs.StringArrayData;
try
{
@ -254,23 +260,24 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonRequestedUpdate. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostRequestedUpdate, this.addonRequestedUpdateArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostRequestedUpdate, this.requestedUpdateArgs);
}
private void OnAddonReceiveEvent(AtkUnitBase* addon, AtkEventType eventType, int eventParam, AtkEvent* atkEvent, AtkEventData* atkEventData)
{
this.LogEvent(EnableLogging);
this.addonReceiveEventArg.Addon = (nint)addon;
this.addonReceiveEventArg.AtkEventType = (byte)eventType;
this.addonReceiveEventArg.EventParam = eventParam;
this.addonReceiveEventArg.AtkEvent = (IntPtr)atkEvent;
this.addonReceiveEventArg.Data = (nint)atkEventData;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreReceiveEvent, this.addonReceiveEventArg);
eventType = (AtkEventType)this.addonReceiveEventArg.AtkEventType;
eventParam = this.addonReceiveEventArg.EventParam;
atkEvent = (AtkEvent*)this.addonReceiveEventArg.AtkEvent;
atkEventData = (AtkEventData*)this.addonReceiveEventArg.Data;
this.receiveEventArgs.Addon = (nint)addon;
this.receiveEventArgs.AtkEventType = (byte)eventType;
this.receiveEventArgs.EventParam = eventParam;
this.receiveEventArgs.AtkEvent = (IntPtr)atkEvent;
this.receiveEventArgs.AtkEventData = (nint)atkEventData;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreReceiveEvent, this.receiveEventArgs);
eventType = (AtkEventType)this.receiveEventArgs.AtkEventType;
eventParam = this.receiveEventArgs.EventParam;
atkEvent = (AtkEvent*)this.receiveEventArgs.AtkEvent;
atkEventData = (AtkEventData*)this.receiveEventArgs.AtkEventData;
try
{
@ -281,7 +288,7 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonReceiveEvent. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostReceiveEvent, this.addonReceiveEventArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostReceiveEvent, this.receiveEventArgs);
}
private bool OnAddonOpen(AtkUnitBase* thisPtr, uint depthLayer)
@ -290,8 +297,8 @@ internal unsafe class AddonVirtualTable : IDisposable
var result = false;
this.addonGenericArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreOpen, this.addonGenericArg);
this.openArgs.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreOpen, this.openArgs);
try
{
@ -302,7 +309,7 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonOpen. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostOpen, this.addonGenericArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostOpen, this.openArgs);
return result;
}
@ -313,8 +320,8 @@ internal unsafe class AddonVirtualTable : IDisposable
var result = false;
this.addonGenericArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreClose, this.addonGenericArg);
this.closeArgs.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreClose, this.closeArgs);
try
{
@ -325,7 +332,7 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonClose. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostClose, this.addonGenericArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostClose, this.closeArgs);
return result;
}
@ -334,8 +341,8 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonGenericArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreShow, this.addonGenericArg);
this.showArgs.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreShow, this.showArgs);
try
{
@ -346,15 +353,15 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonShow. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostShow, this.addonGenericArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostShow, this.showArgs);
}
private void OnAddonHide(AtkUnitBase* thisPtr, bool unkBool, bool callHideCallback, uint setShowHideFlags)
{
this.LogEvent(EnableLogging);
this.addonGenericArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreHide, this.addonGenericArg);
this.hideArgs.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreHide, this.hideArgs);
try
{
@ -365,7 +372,7 @@ internal unsafe class AddonVirtualTable : IDisposable
Log.Error(e, "Caught exception when calling original AddonHide. This may be a bug in the game or another plugin hooking this method.");
}
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostHide, this.addonGenericArg);
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostHide, this.hideArgs);
}
[Conditional("DEBUG")]

View file

@ -5,9 +5,8 @@ using System.Threading.Tasks;
using Dalamud.Bindings.ImGui;
using Dalamud.Game;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.ClientState;
using Dalamud.Hooking;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Serilog;
using Windows.Win32.Foundation;
using Windows.Win32.UI.WindowsAndMessaging;
@ -17,7 +16,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
/// <summary>
/// Widget for displaying hook information.
/// </summary>
internal unsafe class HookWidget : IDataWindowWidget
internal class HookWidget : IDataWindowWidget
{
private readonly List<IDalamudHook> hookStressTestList = [];
@ -32,9 +31,9 @@ internal unsafe class HookWidget : IDataWindowWidget
private bool hookStressTestRunning = false;
private MessageBoxWDelegate? messageBoxWOriginal;
private AddonFinalizeDelegate? addonFinalizeOriginal;
private HandleZoneInitPacketDelegate? zoneInitOriginal;
private AddonLifecycleAddressResolver? address;
private ClientStateAddressResolver? address;
private delegate int MessageBoxWDelegate(
IntPtr hWnd,
@ -42,12 +41,12 @@ internal unsafe class HookWidget : IDataWindowWidget
[MarshalAs(UnmanagedType.LPWStr)] string caption,
MESSAGEBOX_STYLE type);
private delegate void AddonFinalizeDelegate(AtkUnitManager* unitManager, AtkUnitBase** atkUnitBase);
private delegate void HandleZoneInitPacketDelegate(nint a1, uint localPlayerEntityId, nint packet, byte type);
private enum StressTestHookTarget
{
MessageBoxW,
AddonFinalize,
ZoneInit,
Random,
}
@ -65,7 +64,7 @@ internal unsafe class HookWidget : IDataWindowWidget
{
this.Ready = true;
this.address = new AddonLifecycleAddressResolver();
this.address = new ClientStateAddressResolver();
this.address.Setup(Service<TargetSigScanner>.Get());
}
@ -179,7 +178,7 @@ internal unsafe class HookWidget : IDataWindowWidget
return target switch
{
StressTestHookTarget.MessageBoxW => "MessageBoxW (Hook)",
StressTestHookTarget.AddonFinalize => "AddonFinalize (Hook)",
StressTestHookTarget.ZoneInit => "ZoneInit (Hook)",
_ => target.ToString(),
};
}
@ -198,15 +197,10 @@ internal unsafe class HookWidget : IDataWindowWidget
return result;
}
private void OnAddonFinalize(AtkUnitManager* unitManager, AtkUnitBase** atkUnitBase)
private void OnZoneInit(IntPtr a1, uint localPlayerEntityId, IntPtr packet, byte type)
{
Log.Information("OnAddonFinalize");
this.addonFinalizeOriginal!(unitManager, atkUnitBase);
}
private void OnAddonUpdate(AtkUnitBase* thisPtr, float delta)
{
Log.Information("OnAddonUpdate");
Log.Information("OnZoneInit");
this.zoneInitOriginal!.Invoke(a1, localPlayerEntityId, packet, type);
}
private IDalamudHook HookMessageBoxW()
@ -222,11 +216,11 @@ internal unsafe class HookWidget : IDataWindowWidget
return hook;
}
private IDalamudHook HookAddonFinalize()
private IDalamudHook HookZoneInit()
{
var hook = Hook<AddonFinalizeDelegate>.FromAddress(this.address!.AddonFinalize, this.OnAddonFinalize);
var hook = Hook<HandleZoneInitPacketDelegate>.FromAddress(this.address!.HandleZoneInitPacket, this.OnZoneInit);
this.addonFinalizeOriginal = hook.Original;
this.zoneInitOriginal = hook.Original;
hook.Enable();
return hook;
}
@ -241,7 +235,7 @@ internal unsafe class HookWidget : IDataWindowWidget
return target switch
{
StressTestHookTarget.MessageBoxW => this.HookMessageBoxW(),
StressTestHookTarget.AddonFinalize => this.HookAddonFinalize(),
StressTestHookTarget.ZoneInit => this.HookZoneInit(),
_ => throw new ArgumentOutOfRangeException(nameof(target), target, null),
};
}

View file

@ -471,9 +471,9 @@ internal class TitleScreenMenuWindow : Window, IDisposable
private unsafe void OnVersionStringDraw(AddonEvent ev, AddonArgs args)
{
if (args is not AddonDrawArgs drawArgs) return;
if (ev is not (AddonEvent.PostDraw or AddonEvent.PreDraw)) return;
var addon = drawArgs.Addon.Struct;
var addon = args.Addon.Struct;
var textNode = addon->GetTextNodeById(3);
// look and feel init. should be harmless to set.

View file

@ -5,7 +5,7 @@
<TargetFramework>net10.0-windows</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64</Platforms>
<LangVersion>13.0</LangVersion>
<LangVersion>14.0</LangVersion>
<!-- Disable Intel CET. Causes crashes on unpatched Windows 10 systems. -->
<!-- https://github.com/dotnet/runtime/issues/108589 -->