From b4286a261244d7edebbc726515759597732f1049 Mon Sep 17 00:00:00 2001 From: LTS-FFXIV <127939494+LTS-FFXIV@users.noreply.github.com> Date: Wed, 23 Oct 2024 08:25:09 -0500 Subject: [PATCH] Update ECommons submodule and improve null safety Updated ECommons submodule to commit 4011a66. Added null checks for StatusList in DataCenter's DispelTarget property to prevent NullReferenceException. Moved TryGetIconTextureWrap call in RotationSolverPlugin to Svc.Framework.RunOnTick lambda for thread safety. --- ECommons | 2 +- RotationSolver.Basic/DataCenter.cs | 12 ++++++------ RotationSolver/RotationSolverPlugin.cs | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ECommons b/ECommons index bf66e3d69..4011a66cf 160000 --- a/ECommons +++ b/ECommons @@ -1 +1 @@ -Subproject commit bf66e3d6922325bf6c82ff884021bb9f47ba5e90 +Subproject commit 4011a66cf53752ef7db0186fbe5ab2a1364fdd06 diff --git a/RotationSolver.Basic/DataCenter.cs b/RotationSolver.Basic/DataCenter.cs index 4ecf15c48..582d1226b 100644 --- a/RotationSolver.Basic/DataCenter.cs +++ b/RotationSolver.Basic/DataCenter.cs @@ -463,12 +463,12 @@ public static IBattleChara? DispelTarget { get { - var weakenPeople = - DataCenter.PartyMembers.Where(o => o is IBattleChara b && b.StatusList.Any(StatusHelper.CanDispel)); - var weakenNPC = - DataCenter.FriendlyNPCMembers.Where(o => o is IBattleChara b && b.StatusList.Any(StatusHelper.CanDispel)); - var dyingPeople = - weakenPeople.Where(o => o is IBattleChara b && b.StatusList.Any(StatusHelper.IsDangerous)); + var weakenPeople = DataCenter.PartyMembers + .Where(o => o is IBattleChara b && b.StatusList != null && b.StatusList.Any(StatusHelper.CanDispel)); + var weakenNPC = DataCenter.FriendlyNPCMembers + .Where(o => o is IBattleChara b && b.StatusList != null && b.StatusList.Any(StatusHelper.CanDispel)); + var dyingPeople = weakenPeople + .Where(o => o is IBattleChara b && b.StatusList != null && b.StatusList.Any(StatusHelper.IsDangerous)); return dyingPeople.OrderBy(ObjectHelper.DistanceToPlayer).FirstOrDefault() ?? weakenPeople.OrderBy(ObjectHelper.DistanceToPlayer).FirstOrDefault() diff --git a/RotationSolver/RotationSolverPlugin.cs b/RotationSolver/RotationSolverPlugin.cs index 42ca23c23..694a9be2b 100644 --- a/RotationSolver/RotationSolverPlugin.cs +++ b/RotationSolver/RotationSolverPlugin.cs @@ -42,7 +42,10 @@ public sealed class RotationSolverPlugin : IDalamudPlugin, IDisposable public RotationSolverPlugin(IDalamudPluginInterface pluginInterface) { ECommonsMain.Init(pluginInterface, this, ECommons.Module.DalamudReflector, ECommons.Module.ObjectFunctions); - ThreadLoadImageHandler.TryGetIconTextureWrap(0, true, out _); + Svc.Framework.RunOnTick(() => + { + ThreadLoadImageHandler.TryGetIconTextureWrap(0, true, out _); + }); IconSet.Init(); _dis.Add(new Service());