From 14bd2480ce6d4f9be6ad52d35bbaa1d839f69bf4 Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Wed, 7 Feb 2024 05:15:18 -0500 Subject: [PATCH] [+] Fix character selection crash --- AquaMai/Fix/FixCharaCrash.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 AquaMai/Fix/FixCharaCrash.cs diff --git a/AquaMai/Fix/FixCharaCrash.cs b/AquaMai/Fix/FixCharaCrash.cs new file mode 100644 index 00000000..02407fe8 --- /dev/null +++ b/AquaMai/Fix/FixCharaCrash.cs @@ -0,0 +1,28 @@ +using HarmonyLib; +using Process; +using Util; + +namespace AquaMai.Fix +{ + /** + * Fix character selection crashing because get map color returns null + */ + public class FixCharaCrash + { + // Check if the return is null. If it is, make up a color + [HarmonyPostfix] + [HarmonyPatch(typeof(CharacterSelectProces), "GetMapColorData")] + public static void GetMapColorData(ref CharacterSelectProces __instance, ref CharacterMapColorData __result) + { + if (__result != null) return; + + // 1 is a color that definitely exists + if (MapMaster.GetSlotData(1) == null) + { + MapMaster.GetSlotData(1).Load(); + } + __result = MapMaster.GetSlotData(1); + } + + } +} \ No newline at end of file