Make PrerefreshHandler safer

This commit is contained in:
Zeffuro
2025-12-30 10:15:46 +01:00
parent f3b006b276
commit 6696f997d5
2 changed files with 12 additions and 0 deletions
@@ -5,10 +5,12 @@ using AetherBags.Inventory;
using AetherBags.Inventory.Context; using AetherBags.Inventory.Context;
using Dalamud.Game.Addon.Lifecycle; using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.NativeWrapper; using Dalamud.Game.NativeWrapper;
using Dalamud.Utility; using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Text.ReadOnly; using Lumina.Text.ReadOnly;
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
namespace AetherBags.AddonLifecycles; namespace AetherBags.AddonLifecycles;
@@ -39,6 +41,12 @@ public class InventoryLifecycles : IDisposable
if (args is not AddonRefreshArgs refreshArgs) if (args is not AddonRefreshArgs refreshArgs)
return; return;
if (!Services.ClientState.IsLoggedIn)
return;
if (Services.Condition[ConditionFlag.BetweenAreas] || Services.Condition[ConditionFlag.BetweenAreas51])
return;
GeneralSettings config = System.Config.General; GeneralSettings config = System.Config.General;
Services.Logger.Debug("PreRefresh event for Inventory detected"); Services.Logger.Debug("PreRefresh event for Inventory detected");
@@ -51,6 +59,9 @@ public class InventoryLifecycles : IDisposable
AtkValue* value5 = (AtkValue*)atkValues[5].Address; AtkValue* value5 = (AtkValue*)atkValues[5].Address;
AtkValue* value6 = (AtkValue*)atkValues[6].Address; AtkValue* value6 = (AtkValue*)atkValues[6].Address;
if (value5->Type != ValueType.ManagedString || value6->Type != ValueType.ManagedString)
return;
int openTitleId = value1->Int; int openTitleId = value1->Int;
ReadOnlySeString title = value5->String.AsReadOnlySeString(); ReadOnlySeString title = value5->String.AsReadOnlySeString();
ReadOnlySeString upperTitle = value6->String.AsReadOnlySeString(); ReadOnlySeString upperTitle = value6->String.AsReadOnlySeString();
+1
View File
@@ -10,6 +10,7 @@ public class Services
[PluginService] public static IChatGui ChatGui { get; set; } = null!; [PluginService] public static IChatGui ChatGui { get; set; } = null!;
[PluginService] public static IClientState ClientState { get; private set; } = null!; [PluginService] public static IClientState ClientState { get; private set; } = null!;
[PluginService] public static ICommandManager CommandManager { 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 IDataManager DataManager { get; set; } = null!;
[PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!; [PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] public static IFramework Framework { get; private set; } = null!; [PluginService] public static IFramework Framework { get; private set; } = null!;