Fix Unlock event not firing

This commit is contained in:
Haselnussbomber 2025-10-19 17:20:30 +02:00
parent 69caffeb97
commit 700aaa4a5d
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1

View file

@ -577,65 +577,53 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState
return UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(unlockLink); 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) private void OnLogout(int type, int code)
{ {
this.cachedUnlockedRowIds.Clear(); this.cachedUnlockedRowIds.Clear();
} }
private void UpdateUnlocks(bool fireEvent) private void UpdateUnlocks()
{ {
if (!this.IsLoaded) if (!this.IsLoaded)
return; return;
this.UpdateUnlocksForSheet<ActionSheet>(fireEvent); this.UpdateUnlocksForSheet<ActionSheet>();
this.UpdateUnlocksForSheet<AetherCurrent>(fireEvent); this.UpdateUnlocksForSheet<AetherCurrent>();
this.UpdateUnlocksForSheet<AetherCurrentCompFlgSet>(fireEvent); this.UpdateUnlocksForSheet<AetherCurrentCompFlgSet>();
this.UpdateUnlocksForSheet<AozAction>(fireEvent); this.UpdateUnlocksForSheet<AozAction>();
this.UpdateUnlocksForSheet<BannerBg>(fireEvent); this.UpdateUnlocksForSheet<BannerBg>();
this.UpdateUnlocksForSheet<BannerCondition>(fireEvent); this.UpdateUnlocksForSheet<BannerCondition>();
this.UpdateUnlocksForSheet<BannerDecoration>(fireEvent); this.UpdateUnlocksForSheet<BannerDecoration>();
this.UpdateUnlocksForSheet<BannerFacial>(fireEvent); this.UpdateUnlocksForSheet<BannerFacial>();
this.UpdateUnlocksForSheet<BannerFrame>(fireEvent); this.UpdateUnlocksForSheet<BannerFrame>();
this.UpdateUnlocksForSheet<BannerTimeline>(fireEvent); this.UpdateUnlocksForSheet<BannerTimeline>();
this.UpdateUnlocksForSheet<BuddyAction>(fireEvent); this.UpdateUnlocksForSheet<BuddyAction>();
this.UpdateUnlocksForSheet<BuddyEquip>(fireEvent); this.UpdateUnlocksForSheet<BuddyEquip>();
this.UpdateUnlocksForSheet<CSBonusContentType>(fireEvent); this.UpdateUnlocksForSheet<CSBonusContentType>();
this.UpdateUnlocksForSheet<CharaMakeCustomize>(fireEvent); this.UpdateUnlocksForSheet<CharaMakeCustomize>();
this.UpdateUnlocksForSheet<ChocoboTaxi>(fireEvent); this.UpdateUnlocksForSheet<ChocoboTaxi>();
this.UpdateUnlocksForSheet<Companion>(fireEvent); this.UpdateUnlocksForSheet<Companion>();
this.UpdateUnlocksForSheet<CraftAction>(fireEvent); this.UpdateUnlocksForSheet<CraftAction>();
this.UpdateUnlocksForSheet<EmjVoiceNpc>(fireEvent); this.UpdateUnlocksForSheet<EmjVoiceNpc>();
this.UpdateUnlocksForSheet<Emote>(fireEvent); this.UpdateUnlocksForSheet<Emote>();
this.UpdateUnlocksForSheet<GeneralAction>(fireEvent); this.UpdateUnlocksForSheet<GeneralAction>();
this.UpdateUnlocksForSheet<Glasses>(fireEvent); this.UpdateUnlocksForSheet<Glasses>();
this.UpdateUnlocksForSheet<HowTo>(fireEvent); this.UpdateUnlocksForSheet<HowTo>();
this.UpdateUnlocksForSheet<InstanceContentSheet>(fireEvent); this.UpdateUnlocksForSheet<InstanceContentSheet>();
this.UpdateUnlocksForSheet<Item>(fireEvent); this.UpdateUnlocksForSheet<Item>();
this.UpdateUnlocksForSheet<MJILandmark>(fireEvent); this.UpdateUnlocksForSheet<MJILandmark>();
this.UpdateUnlocksForSheet<MKDLore>(fireEvent); this.UpdateUnlocksForSheet<MKDLore>();
this.UpdateUnlocksForSheet<McGuffin>(fireEvent); this.UpdateUnlocksForSheet<McGuffin>();
this.UpdateUnlocksForSheet<Mount>(fireEvent); this.UpdateUnlocksForSheet<Mount>();
this.UpdateUnlocksForSheet<NotebookDivision>(fireEvent); this.UpdateUnlocksForSheet<NotebookDivision>();
this.UpdateUnlocksForSheet<Orchestrion>(fireEvent); this.UpdateUnlocksForSheet<Orchestrion>();
this.UpdateUnlocksForSheet<Ornament>(fireEvent); this.UpdateUnlocksForSheet<Ornament>();
this.UpdateUnlocksForSheet<Perform>(fireEvent); this.UpdateUnlocksForSheet<Perform>();
this.UpdateUnlocksForSheet<PublicContentSheet>(fireEvent); this.UpdateUnlocksForSheet<PublicContentSheet>();
this.UpdateUnlocksForSheet<Recipe>(fireEvent); this.UpdateUnlocksForSheet<Recipe>();
this.UpdateUnlocksForSheet<SecretRecipeBook>(fireEvent); this.UpdateUnlocksForSheet<SecretRecipeBook>();
this.UpdateUnlocksForSheet<Trait>(fireEvent); this.UpdateUnlocksForSheet<Trait>();
this.UpdateUnlocksForSheet<TripleTriadCard>(fireEvent); this.UpdateUnlocksForSheet<TripleTriadCard>();
// Not implemented: // Not implemented:
// - DescriptionPage: quite complex // - 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 // - Support/Phantom Jobs, which require to be in Occult Crescent, because it checks the jobs level for != 0
} }
private void UpdateUnlocksForSheet<T>(bool fireEvent = true) where T : struct, IExcelRow<T> private void UpdateUnlocksForSheet<T>() where T : struct, IExcelRow<T>
{ {
var unlockedRowIds = this.cachedUnlockedRowIds.GetOrAdd(typeof(T), _ => []); var unlockedRowIds = this.cachedUnlockedRowIds.GetOrAdd(typeof(T), _ => []);
@ -679,9 +667,7 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState
unlockedRowIds.Add(row.RowId); unlockedRowIds.Add(row.RowId);
if (fireEvent) Log.Verbose($"Unlock detected: {typeof(T).Name}#{row.RowId}");
{
Log.Verbose("Unlock detected: {row}", $"{typeof(T).Name}#{row.RowId}");
foreach (var action in Delegate.EnumerateInvocationList(this.Unlock)) foreach (var action in Delegate.EnumerateInvocationList(this.Unlock))
{ {
@ -696,7 +682,6 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState
} }
} }
} }
}
} }
/// <summary> /// <summary>