From 700aaa4a5d647a74f657088f0d38a85694a3a28f Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Sun, 19 Oct 2025 17:20:30 +0200 Subject: [PATCH] Fix Unlock event not firing --- Dalamud/Game/UnlockState/UnlockState.cs | 111 ++++++++++-------------- 1 file changed, 48 insertions(+), 63 deletions(-) diff --git a/Dalamud/Game/UnlockState/UnlockState.cs b/Dalamud/Game/UnlockState/UnlockState.cs index f86b89efb..846be8294 100644 --- a/Dalamud/Game/UnlockState/UnlockState.cs +++ b/Dalamud/Game/UnlockState/UnlockState.cs @@ -577,65 +577,53 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState return UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(unlockLink); } - private void UpdateUnlocks() - { - try - { - this.UpdateUnlocks(false); - } - catch (Exception ex) - { - Log.Error(ex, "Error during initial unlock check"); - } - } - private void OnLogout(int type, int code) { this.cachedUnlockedRowIds.Clear(); } - private void UpdateUnlocks(bool fireEvent) + private void UpdateUnlocks() { if (!this.IsLoaded) return; - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); - this.UpdateUnlocksForSheet(fireEvent); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); // Not implemented: // - DescriptionPage: quite complex @@ -663,7 +651,7 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState // - Support/Phantom Jobs, which require to be in Occult Crescent, because it checks the jobs level for != 0 } - private void UpdateUnlocksForSheet(bool fireEvent = true) where T : struct, IExcelRow + private void UpdateUnlocksForSheet() where T : struct, IExcelRow { var unlockedRowIds = this.cachedUnlockedRowIds.GetOrAdd(typeof(T), _ => []); @@ -679,20 +667,17 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState unlockedRowIds.Add(row.RowId); - if (fireEvent) - { - Log.Verbose("Unlock detected: {row}", $"{typeof(T).Name}#{row.RowId}"); + Log.Verbose($"Unlock detected: {typeof(T).Name}#{row.RowId}"); - foreach (var action in Delegate.EnumerateInvocationList(this.Unlock)) + foreach (var action in Delegate.EnumerateInvocationList(this.Unlock)) + { + try { - try - { - action((RowRef)rowRef); - } - catch (Exception ex) - { - Log.Error(ex, "Exception during raise of {handler}", action.Method); - } + action((RowRef)rowRef); + } + catch (Exception ex) + { + Log.Error(ex, "Exception during raise of {handler}", action.Method); } } }