From 479049b78db07e1be2106582c7124ba23797a023 Mon Sep 17 00:00:00 2001 From: aers Date: Mon, 3 Jun 2024 12:49:44 -0700 Subject: [PATCH] [apiX] dalamud fixes for CS updates (#1821) * update CS & fix compilation issues * update CS to latest commit * update CS & change battlechara * more CS updates and compilation fixes * one last cs update --- Dalamud/Game/Addon/Events/AddonEventManager.cs | 4 ++-- Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs | 2 +- Dalamud/Game/ClientState/Buddy/BuddyMember.cs | 2 +- .../Game/ClientState/Objects/SubKinds/PlayerCharacter.cs | 6 +++--- Dalamud/Game/ClientState/Objects/Types/BattleChara.cs | 2 +- Dalamud/Game/ClientState/Objects/Types/Character.cs | 2 +- Dalamud/Game/ClientState/Party/PartyMember.cs | 7 ++++--- Dalamud/Game/Gui/ContextMenu/ContextMenu.cs | 4 ++-- Dalamud/Game/Gui/Dtr/DtrBar.cs | 4 ++-- Dalamud/Game/Gui/GameGui.cs | 4 ++-- Dalamud/Game/Inventory/GameInventoryItem.cs | 8 ++------ Dalamud/Interface/Internal/UiDebug.cs | 2 +- .../Windows/Data/Widgets/AtkArrayDataBrowserWidget.cs | 2 +- lib/FFXIVClientStructs | 2 +- 14 files changed, 24 insertions(+), 27 deletions(-) diff --git a/Dalamud/Game/Addon/Events/AddonEventManager.cs b/Dalamud/Game/Addon/Events/AddonEventManager.cs index 8af02ba70..dda05a6bc 100644 --- a/Dalamud/Game/Addon/Events/AddonEventManager.cs +++ b/Dalamud/Game/Addon/Events/AddonEventManager.cs @@ -173,14 +173,14 @@ internal unsafe class AddonEventManager : IInternalDisposableService { try { - var atkStage = AtkStage.GetSingleton(); + var atkStage = AtkStage.Instance(); if (this.cursorOverride is not null && atkStage is not null) { var cursor = (AddonCursorType)atkStage->AtkCursor.Type; if (cursor != this.cursorOverride) { - AtkStage.GetSingleton()->AtkCursor.SetCursorType((AtkCursor.CursorType)this.cursorOverride, 1); + AtkStage.Instance()->AtkCursor.SetCursorType((AtkCursor.CursorType)this.cursorOverride, 1); } return nint.Zero; diff --git a/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs b/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs index 169851519..7270fb437 100644 --- a/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs +++ b/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs @@ -371,7 +371,7 @@ internal unsafe class AddonLifecycle : IInternalDisposableService try { - addon->OnUpdate(numberArrayData, stringArrayData); + addon->OnRequestedUpdate(numberArrayData, stringArrayData); } catch (Exception e) { diff --git a/Dalamud/Game/ClientState/Buddy/BuddyMember.cs b/Dalamud/Game/ClientState/Buddy/BuddyMember.cs index 571a0ecd9..3b5c2f910 100644 --- a/Dalamud/Game/ClientState/Buddy/BuddyMember.cs +++ b/Dalamud/Game/ClientState/Buddy/BuddyMember.cs @@ -29,7 +29,7 @@ public unsafe class BuddyMember /// /// Gets the object ID of this buddy. /// - public uint ObjectId => this.Struct->ObjectId; + public uint ObjectId => this.Struct->EntityId; /// /// Gets the actor associated with this buddy. diff --git a/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs b/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs index 5c1061e7d..34ab1e19e 100644 --- a/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs +++ b/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs @@ -21,15 +21,15 @@ public unsafe class PlayerCharacter : BattleChara /// /// Gets the current world of the character. /// - public ExcelResolver CurrentWorld => new(this.Struct->Character.CurrentWorld); + public ExcelResolver CurrentWorld => new(this.Struct->CurrentWorld); /// /// Gets the home world of the character. /// - public ExcelResolver HomeWorld => new(this.Struct->Character.HomeWorld); + public ExcelResolver HomeWorld => new(this.Struct->HomeWorld); /// /// Gets the target actor ID of the PlayerCharacter. /// - public override ulong TargetObjectId => this.Struct->Character.Gaze.Controller.Gazes[0].TargetInfo.TargetId; + public override ulong TargetObjectId => this.Struct->LookAt.Controller.Params[0].TargetParam.TargetId; } diff --git a/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs b/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs index 49863b0f9..e7adbbfd2 100644 --- a/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs +++ b/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs @@ -46,7 +46,7 @@ public unsafe class BattleChara : Character /// /// Gets the object ID of the target currently being cast at by the chara. /// - public uint CastTargetObjectId => this.Struct->GetCastInfo()->CastTargetId; + public ulong CastTargetObjectId => this.Struct->GetCastInfo()->CastTargetId; /// /// Gets the current casting time of the spell being cast by the chara. diff --git a/Dalamud/Game/ClientState/Objects/Types/Character.cs b/Dalamud/Game/ClientState/Objects/Types/Character.cs index ea90aac5f..5de803d15 100644 --- a/Dalamud/Game/ClientState/Objects/Types/Character.cs +++ b/Dalamud/Game/ClientState/Objects/Types/Character.cs @@ -82,7 +82,7 @@ public unsafe class Character : GameObject /// Gets a byte array describing the visual appearance of this Chara. /// Indexed by . /// - public byte[] Customize => MemoryHelper.Read((IntPtr)this.Struct->DrawData.CustomizeData.Data, 28); + public byte[] Customize => this.Struct->DrawData.CustomizeData.Data.ToArray(); /// /// Gets the Free Company tag of this chara. diff --git a/Dalamud/Game/ClientState/Party/PartyMember.cs b/Dalamud/Game/ClientState/Party/PartyMember.cs index fac8d55b3..77539820a 100644 --- a/Dalamud/Game/ClientState/Party/PartyMember.cs +++ b/Dalamud/Game/ClientState/Party/PartyMember.cs @@ -1,4 +1,5 @@ using System.Numerics; +using System.Runtime.CompilerServices; using Dalamud.Game.ClientState.Objects; using Dalamud.Game.ClientState.Objects.Types; @@ -41,12 +42,12 @@ public unsafe class PartyMember /// /// Gets the content ID of the party member. /// - public long ContentId => this.Struct->ContentId; + public long ContentId => (long)this.Struct->ContentId; /// /// Gets the actor ID of this party member. /// - public uint ObjectId => this.Struct->ObjectId; + public uint ObjectId => this.Struct->EntityId; /// /// Gets the actor associated with this buddy. @@ -89,7 +90,7 @@ public unsafe class PartyMember /// /// Gets the displayname of this party member. /// - public SeString Name => MemoryHelper.ReadSeString((IntPtr)Struct->Name, 0x40); + public SeString Name => MemoryHelper.ReadSeString((nint)Unsafe.AsPointer(ref Struct->Name[0]), 0x40); /// /// Gets the sex of this party member. diff --git a/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs b/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs index 17578bdfe..1d8d3104f 100644 --- a/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs +++ b/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs @@ -317,8 +317,8 @@ internal sealed unsafe class ContextMenu : IInternalDisposableService, IContextM this.SelectedMenuType = ContextMenuType.Default; var menu = AgentContext.Instance()->CurrentContextMenu; - var handlers = new Span>(menu->EventHandlerArray, 32); - var ids = new Span(menu->EventIdArray, 32); + var handlers = menu->EventHandlers; + var ids = menu->EventIds; var count = (int)values[0].UInt; handlers = handlers.Slice(7, count); ids = ids.Slice(7, count); diff --git a/Dalamud/Game/Gui/Dtr/DtrBar.cs b/Dalamud/Game/Gui/Dtr/DtrBar.cs index 0c116f8e1..adf18adfd 100644 --- a/Dalamud/Game/Gui/Dtr/DtrBar.cs +++ b/Dalamud/Game/Gui/Dtr/DtrBar.cs @@ -459,11 +459,11 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar switch (atkEventType) { case AddonEventType.MouseOver: - AtkStage.GetSingleton()->TooltipManager.ShowTooltip(addon->Id, node, dtrBarEntry.Tooltip.Encode()); + AtkStage.Instance()->TooltipManager.ShowTooltip(addon->Id, node, dtrBarEntry.Tooltip.Encode()); break; case AddonEventType.MouseOut: - AtkStage.GetSingleton()->TooltipManager.HideTooltip(addon->Id); + AtkStage.Instance()->TooltipManager.HideTooltip(addon->Id); break; } } diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs index 32d1d7606..88c8433a2 100644 --- a/Dalamud/Game/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -273,7 +273,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui if (framework == null) return IntPtr.Zero; - var uiModule = framework->GetUiModule(); + var uiModule = framework->GetUIModule(); if (uiModule == null) return IntPtr.Zero; @@ -283,7 +283,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui /// public IntPtr GetAddonByName(string name, int index = 1) { - var atkStage = AtkStage.GetSingleton(); + var atkStage = AtkStage.Instance(); if (atkStage == null) return IntPtr.Zero; diff --git a/Dalamud/Game/Inventory/GameInventoryItem.cs b/Dalamud/Game/Inventory/GameInventoryItem.cs index 31ace0e0b..0ead24450 100644 --- a/Dalamud/Game/Inventory/GameInventoryItem.cs +++ b/Dalamud/Game/Inventory/GameInventoryItem.cs @@ -1,10 +1,7 @@ using System.Diagnostics; -using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Dalamud.Utility; - using FFXIVClientStructs.FFXIV.Client.Game; namespace Dalamud.Game.Inventory; @@ -101,13 +98,12 @@ public unsafe struct GameInventoryItem : IEquatable /// /// Gets the array of materia types. /// - public ReadOnlySpan Materia => new(Unsafe.AsPointer(ref Unsafe.AsRef(in this.InternalItem.Materia[0])), 5); + public ReadOnlySpan Materia => new(Unsafe.AsPointer(ref this.InternalItem.Materia[0]), 5); /// /// Gets the array of materia grades. /// - public ReadOnlySpan MateriaGrade => - new(Unsafe.AsPointer(ref Unsafe.AsRef(in this.InternalItem.MateriaGrade[0])), 5); + public ReadOnlySpan MateriaGrade => new(Unsafe.AsPointer(ref this.InternalItem.MateriaGrades[0]), 5); /// /// Gets the address of native inventory item in the game.
diff --git a/Dalamud/Interface/Internal/UiDebug.cs b/Dalamud/Interface/Internal/UiDebug.cs index 562693de0..6409021de 100644 --- a/Dalamud/Interface/Internal/UiDebug.cs +++ b/Dalamud/Interface/Internal/UiDebug.cs @@ -439,7 +439,7 @@ internal unsafe class UiDebug { var foundSelected = false; var noResults = true; - var stage = AtkStage.GetSingleton(); + var stage = AtkStage.Instance(); var unitManagers = &stage->RaptureAtkUnitManager->AtkUnitManager.DepthLayerOneList; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/AtkArrayDataBrowserWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/AtkArrayDataBrowserWidget.cs index 4da2011a6..ee79764de 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/AtkArrayDataBrowserWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/AtkArrayDataBrowserWidget.cs @@ -30,7 +30,7 @@ internal unsafe class AtkArrayDataBrowserWidget : IDataWindowWidget { var fontWidth = ImGui.CalcTextSize("A").X; var fontHeight = ImGui.GetTextLineHeightWithSpacing(); - var uiModule = FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance()->GetUiModule(); + var uiModule = FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance()->GetUIModule(); if (uiModule == null) { diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 7e59f75b2..d0cbe19f1 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 7e59f75b210593c4a1bdba8a296a08c3c40d05af +Subproject commit d0cbe19f145bcae573a1eb2313f1f8240f869cd7