mirror of https://github.com/hykilpikonna/AquaDX
Fix crash during call to CommonMonitor.SetCharacterSlot
parent
c10085b65a
commit
fcee4d13da
|
@ -1,3 +1,5 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Process;
|
using Process;
|
||||||
using Util;
|
using Util;
|
||||||
|
@ -5,24 +7,32 @@ using Util;
|
||||||
namespace AquaMai.Fix
|
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
|
public class FixCharaCrash {
|
||||||
{
|
|
||||||
// Check if the return is null. If it is, make up a color
|
// Check if the return is null. If it is, make up a color
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(CharacterSelectProces), "GetMapColorData")]
|
[HarmonyPatch(typeof(CharacterSelectProces), "GetMapColorData")]
|
||||||
public static void GetMapColorData(ref CharacterSelectProces __instance, ref CharacterMapColorData __result)
|
public static void GetMapColorData(ref CharacterSelectProces __instance, ref CharacterMapColorData __result) {
|
||||||
{
|
if (__result != null)
|
||||||
if (__result != null) return;
|
return;
|
||||||
|
|
||||||
// 1 is a color that definitely exists
|
// 1 is a color that definitely exists
|
||||||
if (MapMaster.GetSlotData(1) == null)
|
if (MapMaster.GetSlotData(1) == null) {
|
||||||
{
|
|
||||||
MapMaster.GetSlotData(1).Load();
|
MapMaster.GetSlotData(1).Load();
|
||||||
}
|
}
|
||||||
__result = MapMaster.GetSlotData(1);
|
__result = MapMaster.GetSlotData(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(Monitor.CommonMonitor), "SetCharacterSlot", new Type[] { typeof(MessageCharactorInfomationData) })]
|
||||||
|
public static bool SetCharacterSlot(ref MessageCharactorInfomationData data, Dictionary<int, CharacterSlotData> ____characterSlotData) {
|
||||||
|
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