More InvokeSafely calls (#2215)

* Safely invoke DutyState event handlers

* Safely invoke GameGui event handlers
This commit is contained in:
Haselnussbomber 2025-03-28 17:19:25 +01:00 committed by GitHub
parent c1557df585
commit b28fab2d08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 24 deletions

View file

@ -1,10 +1,11 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Hooking;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
namespace Dalamud.Game.DutyState;
@ -81,33 +82,33 @@ internal unsafe class DutyState : IInternalDisposableService, IDutyState
// Duty Commenced
case 0x4000_0001:
this.IsDutyStarted = true;
this.DutyStarted?.Invoke(this, this.clientState.TerritoryType);
this.DutyStarted?.InvokeSafely(this, this.clientState.TerritoryType);
break;
// Party Wipe
case 0x4000_0005:
this.IsDutyStarted = false;
this.DutyWiped?.Invoke(this, this.clientState.TerritoryType);
this.DutyWiped?.InvokeSafely(this, this.clientState.TerritoryType);
break;
// Duty Recommence
case 0x4000_0006:
this.IsDutyStarted = true;
this.DutyRecommenced?.Invoke(this, this.clientState.TerritoryType);
this.DutyRecommenced?.InvokeSafely(this, this.clientState.TerritoryType);
break;
// Duty Completed Flytext Shown
case 0x4000_0002 when !this.CompletedThisTerritory:
this.IsDutyStarted = false;
this.CompletedThisTerritory = true;
this.DutyCompleted?.Invoke(this, this.clientState.TerritoryType);
this.DutyCompleted?.InvokeSafely(this, this.clientState.TerritoryType);
break;
// Duty Completed
case 0x4000_0003 when !this.CompletedThisTerritory:
this.IsDutyStarted = false;
this.CompletedThisTerritory = true;
this.DutyCompleted?.Invoke(this, this.clientState.TerritoryType);
this.DutyCompleted?.InvokeSafely(this, this.clientState.TerritoryType);
break;
}
}

View file

@ -307,15 +307,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
if (values != null && valueCount == 1 && values->Int == -1)
{
this.HoveredItem = 0;
try
{
this.HoveredItemChanged?.Invoke(this, 0);
}
catch (Exception e)
{
Log.Error(e, "Could not dispatch HoveredItemChanged event.");
}
this.HoveredItemChanged?.InvokeSafely(this, 0ul);
Log.Verbose("HoveredItem changed: 0");
}
@ -347,15 +339,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
this.HoveredAction.ActionKind = HoverActionKind.None;
this.HoveredAction.BaseActionID = 0;
this.HoveredAction.ActionID = 0;
try
{
this.HoveredActionChanged?.Invoke(this, this.HoveredAction);
}
catch (Exception e)
{
Log.Error(e, "Could not dispatch HoveredActionChanged event.");
}
this.HoveredActionChanged?.InvokeSafely(this, this.HoveredAction);
Log.Verbose("HoverActionId: 0");
}