Add fix for durability errors while connecting to server

This commit is contained in:
NGnius (Graham) 2020-12-30 19:36:53 -05:00
parent 425afa1c60
commit ed99fa26f2
2 changed files with 72 additions and 1 deletions

View file

@ -23,6 +23,7 @@ namespace CLre.Fixes
HarmonyPatch, HarmonyPatch,
Initialiser, Initialiser,
Workaround, Workaround,
API,
Debug Debug
} }
@ -106,7 +107,10 @@ namespace CLre.Fixes
sb.AppendFormat("[TARGET: {0}] ", target.FullName); sb.AppendFormat("[TARGET: {0}] ", target.FullName);
} }
sb.AppendFormat("[ID: {0}] ", id); sb.AppendFormat("[ID: {0}] ", id);
sb.AppendFormat("({0}M/{1}P/{2}I/{3}W/{4}D/{5}T)", bugfixTypeCount[(byte) BugfixType.Miscellaneous], bugfixTypeCount[(byte) BugfixType.HarmonyPatch], bugfixTypeCount[(byte) BugfixType.Initialiser], bugfixTypeCount[(byte) BugfixType.Workaround], bugfixTypeCount[(byte) BugfixType.Debug], total); sb.AppendFormat("({0}M/{1}P/{2}I/{3}W/{4}A/{5}D/{6}T)",
bugfixTypeCount[(byte) BugfixType.Miscellaneous], bugfixTypeCount[(byte) BugfixType.HarmonyPatch],
bugfixTypeCount[(byte) BugfixType.Initialiser], bugfixTypeCount[(byte) BugfixType.Workaround],
bugfixTypeCount[(byte) BugfixType.API], bugfixTypeCount[(byte) BugfixType.Debug], total);
return sb.ToString(); return sb.ToString();
} }
} }

View file

@ -0,0 +1,67 @@
using System.Reflection;
using HarmonyLib;
namespace CLre.Fixes
{
[Bugfix(name = "ClientDurabilityNodeErrorRemover",
description = "Disable OnServerNotifyChange() callback when it will error",
more = "https://trello.com/c/YT3VbXpZ/15-durability-log-error",
component = BugfixType.API, id = 3)]
public static class DurabilityNodeErrorRemover
{
public static void Disable() => DurabilityGUIEngineClient_OnServerNotifyChange_Patch.IsDisabled = true;
public static void Enable() => DurabilityGUIEngineClient_OnServerNotifyChange_Patch.IsDisabled = false;
}
[Bugfix(name = "ClientDurabilityNodeErrorRemover",
description = "Disable OnServerNotifyChange() callback when it will error",
more = "https://trello.com/c/YT3VbXpZ/15-durability-log-error",
component = BugfixType.HarmonyPatch, id = 3)]
[HarmonyPatch]
class DurabilityGUIEngineClient_OnServerNotifyChange_Patch
{
internal static bool AnyDurabilityClientNodeExists = false;
internal static bool IsDisabled = false;
[HarmonyPrefix]
public static bool BeforeMethodCall()
{
#if DEBUG
API.Utility.Logging.MetaLog("Intercepting DurabilityGUIEngineClient.OnServerNotifyChange()");
#endif
return AnyDurabilityClientNodeExists || IsDisabled;
}
[HarmonyTargetMethod]
public static MethodBase Target()
{
return AccessTools.Method("Game.Durability.Client.DurabilityGUIEngineClient:OnServerNotifyChange");
}
}
[Bugfix(name = "ClientDurabilityNodeErrorRemover",
description = "Disable OnServerNotifyChange() callback when it will error",
more = "https://trello.com/c/YT3VbXpZ/15-durability-log-error",
component = BugfixType.HarmonyPatch, id = 3)]
[HarmonyPatch]
class DurabilityGUIEngineClientSplit_Add_Patch
{
[HarmonyPrefix]
public static void BeforeMethodCall()
{
#if DEBUG
API.Utility.Logging.MetaLog("Intercepting DurabilityGUIEngineClientSplit.Add()");
#endif
DurabilityGUIEngineClient_OnServerNotifyChange_Patch.AnyDurabilityClientNodeExists = true;
}
[HarmonyTargetMethod]
public static MethodBase Target()
{
return AccessTools.Method("Game.Durability.Client.DurabilityGuiEngineClientSplit:Add", new []{ AccessTools.TypeByName("Game.Durability.Client.DurabilityClientNode")});
}
}
}