From 9e6449a2f8df1f0a86f3836188d1255f683e6542 Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Sat, 23 Mar 2024 15:50:58 -0700 Subject: [PATCH] feat: add patch exception handlers --- .../Patches/PatchEnableRelaxComboBreakSound.cs | 13 +++++++++++++ Osu.Patcher.Hook/Patches/PatchEnableRelaxFailing.cs | 13 +++++++++++++ .../Patches/PatchEnableRelaxLowHpGlow.cs | 13 +++++++++++++ Osu.Patcher.Hook/Patches/PatchEnableRelaxMisses.cs | 13 +++++++++++++ Osu.Patcher.Hook/Patches/PatchFixDoubleSkipping.cs | 12 ++++++++++++ Osu.Patcher.Hook/Patches/PatchFixNoGroupSorting.cs | 13 +++++++++++++ Osu.Patcher.Hook/Patches/PatchOsuDirect.cs | 13 +++++++++++++ 7 files changed, 90 insertions(+) diff --git a/Osu.Patcher.Hook/Patches/PatchEnableRelaxComboBreakSound.cs b/Osu.Patcher.Hook/Patches/PatchEnableRelaxComboBreakSound.cs index 7e46072..16f3c4e 100644 --- a/Osu.Patcher.Hook/Patches/PatchEnableRelaxComboBreakSound.cs +++ b/Osu.Patcher.Hook/Patches/PatchEnableRelaxComboBreakSound.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Reflection.Emit; @@ -48,4 +50,15 @@ internal class PatchEnableRelaxComboBreakSound : BasePatch [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) => NoopAfterSignature(instructions, Signature.Take(Signature.Length - 4).ToArray(), 4); + + [UsedImplicitly] + [HarmonyFinalizer] + [SuppressMessage("ReSharper", "InconsistentNaming")] + private static void Finalizer(Exception? __exception) + { + if (__exception != null) + { + Console.WriteLine($"Exception due to {nameof(PatchEnableRelaxComboBreakSound)}: {__exception}"); + } + } } \ No newline at end of file diff --git a/Osu.Patcher.Hook/Patches/PatchEnableRelaxFailing.cs b/Osu.Patcher.Hook/Patches/PatchEnableRelaxFailing.cs index ce36747..de9eddb 100644 --- a/Osu.Patcher.Hook/Patches/PatchEnableRelaxFailing.cs +++ b/Osu.Patcher.Hook/Patches/PatchEnableRelaxFailing.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Reflection.Emit; @@ -46,4 +48,15 @@ internal class PatchEnableRelaxFailing : BasePatch [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) => NoopAfterSignature(instructions, Signature.Take(Signature.Length - 4).ToArray(), 4); + + [UsedImplicitly] + [HarmonyFinalizer] + [SuppressMessage("ReSharper", "InconsistentNaming")] + private static void Finalizer(Exception? __exception) + { + if (__exception != null) + { + Console.WriteLine($"Exception due to {nameof(PatchEnableRelaxFailing)}: {__exception}"); + } + } } \ No newline at end of file diff --git a/Osu.Patcher.Hook/Patches/PatchEnableRelaxLowHpGlow.cs b/Osu.Patcher.Hook/Patches/PatchEnableRelaxLowHpGlow.cs index 11f30bf..1f6f774 100644 --- a/Osu.Patcher.Hook/Patches/PatchEnableRelaxLowHpGlow.cs +++ b/Osu.Patcher.Hook/Patches/PatchEnableRelaxLowHpGlow.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Reflection.Emit; @@ -60,4 +62,15 @@ internal class PatchEnableRelaxLowHpGlow : BasePatch [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) => NoopAfterSignature(instructions, Signature.Take(Signature.Length - 4).ToArray(), 4); + + [UsedImplicitly] + [HarmonyFinalizer] + [SuppressMessage("ReSharper", "InconsistentNaming")] + private static void Finalizer(Exception? __exception) + { + if (__exception != null) + { + Console.WriteLine($"Exception due to {nameof(PatchEnableRelaxLowHpGlow)}: {__exception}"); + } + } } \ No newline at end of file diff --git a/Osu.Patcher.Hook/Patches/PatchEnableRelaxMisses.cs b/Osu.Patcher.Hook/Patches/PatchEnableRelaxMisses.cs index b1a30bc..9d396a1 100644 --- a/Osu.Patcher.Hook/Patches/PatchEnableRelaxMisses.cs +++ b/Osu.Patcher.Hook/Patches/PatchEnableRelaxMisses.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Reflection.Emit; @@ -49,4 +51,15 @@ internal class PatchEnableRelaxMisses : BasePatch [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) => NoopAfterSignature(instructions, Signature.Take(Signature.Length - 4).ToArray(), 4); + + [UsedImplicitly] + [HarmonyFinalizer] + [SuppressMessage("ReSharper", "InconsistentNaming")] + private static void Finalizer(Exception? __exception) + { + if (__exception != null) + { + Console.WriteLine($"Exception due to {nameof(PatchEnableRelaxMisses)}: {__exception}"); + } + } } \ No newline at end of file diff --git a/Osu.Patcher.Hook/Patches/PatchFixDoubleSkipping.cs b/Osu.Patcher.Hook/Patches/PatchFixDoubleSkipping.cs index 8ad0231..af33d11 100644 --- a/Osu.Patcher.Hook/Patches/PatchFixDoubleSkipping.cs +++ b/Osu.Patcher.Hook/Patches/PatchFixDoubleSkipping.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Reflection; @@ -52,4 +53,15 @@ private static IEnumerable Transpiler(IEnumerable inst.OperandIs(10000), inst => inst.operand = 0 ); + + [UsedImplicitly] + [HarmonyFinalizer] + [SuppressMessage("ReSharper", "InconsistentNaming")] + private static void Finalizer(Exception? __exception) + { + if (__exception != null) + { + Console.WriteLine($"Exception due to {nameof(PatchFixDoubleSkipping)}: {__exception}"); + } + } } \ No newline at end of file diff --git a/Osu.Patcher.Hook/Patches/PatchFixNoGroupSorting.cs b/Osu.Patcher.Hook/Patches/PatchFixNoGroupSorting.cs index dafb0af..32ea4a6 100644 --- a/Osu.Patcher.Hook/Patches/PatchFixNoGroupSorting.cs +++ b/Osu.Patcher.Hook/Patches/PatchFixNoGroupSorting.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Reflection.Emit; using HarmonyLib; @@ -126,4 +128,15 @@ private static IEnumerable Transpiler( return instructions; } + + [UsedImplicitly] + [HarmonyFinalizer] + [SuppressMessage("ReSharper", "InconsistentNaming")] + private static void Finalizer(Exception? __exception) + { + if (__exception != null) + { + Console.WriteLine($"Exception due to {nameof(PatchFixNoGroupSorting)}: {__exception}"); + } + } } \ No newline at end of file diff --git a/Osu.Patcher.Hook/Patches/PatchOsuDirect.cs b/Osu.Patcher.Hook/Patches/PatchOsuDirect.cs index 3302962..966fd06 100644 --- a/Osu.Patcher.Hook/Patches/PatchOsuDirect.cs +++ b/Osu.Patcher.Hook/Patches/PatchOsuDirect.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Reflection.Emit; using HarmonyLib; @@ -56,4 +58,15 @@ private static IEnumerable Transpiler(IEnumerable