Skip to content

Commit

Permalink
Performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Taurenkey committed Dec 29, 2024
1 parent 7411c98 commit 0c3a605
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
16 changes: 14 additions & 2 deletions WrathCombo/Core/IconReplacer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Dalamud.Hooking;
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using ECommons.GameHelpers;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using System;
Expand All @@ -8,6 +10,7 @@
using System.Reflection;
using WrathCombo.CustomComboNS;
using WrathCombo.CustomComboNS.Functions;
using WrathCombo.Extensions;
using WrathCombo.Services;

namespace WrathCombo.Core
Expand Down Expand Up @@ -55,9 +58,18 @@ public void Dispose()
/// <returns> The result from the hook. </returns>
internal uint OriginalHook(uint actionID) => getIconHook.Original(actionManager, actionID);

private static IEnumerable<CustomCombo>? _filteredCombos;

public void UpdateFilteredCombos()
{
_filteredCombos = CustomCombos.Where(x => x.Preset.Attributes().CustomComboInfo.JobID == 0 || x.Preset.Attributes().CustomComboInfo.JobID == Player.JobId || x.Preset.Attributes().CustomComboInfo.JobID == CustomComboFunctions.JobIDs.ClassToJob(Player.JobId));
}

private unsafe uint GetIconDetour(IntPtr actionManager, uint actionID)
{
this.actionManager = actionManager;
if (_filteredCombos is null)
UpdateFilteredCombos();

try
{
Expand All @@ -72,8 +84,8 @@ private unsafe uint GetIconDetour(IntPtr actionManager, uint actionID)
uint lastComboMove = ActionManager.Instance()->Combo.Action;
float comboTime = ActionManager.Instance()->Combo.Action != 0 ? ActionManager.Instance()->Combo.Timer : 0;
byte level = Svc.ClientState.LocalPlayer?.Level ?? 0;

foreach (CustomCombo? combo in CustomCombos)
foreach (CustomCombo? combo in _filteredCombos)
{
if (combo.TryInvoke(actionID, level, lastComboMove, comboTime, out uint newActionID))
{
Expand Down
19 changes: 11 additions & 8 deletions WrathCombo/WrathCombo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Security.Cryptography;
using System.Threading.Tasks;
using WrathCombo.Attributes;
using WrathCombo.AutoRotation;
Expand All @@ -31,10 +30,10 @@
using WrathCombo.Data;
using WrathCombo.Extensions;
using WrathCombo.Services;
using IPC = WrathCombo.Services.IPC;
using WrathCombo.Window;
using WrathCombo.Window.Functions;
using WrathCombo.Window.Tabs;
using IPC = WrathCombo.Services.IPC;
using Status = Dalamud.Game.ClientState.Statuses.Status;

namespace WrathCombo
Expand Down Expand Up @@ -94,10 +93,14 @@ public static uint? JobID
{
if (jobID != value && value != null)
{
AST.QuickTargetCards.SelectedRandomMember = null;
PvEFeatures.HasToOpenJob = true;
WrathOpener.SelectOpener(value.Value);
Svc.Framework.RunOnTick(() => P.IPCSearch.UpdateActiveJobPresets(), TimeSpan.FromSeconds(0.1));
Svc.Framework.RunOnTick(() =>
{
Service.IconReplacer.UpdateFilteredCombos();
AST.QuickTargetCards.SelectedRandomMember = null;
PvEFeatures.HasToOpenJob = true;
WrathOpener.SelectOpener(value.Value);
P.IPCSearch.UpdateActiveJobPresets();
}, TimeSpan.FromSeconds(0.1));
}
jobID = value;
}
Expand Down Expand Up @@ -416,7 +419,7 @@ private void OnCommand(string command, string arguments)
var controlled =
IPC.UIHelper.PresetControlled(preset) is not null;
var ctrlText = controlled ? " " + OptionControlledByIPC : "";
DuoLog.Information($"{preset} UNSET{ctrlText}");;
DuoLog.Information($"{preset} UNSET{ctrlText}"); ;
}

Service.Configuration.Save();
Expand Down Expand Up @@ -496,7 +499,7 @@ private void OnCommand(string command, string arguments)
int conflictingPluginsCount = conflictingPlugins?.Length ?? 0;

int leaseesCount = P.IPC.UIHelper.ShowNumberOfLeasees();
(string pluginName, int configurationsCount)[] leasees = P.IPC.UIHelper.ShowLeasees();
(string pluginName, int configurationsCount)[] leasees = P.IPC.UIHelper.ShowLeasees();

string repoURL = RepoCheckFunctions.FetchCurrentRepo()?.InstalledFromUrl ?? "Unknown";
string currentZone = Svc.Data.GetExcelSheet<TerritoryType>()?
Expand Down

0 comments on commit 0c3a605

Please sign in to comment.