From d00a9827d7ab02dbdcf80de879c705ba0bd1dd39 Mon Sep 17 00:00:00 2001 From: Raymond Date: Sun, 26 Sep 2021 17:23:27 -0400 Subject: [PATCH 1/4] StatusList.Length is misleading --- .../Game/ClientState/Statuses/StatusList.cs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/Dalamud/Game/ClientState/Statuses/StatusList.cs b/Dalamud/Game/ClientState/Statuses/StatusList.cs index dedca8ad7..ee4285dd3 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(); From c611a97ab5e5eecad6ff2b71615c774076af2f82 Mon Sep 17 00:00:00 2001 From: Raymond Date: Sun, 26 Sep 2021 17:32:25 -0400 Subject: [PATCH 2/4] feat: CreateStatusListReference, move CreateStatusReference to static --- .../Game/ClientState/Statuses/StatusList.cs | 59 +++++++++++++------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/Dalamud/Game/ClientState/Statuses/StatusList.cs b/Dalamud/Game/ClientState/Statuses/StatusList.cs index ee4285dd3..591988e35 100644 --- a/Dalamud/Game/ClientState/Statuses/StatusList.cs +++ b/Dalamud/Game/ClientState/Statuses/StatusList.cs @@ -57,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. /// @@ -73,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); - } } /// From f01cfd5820a574e50728739a14c968a64771ce11 Mon Sep 17 00:00:00 2001 From: Raymond Date: Sun, 26 Sep 2021 19:02:56 -0400 Subject: [PATCH 3/4] feat: expose Fate table address --- Dalamud/Game/ClientState/Fates/FateTable.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dalamud/Game/ClientState/Fates/FateTable.cs b/Dalamud/Game/ClientState/Fates/FateTable.cs index 5f0de45e5..dbfbd427d 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. /// From 1c6ff893721e08ad612172637ed5fa67abf56a11 Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 27 Sep 2021 07:54:54 -0400 Subject: [PATCH 4/4] Expose createFateReference --- Dalamud/Game/ClientState/Fates/FateTable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Game/ClientState/Fates/FateTable.cs b/Dalamud/Game/ClientState/Fates/FateTable.cs index dbfbd427d..ff0361db9 100644 --- a/Dalamud/Game/ClientState/Fates/FateTable.cs +++ b/Dalamud/Game/ClientState/Fates/FateTable.cs @@ -111,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();