mirror of https://github.com/hykilpikonna/AquaDX
Merge pull request #9 from hykilpikonna/tc21/fix-crash-slot-data-not-found
Fix crash during call to CommonMonitor.SetCharacterSlotpull/10/head
commit
e1180a9a14
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using Process;
|
||||
using Util;
|
||||
|
@ -5,7 +7,7 @@ using Util;
|
|||
namespace AquaMai.Fix
|
||||
{
|
||||
/**
|
||||
* Fix character selection crashing because get map color returns null
|
||||
* Fix character selection crashing due to missing character data
|
||||
*/
|
||||
public class FixCharaCrash
|
||||
{
|
||||
|
@ -15,7 +17,7 @@ namespace AquaMai.Fix
|
|||
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)
|
||||
{
|
||||
|
@ -23,6 +25,20 @@ namespace AquaMai.Fix
|
|||
}
|
||||
__result = MapMaster.GetSlotData(1);
|
||||
}
|
||||
|
||||
|
||||
// This is called when loading the music selection screen, to display characters on the top screen
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(Monitor.CommonMonitor), "SetCharacterSlot", new Type[] { typeof(MessageCharactorInfomationData) })]
|
||||
public static bool SetCharacterSlot(ref MessageCharactorInfomationData data, Dictionary<int, CharacterSlotData> ____characterSlotData)
|
||||
{
|
||||
// Some characters are not found in this dictionary. We simply skip loading those characters
|
||||
if (!____characterSlotData.ContainsKey(data.MapKey))
|
||||
{
|
||||
Console.Log($"Could not get CharacterSlotData for character [Index={data.Index}, MapKey={data.MapKey}], ignoring...");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue