From 6696f997d5994486c2c1ff8499d8cc5b37bbbe51 Mon Sep 17 00:00:00 2001 From: Zeffuro Date: Tue, 30 Dec 2025 10:15:46 +0100 Subject: [PATCH] Make PrerefreshHandler safer --- AetherBags/AddonLifecycles/InventoryLifecycles.cs | 11 +++++++++++ AetherBags/Services.cs | 1 + 2 files changed, 12 insertions(+) diff --git a/AetherBags/AddonLifecycles/InventoryLifecycles.cs b/AetherBags/AddonLifecycles/InventoryLifecycles.cs index c966fc6..fb35975 100644 --- a/AetherBags/AddonLifecycles/InventoryLifecycles.cs +++ b/AetherBags/AddonLifecycles/InventoryLifecycles.cs @@ -5,10 +5,12 @@ using AetherBags.Inventory; using AetherBags.Inventory.Context; using Dalamud.Game.Addon.Lifecycle; using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; +using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.NativeWrapper; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Component.GUI; using Lumina.Text.ReadOnly; +using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType; namespace AetherBags.AddonLifecycles; @@ -39,6 +41,12 @@ public class InventoryLifecycles : IDisposable if (args is not AddonRefreshArgs refreshArgs) return; + if (!Services.ClientState.IsLoggedIn) + return; + + if (Services.Condition[ConditionFlag.BetweenAreas] || Services.Condition[ConditionFlag.BetweenAreas51]) + return; + GeneralSettings config = System.Config.General; Services.Logger.Debug("PreRefresh event for Inventory detected"); @@ -51,6 +59,9 @@ public class InventoryLifecycles : IDisposable AtkValue* value5 = (AtkValue*)atkValues[5].Address; AtkValue* value6 = (AtkValue*)atkValues[6].Address; + if (value5->Type != ValueType.ManagedString || value6->Type != ValueType.ManagedString) + return; + int openTitleId = value1->Int; ReadOnlySeString title = value5->String.AsReadOnlySeString(); ReadOnlySeString upperTitle = value6->String.AsReadOnlySeString(); diff --git a/AetherBags/Services.cs b/AetherBags/Services.cs index 38d2ea1..fb13d0e 100644 --- a/AetherBags/Services.cs +++ b/AetherBags/Services.cs @@ -10,6 +10,7 @@ public class Services [PluginService] public static IChatGui ChatGui { get; set; } = null!; [PluginService] public static IClientState ClientState { get; private set; } = null!; [PluginService] public static ICommandManager CommandManager { get; private set; } = null!; + [PluginService] public static ICondition Condition { get; private set; } = null!; [PluginService] public static IDataManager DataManager { get; set; } = null!; [PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!; [PluginService] public static IFramework Framework { get; private set; } = null!;