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

Commit

Permalink
fix: add another ping check method to refine the ping.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed May 2, 2023
1 parent 476737a commit 1e751cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
9 changes: 9 additions & 0 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,18 @@ public static unsafe void AddActionRec(Action act)
case ActionCate.Spell:
case ActionCate.WeaponSkill:
LastAction = LastGCD = id;
if (ActionManager.GetAdjustedCastTime(ActionType.Spell, (uint)id) == 0)
{
FetchTime = WeaponElapsed;
}
break;
case ActionCate.Ability:
LastAction = LastAbility = id;

if (!act.IsRealGCD() && ActionManager.GetMaxCharges((uint)id, Service.Player.Level) < 2)
{
FetchTime = ActionManager.Instance()->GetRecastGroupDetail(act.CooldownGroup - 1)->Elapsed;
}
break;
default:
return;
Expand Down
21 changes: 0 additions & 21 deletions RotationSolver/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,19 @@ public class Watcher : IDisposable
{
private unsafe delegate void ReceiveAbilityDelegate(uint sourceId, IntPtr sourceCharacter, Vector3* pos, ActionEffectHeader* effectHeader, ActionEffect* effectArray, ulong* effectTargets);

private delegate long ActionRequestDelegate(long a1, uint a2, uint a3);
/// <summary>
/// https://github.com/Tischel/ActionTimeline/blob/master/ActionTimeline/Helpers/TimelineManager.cs#L86
/// </summary>
[Signature("4C 89 44 24 ?? 55 56 41 54 41 55 41 56", DetourName = nameof(ReceiveAbilityEffect))]
private static Hook<ReceiveAbilityDelegate> _receiveAbilityHook;

/// <summary>
/// https://github.com/Bluefissure/DoubleWeaver/blob/master/DoubleWeaver/Plugin.cs#L94
/// </summary>
[Signature("E8 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? FF 50 18", DetourName = nameof(ActionRequest))]
private static Hook<ActionRequestDelegate> _actionRequestDelegate;

public static ICallGateSubscriber<object, object> IpcSubscriber;

private static SortedDictionary<uint, DateTime> _requestTime = new SortedDictionary<uint, DateTime>();

public Watcher()
{
SignatureHelper.Initialise(this);
_receiveAbilityHook?.Enable();
_actionRequestDelegate?.Enable();

IpcSubscriber = Service.Interface.GetIpcSubscriber<object, object>("PingPlugin.Ipc");
IpcSubscriber.Subscribe(UpdateRTTDetour);
Expand All @@ -51,13 +42,6 @@ private void UpdateRTTDetour(dynamic obj)
public static string ShowStrSelf { get; private set; } = string.Empty;
public static string ShowStrEnemy { get; private set; } = string.Empty;

private static long ActionRequest(long a1, uint a2, uint a3)
{
_requestTime[a3] = DateTime.Now;
Service.ChatGui.Print($"Sent: {a3}");
return _actionRequestDelegate.Original(a1, a2, a3);
}

private static unsafe void ReceiveAbilityEffect(uint sourceId, IntPtr sourceCharacter, Vector3* pos, ActionEffectHeader* effectHeader, ActionEffect* effectArray, ulong* effectTargets)
{

Expand Down Expand Up @@ -125,11 +109,6 @@ private static void ActionFromEnemy(uint sourceId, ActionEffectSet set)
private static void ActionFromSelf(uint sourceId, ActionEffectSet set, uint id)
{
if (sourceId != Service.Player.ObjectId) return;
if(_requestTime.TryGetValue(id, out var time))
{
DataCenter.FetchTime = (float)(DateTime.Now - time).TotalSeconds;
_requestTime.Remove(id);
}
if (set.Type != ActionType.Spell && set.Type != ActionType.Item) return;
if (set.Action == null) return;
if ((ActionCate)set.Action.ActionCategory.Value.RowId == ActionCate.AutoAttack) return;
Expand Down

0 comments on commit 1e751cd

Please sign in to comment.