Skip to content

Commit

Permalink
feat: add patch exception handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Mar 23, 2024
1 parent c5237e6 commit 9e6449a
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Osu.Patcher.Hook/Patches/PatchEnableRelaxComboBreakSound.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
Expand Down Expand Up @@ -48,4 +50,15 @@ internal class PatchEnableRelaxComboBreakSound : BasePatch
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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}");
}
}
}
13 changes: 13 additions & 0 deletions Osu.Patcher.Hook/Patches/PatchEnableRelaxFailing.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
Expand Down Expand Up @@ -46,4 +48,15 @@ internal class PatchEnableRelaxFailing : BasePatch
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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}");
}
}
}
13 changes: 13 additions & 0 deletions Osu.Patcher.Hook/Patches/PatchEnableRelaxLowHpGlow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
Expand Down Expand Up @@ -60,4 +62,15 @@ internal class PatchEnableRelaxLowHpGlow : BasePatch
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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}");
}
}
}
13 changes: 13 additions & 0 deletions Osu.Patcher.Hook/Patches/PatchEnableRelaxMisses.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
Expand Down Expand Up @@ -49,4 +51,15 @@ internal class PatchEnableRelaxMisses : BasePatch
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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}");
}
}
}
12 changes: 12 additions & 0 deletions Osu.Patcher.Hook/Patches/PatchFixDoubleSkipping.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
Expand Down Expand Up @@ -52,4 +53,15 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
inst => 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}");
}
}
}
13 changes: 13 additions & 0 deletions Osu.Patcher.Hook/Patches/PatchFixNoGroupSorting.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;
using HarmonyLib;
Expand Down Expand Up @@ -126,4 +128,15 @@ private static IEnumerable<CodeInstruction> 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}");
}
}
}
13 changes: 13 additions & 0 deletions Osu.Patcher.Hook/Patches/PatchOsuDirect.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;
using HarmonyLib;
Expand Down Expand Up @@ -56,4 +58,15 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(Ldc_I4_8),
}
);

[UsedImplicitly]
[HarmonyFinalizer]
[SuppressMessage("ReSharper", "InconsistentNaming")]
private static void Finalizer(Exception? __exception)
{
if (__exception != null)
{
Console.WriteLine($"Exception due to {nameof(PatchOsuDirect)}: {__exception}");
}
}
}

0 comments on commit 9e6449a

Please sign in to comment.