public void CheckDetour() { if (isFirstTime && Loader.DetourInited && Loader.HarmonyDetourInited) { isFirstTime = false; DetourAfterLoad(); if (Loader.DetourInited) { DebugLog.LogToFileOnly("ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Checking detours."); List <string> list = new List <string>(); foreach (Loader.Detour current in Loader.Detours) { if (!RedirectionHelper.IsRedirected(current.OriginalMethod, current.CustomMethod)) { list.Add(string.Format("{0}.{1} with {2} parameters ({3})", new object[] { current.OriginalMethod.DeclaringType.Name, current.OriginalMethod.Name, current.OriginalMethod.GetParameters().Length, current.OriginalMethod.DeclaringType.AssemblyQualifiedName })); } } DebugLog.LogToFileOnly(string.Format("ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Detours checked. Result: {0} missing detours", list.Count)); if (list.Count > 0) { string error = "RealGasStation detected an incompatibility with another mod! You can continue playing but it's NOT recommended. RealGasStation will not work as expected. Send RealGasStation.txt to Author."; DebugLog.LogToFileOnly(error); string text = "The following methods were overriden by another mod:"; foreach (string current2 in list) { text += string.Format("\n\t{0}", current2); } DebugLog.LogToFileOnly(text); UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", text, true); } if (Loader.HarmonyDetourFailed) { string error = "RealGasStation HarmonyDetourInit is failed, Send RealGasStation.txt to Author."; DebugLog.LogToFileOnly(error); UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", error, true); } } } }
public void CheckDetour() { if (isFirstTime) { if (Loader.DetourInited && Loader.HarmonyDetourInited) { isFirstTime = false; DetourAfterLoad(); DebugLog.LogToFileOnly("ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Checking detours."); List <string> list = new List <string>(); foreach (Loader.Detour current in Loader.Detours) { if (!RedirectionHelper.IsRedirected(current.OriginalMethod, current.CustomMethod)) { list.Add(string.Format("{0}.{1} with {2} parameters ({3})", new object[] { current.OriginalMethod.DeclaringType.Name, current.OriginalMethod.Name, current.OriginalMethod.GetParameters().Length, current.OriginalMethod.DeclaringType.AssemblyQualifiedName })); } } DebugLog.LogToFileOnly(string.Format("ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Detours checked. Result: {0} missing detours", list.Count)); if (list.Count > 0) { string error = "CSURToolBox detected an incompatibility with another mod! You can continue playing but it's NOT recommended. CSURToolBox will not work as expected. Send CSURToolBox.txt to Author."; DebugLog.LogToFileOnly(error); string text = "The following methods were overriden by another mod:"; foreach (string current2 in list) { text += string.Format("\n\t{0}", current2); } DebugLog.LogToFileOnly(text); UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", text, true); } if (Loader.HarmonyDetourFailed) { string error = "CSURToolBox HarmonyDetourInit is failed, Send CSURToolBox.txt to Author."; DebugLog.LogToFileOnly(error); UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", error, true); } else { var harmony = new Harmony(HarmonyDetours.Id); var methods = harmony.GetPatchedMethods(); int i = 0; foreach (var method in methods) { var info = Harmony.GetPatchInfo(method); if (info.Owners?.Contains(HarmonyDetours.Id) == true) { DebugLog.LogToFileOnly($"Harmony patch method = {method.FullDescription()}"); if (info.Prefixes.Count != 0) { DebugLog.LogToFileOnly("Harmony patch method has PreFix"); } if (info.Postfixes.Count != 0) { DebugLog.LogToFileOnly("Harmony patch method has PostFix"); } i++; } } if (i != HarmonyPatchNum) { string error = $"CSURToolBox HarmonyDetour Patch Num is {i}, Right Num is {HarmonyPatchNum} Send CSURToolBox.txt to Author."; DebugLog.LogToFileOnly(error); UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", error, true); } } } } }