diff --git a/1.3/Assemblies/BetterLoading.dll b/1.3/Assemblies/BetterLoading.dll index e3fd870..af1697f 100644 Binary files a/1.3/Assemblies/BetterLoading.dll and b/1.3/Assemblies/BetterLoading.dll differ diff --git a/About/Manifest.xml b/About/Manifest.xml index dfcb520..7f755b9 100755 --- a/About/Manifest.xml +++ b/About/Manifest.xml @@ -1,7 +1,7 @@ BetterLoading - 3.1.3.0 + 3.1.3.1
  • Core >= 1.0
  • Startupimpact
  • diff --git a/Source/Compat/HugsLib/StageHugsLibInit.cs b/Source/Compat/HugsLib/StageHugsLibInit.cs index f412227..dc14ea2 100755 --- a/Source/Compat/HugsLib/StageHugsLibInit.cs +++ b/Source/Compat/HugsLib/StageHugsLibInit.cs @@ -16,11 +16,10 @@ public class StageHugsLibInit : LoadingStage private static List? _children; private static int _numChildrenInitialized; - private static int _numChildrenCheckedForUpdate; private static int _numChildrenDefLoaded; private static object? _currentChildMod; - private static Harmony? hInstance; + private static Harmony hInstance; private static PropertyInfo _modIdentifierProperty; @@ -42,27 +41,23 @@ public override string GetStageName() if (_currentChildMod != null) { - if (_numChildrenInitialized < _children.Count) + if (_numChildrenInitialized < _children!.Count) return $"Initializing child mods: {_numChildrenInitialized} / {_children}: {_modIdentifierProperty.GetValue(_currentChildMod, null)}"; - if (_numChildrenCheckedForUpdate < _children.Count) - return $"Checking for mod updates: {_numChildrenCheckedForUpdate} / {_children}: {_modIdentifierProperty.GetValue(_currentChildMod, null)}"; - if (_numChildrenDefLoaded < _children.Count) return $"Invoking post-load callbacks: {_numChildrenDefLoaded} / {_children}: {_modIdentifierProperty.GetValue(_currentChildMod, null)}"; } - return _numChildrenDefLoaded == _children.Count ? "Finishing up" : null; + return _numChildrenDefLoaded == _children!.Count ? "Finishing up" : null; } public override int GetCurrentProgress() { if (_done) return GetMaximumProgress() + 1; - + var result = _hasEnumeratedChildren ? 1 : 0; result += _numChildrenInitialized; - result += _numChildrenCheckedForUpdate; result += _numChildrenDefLoaded; // result += _done ? 1 : 0; @@ -87,19 +82,19 @@ public override void DoPatching(Harmony instance) var hlAssembly = LoadedModManager.RunningMods.First(m => m.Name == "HugsLib").assemblies.loadedAssemblies.Find(a => a.GetName().Name == "HugsLib"); - var controllerType = hlAssembly.GetTypes().First(t => t.Name == "HugsLibController"); - var updateFeatureManagerType = hlAssembly.GetTypes().First(t => t.Name == "UpdateFeatureManager"); + var controllerType = hlAssembly.GetTypes().FirstOrDefault(t => t.Name == "HugsLibController") ?? throw new Exception("Type HugsLibController is missing"); - _modIdentifierProperty = hlAssembly.GetTypes().First(t => t.Name == "ModBase").GetProperty("ModIdentifier"); + _modIdentifierProperty = hlAssembly.GetTypes().First(t => t.Name == "ModBase").GetProperty("ModIdentifier") ?? throw new Exception("Property ModBase.ModIdentifier is missing"); - Log.Message($"[BetterLoading:HugsLib Compat] Resolved required HugsLib types as follows: Controller: {controllerType?.FullName} / Update Manager: {updateFeatureManagerType?.FullName} / Mod Identifier (Property): {_modIdentifierProperty?.Name}"); + Log.Message($"[BetterLoading:HugsLib Compat] Resolved required HugsLib types as follows: Controller: {controllerType.FullName} / Mod Identifier (Property): {_modIdentifierProperty.Name}"); - hInstance.Patch(AccessTools.Method(controllerType, "LoadReloadInitialize"), postfix: new HarmonyMethod(typeof(StageHugsLibInit), nameof(PostLRI))); - hInstance.Patch(AccessTools.Method(controllerType, "EnumerateChildMods"), postfix: new HarmonyMethod(typeof(StageHugsLibInit), nameof(PostEnumerateChildren))); hInstance.Patch( - AccessTools.Method(updateFeatureManagerType, "InspectActiveMod"), - new HarmonyMethod(typeof(StageHugsLibInit), nameof(PreUpdateCheck)), - new HarmonyMethod(typeof(StageHugsLibInit), nameof(PostUpdateCheck)) + AccessTools.Method(controllerType, "LoadReloadInitialize") ?? throw new Exception("Method HugsLibController.LoadReloadInitialize is missing"), + postfix: new HarmonyMethod(typeof(StageHugsLibInit), nameof(PostLRI)) + ); + hInstance.Patch( + AccessTools.Method(controllerType, "EnumerateChildMods") ?? throw new Exception("Method HugsLibController.EnumerateChildMods is missing"), + postfix: new HarmonyMethod(typeof(StageHugsLibInit), nameof(PostEnumerateChildren)) ); Log.Message("[BetterLoading:HugsLib Compat] Successfully blind-patched HugsLib."); @@ -146,18 +141,6 @@ public static void PostChildInit() BetterLoadingApi.DispatchChange(inst); } - public static void PreUpdateCheck(string modId) - { - _currentChildMod = _children?.Find(m => (string) _modIdentifierProperty.GetValue(m, null) == modId); - BetterLoadingApi.DispatchChange(inst); - } - - public static void PostUpdateCheck() - { - _numChildrenCheckedForUpdate++; - BetterLoadingApi.DispatchChange(inst); - } - public static void PreDefsLoaded(object __instance) { if (__instance.GetType().GetProperty("ModIdentifier") == null) return; diff --git a/Source/Stage/InitialLoad/9StageRunPostFinalizeCallbacks.cs b/Source/Stage/InitialLoad/9StageRunPostFinalizeCallbacks.cs index d00d87b..9ff70cf 100755 --- a/Source/Stage/InitialLoad/9StageRunPostFinalizeCallbacks.cs +++ b/Source/Stage/InitialLoad/9StageRunPostFinalizeCallbacks.cs @@ -128,7 +128,6 @@ public static bool PreExecToExecWhenFinished(List ___toExecuteWhenFinish Thread.Sleep(0); GlobalTimingData.TicksFinishedPostFinalize = DateTime.UtcNow.Ticks; - Log.Message("Finished post-finalize at " + GlobalTimingData.TicksFinishedPostFinalize); _finishedExecuting = true; }, null, true, null);