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

Commit

Permalink
fix: changed the way to get Ping.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 26, 2023
1 parent d002784 commit fec60bd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
10 changes: 6 additions & 4 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,10 @@ public static float DPSTaken
public static ActionID LastGCD { get; private set; } = 0;

public static ActionID LastAbility { get; private set; } = 0;
public static float Ping => Math.Min(RealPing, Service.Config.MaxPing);
public static float RealPing { get; private set; } = 0.07f;
public static float Ping => Math.Min(Math.Min(ActionFetchTime, Service.Config.MaxPing),
LastRTT == 0 ? float.MaxValue : LastRTT);
public static float ActionFetchTime { get; private set; } = 0.07f;
public static float LastRTT { get; set; } = 0;

public const float MinAnimationLock = 0.6f;
public static unsafe void AddActionRec(Action act)
Expand All @@ -326,15 +328,15 @@ public static unsafe void AddActionRec(Action act)
LastAction = LastGCD = id;
if (ActionManager.GetAdjustedCastTime(ActionType.Spell, (uint)id) == 0)
{
RealPing = WeaponElapsed;
ActionFetchTime = WeaponElapsed / 2;
}
break;
case ActionCate.Ability:
LastAction = LastAbility = id;

if (!act.IsRealGCD() && ActionManager.GetMaxCharges((uint)id, Service.Player.Level) < 2)
{
RealPing = ActionManager.Instance()->GetRecastGroupDetail(act.CooldownGroup - 1)->Elapsed;
ActionFetchTime = ActionManager.Instance()->GetRecastGroupDetail(act.CooldownGroup - 1)->Elapsed / 2;
}
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/RotationConfigWindow_Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private unsafe void DrawStatus()
ImGui.Text("TimeToNext: " + DataCenter.NextAbilityToNextGCD.ToString());
ImGui.Text("WeaponElapsed: " + DataCenter.WeaponElapsed.ToString());
ImGui.Text("AnimationLock: " + DataCenter.ActionRemain.ToString());
ImGui.Text("Real Ping: " + DataCenter.RealPing.ToString());
ImGui.Text("Fetch Time: " + DataCenter.ActionFetchTime.ToString());

ImGui.Text("Have pet: " + DataCenter.HasPet.ToString());
ImGui.Text("Hostile Near Count: " + DataCenter.NumberOfHostilesInRange.ToString());
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void DrawParamBasic()
ref Service.Config.MaxPing, Service.Default.MaxPing, min: 100, max: 500);

ImGui.SameLine();
ImGui.Text(" Your Ping: " + DataCenter.RealPing.ToString("F3"));
ImGui.Text($" Ping:{DataCenter.LastRTT:F3} Fetch: {DataCenter.ActionFetchTime:F3}");

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_ActionAhead,
ref Service.Config.ActionAhead, Service.Default.ActionAhead, max: 0.5f);
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ internal unsafe static void DoAction()
&& ActionManager.Instance()->QueuedActionId != NextAction.AdjustedID
|| Service.Player.CurrentHp == 0) return;

var maxAhead = Math.Max(DataCenter.MinAnimationLock - DataCenter.RealPing - 0.03f, 0.08f);
var maxAhead = Math.Max(DataCenter.MinAnimationLock - DataCenter.ActionFetchTime - 0.03f, 0.08f);
var ahead = Math.Min(maxAhead, Service.Config.ActionAhead);

//GCD
Expand Down
12 changes: 11 additions & 1 deletion RotationSolver/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Dalamud.Hooking;
using Dalamud.Interface.Colors;
using Dalamud.Logging;
using Dalamud.Plugin.Ipc;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game;
using RotationSolver.Localization;
Expand All @@ -18,14 +19,23 @@ public class Watcher : IDisposable
/// </summary>
[Signature("4C 89 44 24 ?? 55 56 41 54 41 55 41 56", DetourName = nameof(ReceiveAbilityEffect))]
private static Hook<ReceiveAbilityDelegate> _receiveAbilityHook;
public static ICallGateSubscriber<object, object> IpcSubscriber;

public static DateTime HealTime { get; private set; } = DateTime.Now;
public static Dictionary<uint, (uint, uint)> HealHP { get; private set; } = new Dictionary<uint, (uint, uint)>();
public Watcher()
{
SignatureHelper.Initialise(this);

_receiveAbilityHook?.Enable();

IpcSubscriber = Service.Interface.GetIpcSubscriber<object, object>("PingPlugin.Ipc");
IpcSubscriber.Subscribe(UpdateRTTDetour);
}

private void UpdateRTTDetour(dynamic expando)
{
PluginLog.LogDebug($"LastRTT:{expando.LastRTT}");
DataCenter.LastRTT = (long)expando.LastRTT / 1000f;
}

public static string ShowStrSelf { get; private set; } = string.Empty;
Expand Down

0 comments on commit fec60bd

Please sign in to comment.