From eeded1c9ee923ac0e4a974c22f7310b80ab14a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Mon, 20 Mar 2023 21:47:10 +0800 Subject: [PATCH] fix: changed the rotation choic --- RotationSolver/RotationHelper.cs | 9 ++++++-- .../UI/RotationConfigWindow_Debug.cs | 15 ++++++++++--- RotationSolver/Updaters/RotationUpdater.cs | 22 +++++++++---------- RotationSolver/Updaters/SocialUpdater.cs | 2 +- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/RotationSolver/RotationHelper.cs b/RotationSolver/RotationHelper.cs index b1263fcc2..a861500eb 100644 --- a/RotationSolver/RotationHelper.cs +++ b/RotationSolver/RotationHelper.cs @@ -16,7 +16,7 @@ internal static class RotationHelper }; public static bool IsDefault(this ICustomRotation rotation) - => DefaultAssembly == rotation.GetType().Assembly.GetName().Name; + => DefaultAssembly == GetId(rotation); public static bool IsAllowed(this ICustomRotation rotation, out string name) { @@ -26,7 +26,12 @@ public static bool IsAllowed(this ICustomRotation rotation, out string name) return false; } name = rotation.GetType().Assembly.GetName().Name; - return _allowedAssembly.Contains(name); + return _allowedAssembly.Contains(GetId(rotation)); + } + + internal static string GetId(this ICustomRotation rotation) + { + return Convert.ToBase64String(rotation.GetType().Assembly.GetName().GetPublicKeyToken()); } public static Vector4 GetColor(this ICustomRotation rotation) diff --git a/RotationSolver/UI/RotationConfigWindow_Debug.cs b/RotationSolver/UI/RotationConfigWindow_Debug.cs index ac4c59aa8..e4ff83ee4 100644 --- a/RotationSolver/UI/RotationConfigWindow_Debug.cs +++ b/RotationSolver/UI/RotationConfigWindow_Debug.cs @@ -5,8 +5,6 @@ using RotationSolver.Basic; using RotationSolver.Basic.Data; using RotationSolver.Basic.Helpers; -using RotationSolver.Commands; -using RotationSolver.UI; using RotationSolver.Updaters; using System.Numerics; @@ -25,6 +23,17 @@ private void DrawDebugTab() if (ImGui.BeginTabBar("Debug Items")) { + +#if DEBUG + if(RotationUpdater.Plugins != null) + { + foreach (var p in RotationUpdater.Plugins) + { + var s = p; + ImGui.InputText($"##{p}", ref s, 512); + } + } +#endif DrawParamTabItem("Status", DrawStatus); DrawParamTabItem("Party", DrawParty); DrawParamTabItem("Target Data", DrawTargetData); @@ -52,7 +61,7 @@ private unsafe void DrawStatus() foreach (var status in Service.Player.StatusList) { - var source = Service.ObjectTable.SearchById(status.SourceId)?.Name ?? "None"; + var source = status.SourceId == Service.Player.ObjectId ? "You" : Service.ObjectTable.SearchById(status.SourceId) == null ? "None" : "Others"; ImGui.Text($"{status.GameData.Name}: {status.StatusId} From: {source}"); } } diff --git a/RotationSolver/Updaters/RotationUpdater.cs b/RotationSolver/Updaters/RotationUpdater.cs index 49b417de7..359eb1d7c 100644 --- a/RotationSolver/Updaters/RotationUpdater.cs +++ b/RotationSolver/Updaters/RotationUpdater.cs @@ -21,6 +21,9 @@ public record CustomRotationGroup(ClassJobID jobId, ClassJobID[] classJobIds, IC static readonly string[] _locs = new string[] { "RotationSolver.dll", "RotationSolver.Basic.dll" }; +#if DEBUG + internal static string[] Plugins; +#endif public static void GetAllCustomRotations() { var directories = Service.Config.OtherLibs @@ -32,10 +35,7 @@ from l in Directory.GetFiles(dir, "*.dll") where !_locs.Any(l.Contains) select RotationLoadContext.LoadFrom(l); #if DEBUG - foreach (var ass in assemblies) - { - Service.ChatGui.Print(ass.FullName); - } + Plugins = assemblies.Select(a => a.GetName().Name + " : " + Convert.ToBase64String(a.GetName().GetPublicKeyToken())).ToArray(); #endif AuthorHashes = (from a in assemblies select a.GetCustomAttribute() into author @@ -123,23 +123,23 @@ public static IEnumerable> AllGroupedActions public static IBaseAction[] RightRotationBaseActions { get; private set; } = new IBaseAction[0]; - static ClassJobID _job; - static string _rotationName; + //static ClassJobID _job; + //static string _rotationName; public static void UpdateRotation() { var nowJob = (ClassJobID)Service.Player.ClassJob.Id; Service.Config.RotationChoices.TryGetValue((uint)nowJob, out var newName); - if (_job == nowJob && _rotationName == newName) return; + //if (_job == nowJob && _rotationName == newName) return; - _job = nowJob; - _rotationName = newName; + //_job = nowJob; + //_rotationName = newName; foreach (var group in _customRotations) { - if (!group.classJobIds.Contains(_job)) continue; + if (!group.classJobIds.Contains(nowJob)) continue; - RightNowRotation = GetChooseRotation(group, _rotationName); + RightNowRotation = GetChooseRotation(group, newName); RightRotationBaseActions = RightNowRotation.AllBaseActions; break; } diff --git a/RotationSolver/Updaters/SocialUpdater.cs b/RotationSolver/Updaters/SocialUpdater.cs index b22459fe2..c38c3301b 100644 --- a/RotationSolver/Updaters/SocialUpdater.cs +++ b/RotationSolver/Updaters/SocialUpdater.cs @@ -150,7 +150,7 @@ internal static string EncryptString(PlayerCharacter player) + " - " + player.Name.ToString() + "U6Wy.zCG"); var tmpHash = MD5.Create().ComputeHash(inputByteArray); - var retB = Convert.ToBase64String(tmpHash.ToArray()); + var retB = Convert.ToBase64String(tmpHash); return retB; } }