Skip to content

Commit

Permalink
Fix #92
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownX7 committed May 26, 2023
1 parent 88c51a8 commit 3dfba14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions Modules/QueueAdjustments.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using FFXIVClientStructs.FFXIV.Client.Game;
using Hypostasis.Game.Structures;
using ActionManager = Hypostasis.Game.Structures.ActionManager;
Expand All @@ -10,6 +11,7 @@ public unsafe class QueueAdjustments : PluginModule
private static bool isRequeuing = false;
private static float tempQueue = 0f;
private static uint lastUsedActionID = 0;
private static Stopwatch lastUsedActionTimer = new();

public override bool ShouldEnable => ReAction.Config.EnableQueueAdjustments;

Expand Down Expand Up @@ -50,7 +52,10 @@ private static void PostActionStack(ActionManager* actionManager, uint actionTyp
private static void PostUseAction(ActionManager* actionManager, uint actionType, uint actionID, uint adjustedActionID, long targetObjectID, uint param, uint useType, int pvp, bool ret)
{
if (ret && (useType == 1 || !actionManager->isQueued))
{
lastUsedActionID = adjustedActionID;
lastUsedActionTimer.Restart();
}

if (!isRequeuing) return;

Expand Down Expand Up @@ -80,12 +85,6 @@ private static void PostUseAction(ActionManager* actionManager, uint actionType,
return recastRemaining > additionalRecastRemaining ? recastRemaining : additionalRecastRemaining;
}

private static float GetElapsedActionRecast(ActionManager* actionManager, uint actionType, uint actionID)
{
var recastGroupDetail = actionManager->CS.GetRecastGroupDetail(actionManager->CS.GetRecastGroup((int)actionType, actionID));
return recastGroupDetail != null ? recastGroupDetail->Elapsed : -1;
}

public static Bool CanQueueActionDetour(ActionManager* actionManager, uint actionType, uint actionID)
{
float threshold;
Expand All @@ -100,8 +99,7 @@ public static Bool CanQueueActionDetour(ActionManager* actionManager, uint actio
}
else
{
var elapsed = GetElapsedActionRecast(actionManager, actionType, actionID);
threshold = (actionType == 1 ? actionManager->CS.GetAdjustedActionId(lastUsedActionID) == actionManager->CS.GetAdjustedActionId(actionID) : lastUsedActionID == actionID) && elapsed >= 0 && elapsed < ReAction.Config.QueueActionLockout
threshold = (actionType == 1 ? actionManager->CS.GetAdjustedActionId(lastUsedActionID) == actionManager->CS.GetAdjustedActionId(actionID) : lastUsedActionID == actionID) && lastUsedActionTimer.Elapsed.TotalSeconds < ReAction.Config.QueueActionLockout
? 0
: ReAction.Config.EnableGCDAdjustedQueueThreshold
? ReAction.Config.QueueThreshold * ActionManager.GCDRecast / 2500f
Expand Down
2 changes: 1 addition & 1 deletion ReAction.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.3.3.4</Version>
<Version>1.3.3.5</Version>
<TargetFramework>net7.0</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64;AnyCPU</Platforms>
Expand Down

0 comments on commit 3dfba14

Please sign in to comment.