Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1284 from Taurenkey/API9
Browse files Browse the repository at this point in the history
API9 Fixes
  • Loading branch information
Taurenkey authored Oct 3, 2023
2 parents f69c839 + 35def18 commit 46ced87
Show file tree
Hide file tree
Showing 24 changed files with 97 additions and 62 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
[submodule "lib/FFXIVClientStructs"]
path = lib/FFXIVClientStructs
url = https://github.com/aers/FFXIVClientStructs.git
[submodule "ECommons"]
path = ECommons
url = https://github.com/NightmareXIV/ECommons.git
1 change: 1 addition & 0 deletions ECommons
Submodule ECommons added at 1ad0de
12 changes: 10 additions & 2 deletions XIVSlothCombo.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32228.343
# Visual Studio Version 17
VisualStudioVersion = 17.8.34112.27
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XIVSlothCombo", "XIVSlothCombo\XIVSlothCombo.csproj", "{619DF476-7225-4783-95A5-D29A8816EE66}"
EndProject
Expand All @@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github Actions", "Github Ac
.github\workflows\build.yml = .github\workflows\build.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ECommons", "ECommons\ECommons\ECommons.csproj", "{3E8E720E-9990-4202-9035-12F54C78CF47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All @@ -30,6 +32,12 @@ Global
{619DF476-7225-4783-95A5-D29A8816EE66}.GitBuild|x64.Build.0 = GitBuild|x64
{619DF476-7225-4783-95A5-D29A8816EE66}.Release|x64.ActiveCfg = Release|x64
{619DF476-7225-4783-95A5-D29A8816EE66}.Release|x64.Build.0 = Release|x64
{3E8E720E-9990-4202-9035-12F54C78CF47}.Debug|x64.ActiveCfg = Debug|x64
{3E8E720E-9990-4202-9035-12F54C78CF47}.Debug|x64.Build.0 = Debug|x64
{3E8E720E-9990-4202-9035-12F54C78CF47}.GitBuild|x64.ActiveCfg = Debug|x64
{3E8E720E-9990-4202-9035-12F54C78CF47}.GitBuild|x64.Build.0 = Debug|x64
{3E8E720E-9990-4202-9035-12F54C78CF47}.Release|x64.ActiveCfg = Release|x64
{3E8E720E-9990-4202-9035-12F54C78CF47}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 2 additions & 1 deletion XIVSlothCombo/Combos/JobHelpers/AST.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Dalamud.Game;
using Dalamud.Game.ClientState.JobGauge.Enums;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Plugin.Services;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -20,7 +21,7 @@ internal static void Init()
Service.Framework.Update += CheckCards;
}

