diff --git a/RotationSolver.Basic/DataCenter.cs b/RotationSolver.Basic/DataCenter.cs index 963163cb8..830c823af 100644 --- a/RotationSolver.Basic/DataCenter.cs +++ b/RotationSolver.Basic/DataCenter.cs @@ -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) @@ -326,7 +328,7 @@ 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: @@ -334,7 +336,7 @@ public static unsafe void AddActionRec(Action act) 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: diff --git a/RotationSolver/UI/RotationConfigWindow_Debug.cs b/RotationSolver/UI/RotationConfigWindow_Debug.cs index d020c90cf..1f2ae6ef4 100644 --- a/RotationSolver/UI/RotationConfigWindow_Debug.cs +++ b/RotationSolver/UI/RotationConfigWindow_Debug.cs @@ -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()); diff --git a/RotationSolver/UI/RotationConfigWindow_Param.cs b/RotationSolver/UI/RotationConfigWindow_Param.cs index d25d3c7bc..509bf1474 100644 --- a/RotationSolver/UI/RotationConfigWindow_Param.cs +++ b/RotationSolver/UI/RotationConfigWindow_Param.cs @@ -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); diff --git a/RotationSolver/Updaters/ActionUpdater.cs b/RotationSolver/Updaters/ActionUpdater.cs index 2f6552b6f..afa69a6b9 100644 --- a/RotationSolver/Updaters/ActionUpdater.cs +++ b/RotationSolver/Updaters/ActionUpdater.cs @@ -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 diff --git a/RotationSolver/Watcher.cs b/RotationSolver/Watcher.cs index 18b8da063..a9ae15060 100644 --- a/RotationSolver/Watcher.cs +++ b/RotationSolver/Watcher.cs @@ -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; @@ -18,14 +19,23 @@ public class Watcher : IDisposable /// [Signature("4C 89 44 24 ?? 55 56 41 54 41 55 41 56", DetourName = nameof(ReceiveAbilityEffect))] private static Hook _receiveAbilityHook; + public static ICallGateSubscriber IpcSubscriber; public static DateTime HealTime { get; private set; } = DateTime.Now; public static Dictionary HealHP { get; private set; } = new Dictionary(); public Watcher() { SignatureHelper.Initialise(this); - _receiveAbilityHook?.Enable(); + + IpcSubscriber = Service.Interface.GetIpcSubscriber("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;