From 879bc15e03d3fb2342cd7a6654a423d1b960e169 Mon Sep 17 00:00:00 2001 From: KlaasWhite Date: Sun, 8 Nov 2026 16:58:46 +0100 Subject: [PATCH] Ensure no exceptions shutdown --- StarMap.Core/Patches/PatchManager.cs | 15 ++++++++++----- StarMap/Properties/launchSettings.json | 8 ++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 StarMap/Properties/launchSettings.json diff --git a/StarMap.Core/Patches/PatchManager.cs b/StarMap.Core/Patches/PatchManager.cs index c6ee34e..4edd0bc 100644 --- a/StarMap.Core/Patches/PatchManager.cs +++ b/StarMap.Core/Patches/PatchManager.cs @@ -132,9 +132,9 @@ public static bool PrefixPatchEntryPoint( MethodBase __originalMethod, object[] __args, object? __instance, - ref T __result) + ref object? __result) { - object? result = __result; + var result = __result; var outcome = _instance?.PatchEntryPoint(HarmonyPatchType.Prefix, __originalMethod, __args, __instance, ref result) ?? true; __result = IPatchCallback.CastValue(result, nameof(__result)); return outcome; @@ -154,9 +154,9 @@ public static void PostfixPatchEntryPoint( MethodBase __originalMethod, object[] __args, object? __instance, - ref T __result) + ref object? __result) { - object? result = __result; + var result = __result; _instance?.PatchEntryPoint(HarmonyPatchType.Postfix, __originalMethod, __args, __instance, ref result); __result = IPatchCallback.CastValue(result, nameof(__result)); } @@ -454,7 +454,12 @@ public void Dispose() if (Interlocked.Exchange(ref _disposed, 1) != 0) return; - _patch.UnregisterPatch(this); + try + { + _patch.UnregisterPatch(this); + } + catch { } + } } } diff --git a/StarMap/Properties/launchSettings.json b/StarMap/Properties/launchSettings.json new file mode 100644 index 0000000..80ebb9d --- /dev/null +++ b/StarMap/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "StarMap": { + "commandName": "Project", + "commandLineArgs": "-InstancePath \"C:\\Users\\klaas\\AppData\\Local\\Borea\\Instances\\6cc3f568-20c3-4592-9df6-faaf6448ea8e\"" + } + } +} \ No newline at end of file