diff --git a/src/Bannerlord.LauncherEx/Patches/LauncherUIPatch.cs b/src/Bannerlord.LauncherEx/Patches/LauncherUIPatch.cs index b70b34a..dc2fb73 100644 --- a/src/Bannerlord.LauncherEx/Patches/LauncherUIPatch.cs +++ b/src/Bannerlord.LauncherEx/Patches/LauncherUIPatch.cs @@ -1,4 +1,4 @@ -using Bannerlord.LauncherEx.Helpers; +using Bannerlord.LauncherEx.Helpers; using HarmonyLib; using HarmonyLib.BUTR.Extensions; @@ -23,16 +23,20 @@ public static bool Enable(Harmony harmony) postfix: AccessTools2.DeclaredMethod(typeof(LauncherUIPatch), nameof(InitializePostfix))); if (!res1) return false; - var res2 = harmony.TryPatch( - AccessTools2.DeclaredMethod(typeof(LauncherUI), "Update"), - postfix: AccessTools2.DeclaredMethod(typeof(LauncherUIPatch), nameof(UpdatePostfix))); - if (!res2) return false; - + // Patch the cleanup point before installing BUTRInputManager. + // If LauncherUI.AdditionalArgs was removed or renamed in this game version, + // installing BUTRInputManager without a cleanup path would leave it active + // when the game starts, causing a native crash (e.g. at GauntletVideoPlaybackScreen). var res3 = harmony.TryPatch( AccessTools2.DeclaredPropertyGetter(typeof(LauncherUI), "AdditionalArgs"), postfix: AccessTools2.DeclaredMethod(typeof(LauncherUIPatch), nameof(AdditionalArgsPostfix))); if (!res3) return false; + var res2 = harmony.TryPatch( + AccessTools2.DeclaredMethod(typeof(LauncherUI), "Update"), + postfix: AccessTools2.DeclaredMethod(typeof(LauncherUIPatch), nameof(UpdatePostfix))); + if (!res2) return false; + return true; }