2024-02-08 12:01:49 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2024-02-07 18:15:18 +08:00
|
|
|
using HarmonyLib;
|
|
|
|
using Process;
|
|
|
|
using Util;
|
|
|
|
|
|
|
|
namespace AquaMai.Fix
|
|
|
|
{
|
|
|
|
/**
|
2024-02-08 12:01:49 +08:00
|
|
|
* Fix character selection crashing due to missing character data
|
2024-02-07 18:15:18 +08:00
|
|
|
*/
|
2024-02-08 12:04:15 +08:00
|
|
|
public class FixCharaCrash
|
|
|
|
{
|
2024-02-07 18:15:18 +08:00
|
|
|
// Check if the return is null. If it is, make up a color
|
|
|
|
[HarmonyPostfix]
|
|
|
|
[HarmonyPatch(typeof(CharacterSelectProces), "GetMapColorData")]
|
2024-02-08 12:04:15 +08:00
|
|
|
public static void GetMapColorData(ref CharacterSelectProces __instance, ref CharacterMapColorData __result)
|
|
|
|
{
|
|
|
|
if (__result != null) return;
|
2024-02-08 12:01:49 +08:00
|
|
|
|
2024-02-07 18:15:18 +08:00
|
|
|
// 1 is a color that definitely exists
|
2024-02-08 12:04:15 +08:00
|
|
|
if (MapMaster.GetSlotData(1) == null)
|
|
|
|
{
|
2024-02-07 18:15:18 +08:00
|
|
|
MapMaster.GetSlotData(1).Load();
|
|
|
|
}
|
|
|
|
__result = MapMaster.GetSlotData(1);
|
|
|
|
}
|
2024-02-08 12:01:49 +08:00
|
|
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
[HarmonyPatch(typeof(Monitor.CommonMonitor), "SetCharacterSlot", new Type[] { typeof(MessageCharactorInfomationData) })]
|
2024-02-08 12:04:15 +08:00
|
|
|
public static bool SetCharacterSlot(ref MessageCharactorInfomationData data, Dictionary<int, CharacterSlotData> ____characterSlotData)
|
|
|
|
{
|
|
|
|
if (!____characterSlotData.ContainsKey(data.MapKey))
|
|
|
|
{
|
2024-02-08 12:01:49 +08:00
|
|
|
Console.Log($"Could not get CharacterSlotData for character [Index={data.Index}, MapKey={data.MapKey}], ignoring...");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2024-02-07 18:15:18 +08:00
|
|
|
}
|
2024-02-08 12:01:49 +08:00
|
|
|
}
|