From 6ba62e406faa1e28888117dffdd1f56aa916f319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Wed, 25 Jan 2023 21:22:51 +0800 Subject: [PATCH] fix: fix with fateManager..GOD! --- .../Updaters/TargetUpdater_Hostile.cs | 20 +++++++++++++++++-- .../Windows/RotationConfigWindow_Debug.cs | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/RotationSolver/Updaters/TargetUpdater_Hostile.cs b/RotationSolver/Updaters/TargetUpdater_Hostile.cs index a2f80ba9f..717e69943 100644 --- a/RotationSolver/Updaters/TargetUpdater_Hostile.cs +++ b/RotationSolver/Updaters/TargetUpdater_Hostile.cs @@ -1,4 +1,5 @@ using Dalamud.Game.ClientState.Objects.Types; +using Dalamud.Logging; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.Fate; using FFXIVClientStructs.FFXIV.Client.UI; @@ -36,11 +37,26 @@ internal static partial class TargetUpdater internal static bool IsHostileCastingToTank { get; private set; } = false; - + internal static unsafe bool Infate + { + get + { + try + { + return Service.Configuration.ChangeTargetForFate && (IntPtr)FateManager.Instance() != IntPtr.Zero && FateManager.Instance()->FateJoined > 0 + && Service.ClientState.LocalPlayer.Level <= FateManager.Instance()->CurrentFate->MaxLevel; + } + catch(Exception ex) + { + PluginLog.Error(ex.StackTrace); + return false; + } + } + } internal unsafe static void UpdateHostileTargets() { - var inFate = Service.Configuration.ChangeTargetForFate && (IntPtr)FateManager.Instance() != IntPtr.Zero && FateManager.Instance()->FateJoined > 0; + var inFate = Infate; AllTargets = TargetFilter.GetTargetable(TargetFilter.GetObjectInRadius(Service.ObjectTable, 30).Where(obj => { diff --git a/RotationSolver/Windows/RotationConfigWindow_Debug.cs b/RotationSolver/Windows/RotationConfigWindow_Debug.cs index 9c6ff8cf5..fdb9054d4 100644 --- a/RotationSolver/Windows/RotationConfigWindow_Debug.cs +++ b/RotationSolver/Windows/RotationConfigWindow_Debug.cs @@ -24,7 +24,7 @@ private unsafe void DrawDebugTab() ImGui.Text("Friends: " + TargetUpdater.PartyMembers.Count().ToString()); if ((IntPtr)FateManager.Instance() != IntPtr.Zero) { - ImGui.Text("Fate: " + FateManager.Instance()->FateJoined.ToString()); + ImGui.Text("Fate: " + TargetUpdater.Infate.ToString()); } if (ImGui.CollapsingHeader("Status"))