private static void CheckCards(Framework framework)
private static void CheckCards(IFramework framework)
{
if (Service.ClientState.LocalPlayer is null || Service.ClientState.LocalPlayer.ClassJob.Id != 33)
return;
Expand Down
3 changes: 1 addition & 2 deletions XIVSlothCombo/Combos/PvE/BLU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ protected override uint Invoke(uint actionID, uint lastComboActionID, float comb
internal class BLU_NewMoonFluteOpener : CustomCombo
{
protected internal override CustomComboPreset Preset { get; } = CustomComboPreset.BLU_NewMoonFluteOpener;
private static bool surpanakhaReady = false;


protected override uint Invoke(uint actionID, uint lastComboActionID, float comboTime, byte level)
{
if (actionID is MoonFlute)
Expand Down
7 changes: 4 additions & 3 deletions XIVSlothCombo/Core/IconReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reflection;
using Dalamud.Hooking;
using Dalamud.Logging;
using FFXIVClientStructs.FFXIV.Client.Game;
using XIVSlothCombo.CustomComboNS;
using XIVSlothCombo.Services;

Expand All @@ -29,8 +30,8 @@ public IconReplacer()
.OrderByDescending(x => x.Preset)
.ToList();

getIconHook = Hook<GetIconDelegate>.FromAddress(Service.Address.GetAdjustedActionId, GetIconDetour);
isIconReplaceableHook = Hook<IsIconReplaceableDelegate>.FromAddress(Service.Address.IsActionIdReplaceable, IsIconReplaceableDetour);
getIconHook = Service.GameInteropProvider.HookFromAddress<GetIconDelegate>((nint)ActionManager.Addresses.GetAdjustedActionId.Value, GetIconDetour);
isIconReplaceableHook = Service.GameInteropProvider.HookFromAddress<IsIconReplaceableDelegate>(Service.Address.IsActionIdReplaceable, IsIconReplaceableDetour);

getIconHook.Enable();
isIconReplaceableHook.Enable();
Expand Down Expand Up @@ -80,7 +81,7 @@ private unsafe uint GetIconDetour(IntPtr actionManager, uint actionID)

catch (Exception ex)
{
PluginLog.Error(ex, "Preset error");
Service.PluginLog.Error(ex, "Preset error");
return OriginalHook(actionID);
}
}
Expand Down
19 changes: 7 additions & 12 deletions XIVSlothCombo/Core/PluginAddressResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,33 @@
using Dalamud.Game;
using Dalamud.Logging;
using FFXIVClientStructs.FFXIV.Client.Game;
using XIVSlothCombo.Services;

namespace XIVSlothCombo.Core
{
/// <summary> Plugin address resolver. </summary>
internal class PluginAddressResolver : BaseAddressResolver
internal class PluginAddressResolver
{
/// <summary> Gets the address of the member ComboTimer. </summary>
public IntPtr ComboTimer { get; private set; }

/// <summary> Gets the address of the member LastComboMove. </summary>
public IntPtr LastComboMove => ComboTimer + 0x4;

/// <summary> Gets the address of fpGetAdjustedActionId. </summary>
public IntPtr GetAdjustedActionId { get; private set; }

/// <summary> Gets the address of fpIsIconReplacable. </summary>
public IntPtr IsActionIdReplaceable { get; private set; }

/// <inheritdoc/>
protected unsafe override void Setup64Bit(SigScanner scanner)
public unsafe void Setup(ISigScanner scanner)
{
ComboTimer = new IntPtr(&ActionManager.Instance()->Combo.Timer);

GetAdjustedActionId = scanner.ScanText("E8 ?? ?? ?? ?? 89 03 8B 03"); // Client::Game::ActionManager.GetAdjustedActionId

IsActionIdReplaceable = scanner.ScanText("E8 ?? ?? ?? ?? 84 C0 74 4C 8B D3");

PluginLog.Verbose("===== X I V S L O T H C O M B O =====");
PluginLog.Verbose($"{nameof(GetAdjustedActionId)} 0x{GetAdjustedActionId:X}");
PluginLog.Verbose($"{nameof(IsActionIdReplaceable)} 0x{IsActionIdReplaceable:X}");
PluginLog.Verbose($"{nameof(ComboTimer)} 0x{ComboTimer:X}");
PluginLog.Verbose($"{nameof(LastComboMove)} 0x{LastComboMove:X}");
Service.PluginLog.Verbose("===== X I V S L O T H C O M B O =====");
Service.PluginLog.Verbose($"{nameof(IsActionIdReplaceable)} 0x{IsActionIdReplaceable:X}");
Service.PluginLog.Verbose($"{nameof(ComboTimer)} 0x{ComboTimer:X}");
Service.PluginLog.Verbose($"{nameof(LastComboMove)} 0x{LastComboMove:X}");
}
}
}
4 changes: 2 additions & 2 deletions XIVSlothCombo/Core/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private void SetResetValues(string config, bool value)

public void ResetFeatures(string config, int[] values)
{
Dalamud.Logging.PluginLog.Debug($"{config} {GetResetValues(config)}");
Service.PluginLog.Debug($"{config} {GetResetValues(config)}");
if (!GetResetValues(config))
{
bool needToResetMessagePrinted = false;
Expand All @@ -274,7 +274,7 @@ public void ResetFeatures(string config, int[] values)

foreach (int value in values)
{
Dalamud.Logging.PluginLog.Debug(value.ToString());
Service.PluginLog.Debug(value.ToString());
if (presets.Contains(value))
{
var preset = Enum.GetValues<CustomComboPreset>()
Expand Down
2 changes: 1 addition & 1 deletion XIVSlothCombo/CustomCombo/Functions/Cooldown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ internal abstract partial class CustomComboFunctions
/// <summary> Get if an action is enabled.</summary>
/// <param name="actionID"> Action ID to check</param>
/// <returns> If the action is currently enabled.</returns>
public unsafe static bool IsEnabled(uint actionID) => ActionManager.Instance()->GetActionStatus(ActionType.Spell, actionID) == 0;
public unsafe static bool IsEnabled(uint actionID) => ActionManager.Instance()->GetActionStatus(ActionType.Action, actionID) == 0;
}
}
3 changes: 2 additions & 1 deletion XIVSlothCombo/CustomCombo/Functions/Party.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.ClientState.Party;
using Dalamud.Plugin.Services;
using XIVSlothCombo.Services;

namespace XIVSlothCombo.CustomComboNS.Functions
Expand All @@ -12,7 +13,7 @@ internal abstract partial class CustomComboFunctions

/// <summary> Gets the party list </summary>
/// <returns> Current party list. </returns>
public static PartyList GetPartyMembers() => Service.PartyList;
public static IPartyList GetPartyMembers() => Service.PartyList;

public unsafe static GameObject? GetPartySlot(int slot)
{
Expand Down
4 changes: 2 additions & 2 deletions XIVSlothCombo/CustomCombo/Functions/PlayerCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ internal abstract partial class CustomComboFunctions

/// <summary> Find if the player has a pet present. </summary>
/// <returns> A value indicating whether the player has a pet (fairy/carbuncle) present. </returns>
public static bool HasPetPresent() => Service.BuddyList.PetBuddyPresent;
public static bool HasPetPresent() => Service.BuddyList.PetBuddy != null;

/// <summary> Find if the player has a companion (chocobo) present. </summary>
/// <returns> A value indicating whether the player has a companion (chocobo). </returns>
public static bool HasCompanionPresent() => Service.BuddyList.CompanionBuddyPresent;
public static bool HasCompanionPresent() => Service.BuddyList.CompanionBuddy != null;

/// <summary> Checks if the player is in a PVP enabled zone. </summary>
/// <returns> A value indicating whether the player is in a PVP enabled zone. </returns>
Expand Down
2 changes: 1 addition & 1 deletion XIVSlothCombo/CustomCombo/Functions/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static bool HasFriendlyTarget(GameObject? OurTarget = null)
public static unsafe GameObject? GetHealTarget(bool checkMOPartyUI = false, bool restrictToMouseover = false)
{
GameObject? healTarget = null;
TargetManager tm = Service.TargetManager;
ITargetManager tm = Service.TargetManager;

if (HasFriendlyTarget(tm.SoftTarget)) healTarget = tm.SoftTarget;
if (healTarget is null && HasFriendlyTarget(CurrentTarget) && !restrictToMouseover) healTarget = CurrentTarget;
Expand Down
6 changes: 3 additions & 3 deletions XIVSlothCombo/Data/ActionWatching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private unsafe static void SendActionDetour(long targetObjectId, byte actionType
}
catch (Exception ex)
{
Dalamud.Logging.PluginLog.Error(ex, "SendActionDetour");
Service.PluginLog.Error(ex, "SendActionDetour");
SendActionHook!.Original(targetObjectId, actionType, actionId, sequence, a5, a6, a7, a8, a9);
}
}
Expand Down Expand Up @@ -204,8 +204,8 @@ public static void Dispose()

static unsafe ActionWatching()
{
ReceiveActionEffectHook ??= Hook<ReceiveActionEffectDelegate>.FromAddress(Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B 8D F0 03 00 00"), ReceiveActionEffectDetour);
SendActionHook ??= Hook<SendActionDelegate>.FromAddress(Service.SigScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? F3 0F 10 3D ?? ?? ?? ?? 48 8D 4D BF"), SendActionDetour);
ReceiveActionEffectHook ??= Service.GameInteropProvider.HookFromSignature<ReceiveActionEffectDelegate>("E8 ?? ?? ?? ?? 48 8B 8D F0 03 00 00", ReceiveActionEffectDetour);
SendActionHook ??= Service.GameInteropProvider.HookFromSignature<SendActionDelegate>("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? F3 0F 10 3D ?? ?? ?? ?? 48 8D 4D BF", SendActionDetour);
}


Expand Down
5 changes: 3 additions & 2 deletions XIVSlothCombo/Data/CustomComboCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using DalamudStatus = Dalamud.Game.ClientState.Statuses; // conflicts with structs if not defined
using FFXIVClientStructs.FFXIV.Client.Game;
using XIVSlothCombo.Services;
using Dalamud.Plugin.Services;

namespace XIVSlothCombo.Data
{
Expand Down Expand Up @@ -129,7 +130,7 @@ internal static unsafe int GetResourceCost(uint actionID)
if (actionManager == null)
return 0;

int cost = ActionManager.GetActionCost(ActionType.Spell, actionID, 0, 0, 0, 0);
int cost = ActionManager.GetActionCost(ActionType.Action, actionID, 0, 0, 0, 0);

return cost;
}
Expand All @@ -148,7 +149,7 @@ private byte GetCooldownGroup(uint actionID)
}

/// <summary> Triggers when the game framework updates. Clears cooldown and status caches. </summary>
private unsafe void Framework_Update(Framework framework)
private unsafe void Framework_Update(IFramework framework)
{
statusCache.Clear();
cooldownCache.Clear();
Expand Down
33 changes: 20 additions & 13 deletions XIVSlothCombo/Services/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using XIVSlothCombo.Core;
using XIVSlothCombo.Data;

Expand All @@ -26,44 +27,44 @@ internal class Service

/// <summary> Gets the Dalamud buddy list. </summary>
[PluginService]
internal static BuddyList BuddyList { get; private set; } = null!;
internal static IBuddyList BuddyList { get; private set; } = null!;

/// <summary> Gets the Dalamud chat gui. </summary>
[PluginService]
internal static ChatGui ChatGui { get; private set; } = null!;
internal static IChatGui ChatGui { get; private set; } = null!;

/// <summary> Facilitates class-based locking. </summary>
internal static bool ClassLocked { get; set; } = true;

/// <summary> Gets the Dalamud client state. </summary>
[PluginService]
internal static ClientState ClientState { get; private set; } = null!;
internal static IClientState ClientState { get; private set; } = null!;

/// <summary> Gets or sets the plugin caching mechanism. </summary>
internal static CustomComboCache ComboCache { get; set; } = null!;

/// <summary> Gets the Dalamud command manager. </summary>
[PluginService]
internal static CommandManager CommandManager { get; private set; } = null!;
internal static ICommandManager CommandManager { get; private set; } = null!;

/// <summary> Gets the Dalamud condition. </summary>
[PluginService]
internal static Condition Condition { get; private set; } = null!;
internal static ICondition Condition { get; private set; } = null!;

/// <summary> Gets or sets the plugin configuration. </summary>
internal static PluginConfiguration Configuration { get; set; } = null!;

/// <summary> Gets the Dalamud data manager. </summary>
[PluginService]
internal static DataManager DataManager { get; private set; } = null!;
internal static IDataManager DataManager { get; private set; } = null!;

/// <summary> Gets the Dalamud framework manager. </summary>
[PluginService]
internal static Framework Framework { get; private set; } = null!;
internal static IFramework Framework { get; private set; } = null!;

/// <summary> Handles the in-game UI. </summary>
[PluginService]
internal static GameGui GameGui { get; private set; } = null!;
internal static IGameGui GameGui { get; private set; } = null!;

/// <summary> Gets or sets the plugin icon replacer. </summary>
internal static IconReplacer IconReplacer { get; set; } = null!;
Expand All @@ -74,11 +75,11 @@ internal class Service

/// <summary> Gets the Dalamud job gauges. </summary>
[PluginService]
internal static JobGauges JobGauges { get; private set; } = null!;
internal static IJobGauges JobGauges { get; private set; } = null!;

/// <summary> Gets the Dalamud object table. </summary>
[PluginService]
internal static ObjectTable ObjectTable { get; private set; } = null!;
internal static IObjectTable ObjectTable { get; private set; } = null!;

/// <summary> Returns the Plugin Folder location </summary>
public static string PluginFolder
Expand All @@ -94,14 +95,20 @@ public static string PluginFolder

/// <summary> Gets the Dalamud party list. </summary>
[PluginService]
internal static PartyList PartyList { get; private set; } = null!;
internal static IPartyList PartyList { get; private set; } = null!;

/// <summary> Facilitates searching for memory signatures. </summary>
[PluginService]
internal static SigScanner SigScanner { get; private set; } = null!;
internal static ISigScanner SigScanner { get; private set; } = null!;

/// <summary> Gets the Dalamud target manager. </summary>
[PluginService]
internal static TargetManager TargetManager { get; private set; } = null!;
internal static ITargetManager TargetManager { get; private set; } = null!;

[PluginService]
internal static IGameInteropProvider GameInteropProvider { get; private set; } = null!;

[PluginService]
internal static IPluginLog PluginLog { get; private set; } = null!;
}
}
3 changes: 2 additions & 1 deletion XIVSlothCombo/Window/ConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Numerics;
using System.Runtime.InteropServices;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Dalamud.Plugin;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.UI;
Expand Down Expand Up @@ -124,7 +125,7 @@ public void DrawConfig()

if (ImGui.BeginTabItem("About XIVSlothCombo / Report an Issue"))
{
AboutUs.Draw(Plugin);
AboutUs.Draw();
ImGui.EndTabItem();
}

Expand Down
3 changes: 2 additions & 1 deletion XIVSlothCombo/Window/IconTextButton.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Interface;
using Dalamud.Interface.Internal;
using ECommons.ImGuiMethods;
using ImGuiNET;
using ImGuiScene;
Expand All @@ -16,7 +17,7 @@ private static Vector2 GetIconSize(FontAwesomeIcon icon)
return iconSize;
}

public static bool IconImageButton(TextureWrap texture, string text, Vector2 size = new(), bool imageOnRight = false, float imageScale = 0)
public static bool IconImageButton(IDalamudTextureWrap texture, string text, Vector2 size = new(), bool imageOnRight = false, float imageScale = 0)
{
var buttonClicked = false;

Expand Down
1 change: 1 addition & 0 deletions XIVSlothCombo/Window/InfoBox.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using ImGuiNET;

namespace XIVSlothCombo.Window
Expand Down
Loading

0 comments on commit 46ced87

Please sign in to comment.