diff --git a/Dalamud/Game/ClientState/Fates/FateTable.cs b/Dalamud/Game/ClientState/Fates/FateTable.cs index 5f0de45e5..ff0361db9 100644 --- a/Dalamud/Game/ClientState/Fates/FateTable.cs +++ b/Dalamud/Game/ClientState/Fates/FateTable.cs @@ -28,6 +28,11 @@ namespace Dalamud.Game.ClientState.Fates Log.Verbose($"Fate table address 0x{this.address.FateTablePtr.ToInt64():X}"); } + /// + /// Gets the address of the Fate table. + /// + public IntPtr Address => this.address.FateTablePtr; + /// /// Gets the amount of currently active Fates. /// @@ -106,7 +111,7 @@ namespace Dalamud.Game.ClientState.Fates /// /// The offset of the actor in memory. /// object containing requested data. - internal Fate? CreateFateReference(IntPtr offset) + public Fate? CreateFateReference(IntPtr offset) { var clientState = Service.Get(); diff --git a/Dalamud/Game/ClientState/Statuses/StatusList.cs b/Dalamud/Game/ClientState/Statuses/StatusList.cs index dedca8ad7..591988e35 100644 --- a/Dalamud/Game/ClientState/Statuses/StatusList.cs +++ b/Dalamud/Game/ClientState/Statuses/StatusList.cs @@ -36,23 +36,9 @@ namespace Dalamud.Game.ClientState.Statuses public IntPtr Address { get; } /// - /// Gets the amount of status effects the actor has. + /// Gets the amount of status effect slots the actor has. /// - public int Length - { - get - { - var i = 0; - for (; i < StatusListLength; i++) - { - var status = this[i]; - if (status == null || status.StatusId == 0) - break; - } - - return i; - } - } + public int Length => StatusListLength; private static int StatusSize { get; } = Marshal.SizeOf(); @@ -71,10 +57,49 @@ namespace Dalamud.Game.ClientState.Statuses return null; var addr = this.GetStatusAddress(index); - return this.CreateStatusReference(addr); + return CreateStatusReference(addr); } } + /// + /// Create a reference to an FFXIV actor status list. + /// + /// The address of the status list in memory. + /// The status object containing the requested data. + public static StatusList? CreateStatusListReference(IntPtr address) + { + // The use case for CreateStatusListReference and CreateStatusReference to be static is so + // fake status lists can be generated. Since they aren't exposed as services, it's either + // here or somewhere else. + var clientState = Service.Get(); + + if (clientState.LocalContentId == 0) + return null; + + if (address == IntPtr.Zero) + return null; + + return new StatusList(address); + } + + /// + /// Create a reference to an FFXIV actor status. + /// + /// The address of the status effect in memory. + /// The status object containing the requested data. + public static Status? CreateStatusReference(IntPtr address) + { + var clientState = Service.Get(); + + if (clientState.LocalContentId == 0) + return null; + + if (address == IntPtr.Zero) + return null; + + return new Status(address); + } + /// /// Gets the address of the party member at the specified index of the party list. /// @@ -87,24 +112,6 @@ namespace Dalamud.Game.ClientState.Statuses return (IntPtr)(this.Struct->Status + (index * StatusSize)); } - - /// - /// Create a reference to an FFXIV actor status. - /// - /// The address of the status effect in memory. - /// The status object containing the requested data. - public Status? CreateStatusReference(IntPtr address) - { - var clientState = Service.Get(); - - if (clientState.LocalContentId == 0) - return null; - - if (address == IntPtr.Zero) - return null; - - return new Status(address); - } } ///