diff --git a/MosswartMassacre/DecalHarmonyClean.cs b/MosswartMassacre/DecalHarmonyClean.cs index 5a6e740..0bcdf23 100644 --- a/MosswartMassacre/DecalHarmonyClean.cs +++ b/MosswartMassacre/DecalHarmonyClean.cs @@ -62,9 +62,9 @@ namespace MosswartMassacre // PATHWAY 2: Target Host.Actions.AddChatText (what our plugin uses) PatchHostActions(); } - catch + catch (Exception ex) { - // Only log if completely unable to apply any patches + AddDebugLog($"ApplyDecalPatches failed: {ex.Message}"); } } @@ -92,13 +92,15 @@ namespace MosswartMassacre { ApplySinglePatch(method, prefixMethodName); } - catch + catch (Exception ex) { + AddDebugLog($"PatchHooksWrapper single patch failed ({prefixMethodName}): {ex.Message}"); } } } - catch + catch (Exception ex) { + AddDebugLog($"PatchHooksWrapper failed: {ex.Message}"); } } @@ -139,16 +141,18 @@ namespace MosswartMassacre { ApplySinglePatch(method, prefixMethodName); } - catch + catch (Exception ex) { + AddDebugLog($"PatchHostActions single patch failed ({prefixMethodName}): {ex.Message}"); } } - + // PATHWAY 3: Try to patch at PluginHost level PatchPluginHost(); } - catch + catch (Exception ex) { + AddDebugLog($"PatchHostActions failed: {ex.Message}"); } } @@ -159,36 +163,31 @@ namespace MosswartMassacre { try { - // Try to patch CoreManager.Current.Actions if it's different - try + var coreActions = CoreManager.Current?.Actions; + if (coreActions != null && coreActions != PluginCore.MyHost?.Actions) { - var coreActions = CoreManager.Current?.Actions; - if (coreActions != null && coreActions != PluginCore.MyHost?.Actions) + var coreActionsMethods = coreActions.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance) + .Where(m => m.Name == "AddChatText" || m.Name == "AddChatTextRaw" || m.Name == "AddStatusText").ToArray(); + + foreach (var method in coreActionsMethods) { - var coreActionsMethods = coreActions.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance) - .Where(m => m.Name == "AddChatText" || m.Name == "AddChatTextRaw" || m.Name == "AddStatusText").ToArray(); - - foreach (var method in coreActionsMethods) + var parameters = method.GetParameters(); + + try { - var parameters = method.GetParameters(); - - try - { - string prefixMethodName = "AddChatTextPrefixCore" + parameters.Length; - ApplySinglePatch(method, prefixMethodName); - } - catch - { - } + string prefixMethodName = "AddChatTextPrefixCore" + parameters.Length; + ApplySinglePatch(method, prefixMethodName); + } + catch (Exception ex) + { + AddDebugLog($"PatchPluginHost single patch failed: {ex.Message}"); } } } - catch - { - } } - catch + catch (Exception ex) { + AddDebugLog($"PatchPluginHost failed: {ex.Message}"); } } @@ -200,9 +199,9 @@ namespace MosswartMassacre try { // Get our prefix method - var prefixMethod = typeof(DecalPatchMethods).GetMethod(prefixMethodName, + var prefixMethod = typeof(DecalPatchMethods).GetMethod(prefixMethodName, BindingFlags.Static | BindingFlags.Public); - + if (prefixMethod != null) { // Use UtilityBelt's exact approach @@ -210,8 +209,9 @@ namespace MosswartMassacre patchesApplied = true; } } - catch + catch (Exception ex) { + AddDebugLog($"ApplySinglePatch failed ({prefixMethodName}): {ex.Message}"); } } @@ -244,8 +244,9 @@ namespace MosswartMassacre } patchesApplied = false; } - catch + catch (Exception ex) { + AddDebugLog($"Cleanup failed: {ex.Message}"); } } @@ -390,8 +391,9 @@ namespace MosswartMassacre Task.Run(() => WebSocket.SendChatTextAsync(color, text)); } } - catch + catch (Exception ex) { + DecalHarmonyClean.AddDebugLog($"ProcessInterceptedMessage failed: {ex.Message}"); } } diff --git a/MosswartMassacre/PluginCore.cs b/MosswartMassacre/PluginCore.cs index a7d971e..31e42a8 100644 --- a/MosswartMassacre/PluginCore.cs +++ b/MosswartMassacre/PluginCore.cs @@ -1,13 +1,9 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Drawing; using System.Globalization; using System.Linq; using System.Net; using System.Runtime.InteropServices; -using System.Text; -using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Timers; using Decal.Adapter; diff --git a/MosswartMassacre/VtankControl.cs b/MosswartMassacre/VtankControl.cs index 7b5e4d6..4bee425 100644 --- a/MosswartMassacre/VtankControl.cs +++ b/MosswartMassacre/VtankControl.cs @@ -72,9 +72,9 @@ namespace MosswartMassacre return 0; } } - catch + catch (Exception ex) { - // Swallow any errors and signal failure + PluginCore.WriteToChat($"[VTank] SetSetting error ({setting}): {ex.Message}"); return 0; } diff --git a/MosswartMassacre/bin/Release/MosswartMassacre.dll b/MosswartMassacre/bin/Release/MosswartMassacre.dll index e789944..334302d 100644 Binary files a/MosswartMassacre/bin/Release/MosswartMassacre.dll and b/MosswartMassacre/bin/Release/MosswartMassacre.dll differ