From 3131c8d5a9f6f163eebc334fe92b3e5816b7476f Mon Sep 17 00:00:00 2001 From: LeeTwentyThree <31892011+LeeTwentyThree@users.noreply.github.com> Date: Sun, 30 Jul 2023 23:50:30 -0400 Subject: [PATCH] Fixes --- .../Patchers/SMLHelperCompatibilityPatcher.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Nautilus/Patchers/SMLHelperCompatibilityPatcher.cs b/Nautilus/Patchers/SMLHelperCompatibilityPatcher.cs index 7d9dc61a..873da48f 100644 --- a/Nautilus/Patchers/SMLHelperCompatibilityPatcher.cs +++ b/Nautilus/Patchers/SMLHelperCompatibilityPatcher.cs @@ -16,6 +16,7 @@ internal class SMLHelperCompatibilityPatcher public const string SMLHarmonyInstance = "com.ahk1221.smlhelper"; // This string is both the harmony instance & plugin GUID. public const string QModManagerGUID = "QModManager.QMMLoader"; private const string SMLAssemblyName = "SMLHelper"; + private const string SMLHelperModJsonID = "SMLHelper"; private static Assembly _smlHelperAssembly; @@ -41,18 +42,14 @@ private static bool GetSMLHelperExists() if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(QModManagerGUID, out var qmodManager)) return false; var qmodServices = Assembly.GetAssembly(qmodManager.Instance.GetType()).GetType("QModManager.API.QModServices"); - if (qmodServices == null) - return false; - return (bool)AccessTools.Method(qmodServices, "ModPresent").Invoke(null, new object[] { SMLHarmonyInstance }); + var qmodServicesInstance = AccessTools.PropertyGetter(qmodServices, "Main").Invoke(null, new object[0]); + return (bool)AccessTools.Method(qmodServices, "ModPresent").Invoke(qmodServicesInstance, new object[] { SMLHelperModJsonID }); #endif } internal static void Patch(Harmony harmony) { - if (SMLHelperInstalled) - { - CoroutineHost.StartCoroutine(WaitOnSMLHelperForPatches(harmony)); - } + CoroutineHost.StartCoroutine(WaitOnSMLHelperForPatches(harmony)); } private static IEnumerator WaitOnSMLHelperForPatches(Harmony harmony) @@ -73,6 +70,11 @@ private static IEnumerator WaitOnSMLHelperForPatches(Harmony harmony) yield return null; + if (!SMLHelperInstalled) + { + yield break; + } + InternalLogger.Log("Patching SMLHelper compatibility fixes", BepInEx.Logging.LogLevel.Info); // Finally apply the patches: