diff --git a/Dalamud/Game/ClientState/ClientState.cs b/Dalamud/Game/ClientState/ClientState.cs index 5488bef2a..2dc687aa2 100644 --- a/Dalamud/Game/ClientState/ClientState.cs +++ b/Dalamud/Game/ClientState/ClientState.cs @@ -146,7 +146,7 @@ namespace Dalamud.Game.ClientState private IntPtr SetupTerritoryTypeDetour(IntPtr manager, ushort terriType) { this.TerritoryType = terriType; - this.TerritoryChanged?.Raise(this, terriType); + this.TerritoryChanged?.InvokeSafely(this, terriType); Log.Debug("TerritoryType changed: {0}", terriType); @@ -155,7 +155,7 @@ namespace Dalamud.Game.ClientState private void NetworkHandlersOnCfPop(object sender, Lumina.Excel.GeneratedSheets.ContentFinderCondition e) { - this.CfPop?.Raise(this, e); + this.CfPop?.InvokeSafely(this, e); } private void FrameworkOnOnUpdateEvent(Framework framework1) @@ -172,7 +172,7 @@ namespace Dalamud.Game.ClientState Log.Debug("Is login"); this.lastConditionNone = false; this.IsLoggedIn = true; - this.Login?.Raise(this, null); + this.Login?.InvokeSafely(this, null); gameGui.ResetUiHideState(); } @@ -181,7 +181,7 @@ namespace Dalamud.Game.ClientState Log.Debug("Is logout"); this.lastConditionNone = true; this.IsLoggedIn = false; - this.Logout?.Raise(this, null); + this.Logout?.InvokeSafely(this, null); gameGui.ResetUiHideState(); } @@ -194,11 +194,11 @@ namespace Dalamud.Game.ClientState if (this.IsPvP) { - this.EnterPvP?.Raise(); + this.EnterPvP?.InvokeSafely(); } else { - this.LeavePvP?.Raise(); + this.LeavePvP?.InvokeSafely(); } } } diff --git a/Dalamud/Game/Framework.cs b/Dalamud/Game/Framework.cs index 921fa1ce4..8d2e73812 100644 --- a/Dalamud/Game/Framework.cs +++ b/Dalamud/Game/Framework.cs @@ -415,7 +415,7 @@ namespace Dalamud.Game } else { - this.Update?.Raise(this); + this.Update?.InvokeSafely(this); } } diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs index e8f2b68b1..8272a6ce7 100644 --- a/Dalamud/Game/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -466,7 +466,7 @@ namespace Dalamud.Game.Gui var itemId = (ulong)Marshal.ReadInt32(hoverState, 0x138); this.HoveredItem = itemId; - this.HoveredItemChanged?.Raise(this, itemId); + this.HoveredItemChanged?.InvokeSafely(this, itemId); Log.Verbose("HoverItemId:{0} this:{1}", itemId, hoverState.ToInt64().ToString("X")); } @@ -508,7 +508,7 @@ namespace Dalamud.Game.Gui this.HoveredAction.ActionKind = actionKind; this.HoveredAction.BaseActionID = actionId; this.HoveredAction.ActionID = (uint)Marshal.ReadInt32(hoverState, 0x3C); - this.HoveredActionChanged?.Raise(this, this.HoveredAction); + this.HoveredActionChanged?.InvokeSafely(this, this.HoveredAction); Log.Verbose("HoverActionId: {0}/{1} this:{2}", actionKind, actionId, hoverState.ToInt64().ToString("X")); } @@ -548,7 +548,7 @@ namespace Dalamud.Game.Gui // TODO(goat): We should read this from memory directly, instead of relying on catching every toggle. this.GameUiHidden = !this.GameUiHidden; - this.UiHideToggled?.Raise(this, this.GameUiHidden); + this.UiHideToggled?.InvokeSafely(this, this.GameUiHidden); Log.Debug("UiHide toggled: {0}", this.GameUiHidden); diff --git a/Dalamud/Game/Network/Internal/NetworkHandlers.cs b/Dalamud/Game/Network/Internal/NetworkHandlers.cs index b1a9c4aeb..93c46f750 100644 --- a/Dalamud/Game/Network/Internal/NetworkHandlers.cs +++ b/Dalamud/Game/Network/Internal/NetworkHandlers.cs @@ -288,7 +288,7 @@ namespace Dalamud.Game.Network.Internal Service.GetNullable()?.Print($"Duty pop: {cfcName}"); } - this.CfPop?.Raise(this, cfCondition); + this.CfPop?.InvokeSafely(this, cfCondition); }).ContinueWith((task) => Log.Error(task.Exception, "CfPop.Invoke failed."), TaskContinuationOptions.OnlyOnFaulted); } } diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index 087787c1d..4d3faeadb 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -773,7 +773,7 @@ namespace Dalamud.Interface.Internal var customFontFirstConfigIndex = ioFonts.ConfigData.Size; Log.Verbose("[FONT] Invoke OnBuildFonts"); - this.BuildFonts?.Raise(); + this.BuildFonts?.InvokeSafely(); Log.Verbose("[FONT] OnBuildFonts OK!"); for (int i = customFontFirstConfigIndex, i_ = ioFonts.ConfigData.Size; i < i_; i++) @@ -881,7 +881,7 @@ namespace Dalamud.Interface.Internal } Log.Verbose("[FONT] Invoke OnAfterBuildFonts"); - this.AfterBuildFonts?.Raise(); + this.AfterBuildFonts?.InvokeSafely(); Log.Verbose("[FONT] OnAfterBuildFonts OK!"); if (ioFonts.Fonts[0].NativePtr != DefaultFont.NativePtr) @@ -978,7 +978,7 @@ namespace Dalamud.Interface.Internal Log.Verbose($"Calling resizebuffers swap@{swapChain.ToInt64():X}{bufferCount} {width} {height} {newFormat} {swapChainFlags}"); #endif - this.ResizeBuffers?.Raise(); + this.ResizeBuffers?.InvokeSafely(); // We have to ensure we're working with the main swapchain, // as viewports might be resizing as well diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index 4849ee80b..22d620c8e 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -393,7 +393,7 @@ namespace Dalamud.Interface /// internal void OpenConfig() { - this.OpenConfigUi?.Raise(); + this.OpenConfigUi?.InvokeSafely(); } /// @@ -401,7 +401,7 @@ namespace Dalamud.Interface /// internal void NotifyHideUi() { - this.HideUi?.Raise(); + this.HideUi?.InvokeSafely(); } /// @@ -409,7 +409,7 @@ namespace Dalamud.Interface /// internal void NotifyShowUi() { - this.ShowUi?.Raise(); + this.ShowUi?.InvokeSafely(); } private void OnDraw() @@ -429,7 +429,7 @@ namespace Dalamud.Interface if (!this.lastFrameUiHideState) { this.lastFrameUiHideState = true; - this.HideUi?.Raise(); + this.HideUi?.InvokeSafely(); } return; @@ -438,7 +438,7 @@ namespace Dalamud.Interface if (this.lastFrameUiHideState) { this.lastFrameUiHideState = false; - this.ShowUi?.Raise(); + this.ShowUi?.InvokeSafely(); } if (!this.interfaceManager.FontsReady) @@ -471,7 +471,7 @@ namespace Dalamud.Interface try { - this.Draw?.Raise(); + this.Draw?.InvokeSafely(); } catch (Exception ex) { @@ -504,17 +504,17 @@ namespace Dalamud.Interface private void OnBuildFonts() { - this.BuildFonts?.Raise(); + this.BuildFonts?.InvokeSafely(); } private void OnAfterBuildFonts() { - this.AfterBuildFonts?.Raise(); + this.AfterBuildFonts?.InvokeSafely(); } private void OnResizeBuffers() { - this.ResizeBuffers?.Raise(); + this.ResizeBuffers?.InvokeSafely(); } } } diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index a5b235635..19e89b2d2 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -1262,14 +1262,14 @@ internal partial class PluginManager : IDisposable, IServiceType { this.DetectAvailablePluginUpdates(); - this.OnAvailablePluginsChanged?.Raise(); + this.OnAvailablePluginsChanged?.InvokeSafely(); } private void NotifyInstalledPluginsChanged() { this.DetectAvailablePluginUpdates(); - this.OnInstalledPluginsChanged?.Raise(); + this.OnInstalledPluginsChanged?.InvokeSafely(); } private static class Locs diff --git a/Dalamud/Utility/EventHandlerExtensions.cs b/Dalamud/Utility/EventHandlerExtensions.cs index 8812034ef..f07b46d10 100644 --- a/Dalamud/Utility/EventHandlerExtensions.cs +++ b/Dalamud/Utility/EventHandlerExtensions.cs @@ -20,14 +20,14 @@ namespace Dalamud.Utility /// The EventHandler in question. /// Default sender for Invoke equivalent. /// Default EventArgs for Invoke equivalent. - public static void Raise(this EventHandler eh, object sender, EventArgs e) + public static void InvokeSafely(this EventHandler eh, object sender, EventArgs e) { if (eh == null) return; foreach (var handler in eh.GetInvocationList().Cast()) { - HandleRaise(() => handler(sender, e)); + HandleInvoke(() => handler(sender, e)); } } @@ -39,14 +39,14 @@ namespace Dalamud.Utility /// Default sender for Invoke equivalent. /// Default EventArgs for Invoke equivalent. /// Type of EventArgs. - public static void Raise(this EventHandler eh, object sender, T e) + public static void InvokeSafely(this EventHandler eh, object sender, T e) { if (eh == null) return; foreach (var handler in eh.GetInvocationList().Cast>()) { - HandleRaise(() => handler(sender, e)); + HandleInvoke(() => handler(sender, e)); } } @@ -55,14 +55,14 @@ namespace Dalamud.Utility /// of a thrown Exception inside of an invocation. /// /// The Action in question. - public static void Raise(this Action act) + public static void InvokeSafely(this Action act) { if (act == null) return; foreach (var action in act.GetInvocationList().Cast()) { - HandleRaise(action); + HandleInvoke(action); } } @@ -72,18 +72,18 @@ namespace Dalamud.Utility /// /// The OnUpdateDelegate in question. /// Framework to be passed on to OnUpdateDelegate. - public static void Raise(this OnUpdateDelegate updateDelegate, Framework framework) + public static void InvokeSafely(this OnUpdateDelegate updateDelegate, Framework framework) { if (updateDelegate == null) return; foreach (var action in updateDelegate.GetInvocationList().Cast()) { - HandleRaise(() => action(framework)); + HandleInvoke(() => action(framework)); } } - private static void HandleRaise(Action act) + private static void HandleInvoke(Action act) { try {