From 9867d6f201646a95b266a0e20169f00309716751 Mon Sep 17 00:00:00 2001 From: xen-42 Date: Thu, 26 Dec 2024 13:57:12 -0500 Subject: [PATCH] Fix introskipper breaking on 1.5.4 (Epic store version) --- .../IntroSkipper/SplashControllerPatcher.cs | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Winch.Examples/IntroSkipper/SplashControllerPatcher.cs b/Winch.Examples/IntroSkipper/SplashControllerPatcher.cs index 26a74cee..c027dcdb 100644 --- a/Winch.Examples/IntroSkipper/SplashControllerPatcher.cs +++ b/Winch.Examples/IntroSkipper/SplashControllerPatcher.cs @@ -1,16 +1,36 @@ -using HarmonyLib; +using System; +using HarmonyLib; using Winch.Core; namespace IntroSkipper; -[HarmonyPatch(typeof(SplashController))] -[HarmonyPatch(nameof(SplashController.OnEnable))] +[HarmonyPatch] internal static class SplashControllerPatcher { - public static bool Prefix() + [HarmonyPrefix] + [HarmonyPatch(typeof(SceneLoader), nameof(SceneLoader.ShouldShowSplashScreen))] + public static bool SceneLoader_ShouldShowSplashScreen(SceneLoader __instance, ref bool __result) + { + // Base game checks for save files here without null checking + __result = false; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(SplashController), nameof(SplashController.OnEnable))] + public static bool SplashController_OnEnable() { WinchCore.Log.Info("Skipping Splash Screen..."); - GameManager.Instance.Loader.LoadStartupFromSplash(); + try + { + GameManager.Instance.Loader.LoadStartupFromSplash(); + } + catch (Exception e) + { + // version 1.5.4 made it throw an exception before, let's keep this try-catch just in case (would result in a black screen that bricks the game) + WinchCore.Log.Error(e); + } + return false; } } \ No newline at end of file