From 1fab50435233d2f1e8c141965dabf293b192dd9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ne=C3=9Flauer?= Date: Sun, 8 Nov 2026 14:42:52 +0100 Subject: [PATCH] Run mod callbacks on KSA 2026.11.10.5801 - Call the StarMapAllModsLoaded methods without arguments, because ModLibrary.LoadAll has an optional parameter now - Hook StarMapImmediateLoad to Mod.LoadSettings when Mod.PrepareSystems is gone, and skip the callback with a warning when KSA has neither - Add the using for the NativeList extension that moved to Brutal.Collections --- StarMap.Core/ModRepository/RuntimeMod.cs | 12 ++++++++++-- StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/StarMap.Core/ModRepository/RuntimeMod.cs b/StarMap.Core/ModRepository/RuntimeMod.cs index 62bf7a8..d4d4961 100644 --- a/StarMap.Core/ModRepository/RuntimeMod.cs +++ b/StarMap.Core/ModRepository/RuntimeMod.cs @@ -162,14 +162,22 @@ public bool InitializeMod(ModRegistry modRegistry, IPatchManager patchManager, I var allModsLoadedPatch = patchManager.RegisterStaticVoidPatch(IPatchService.PatchType.Postfix, this, typeof(KSA.ModLibrary).GetMethod(nameof(ModLibrary.LoadAll))!, args => { - classMethod.Invoke(modObject, args); + classMethod.Invoke(modObject, []); return true; }); Patches.Add(allModsLoadedPatch); break; case StarMapImmediateLoadAttribute: - var immediateLoadPatch = patchManager.RegisterInstanceVoidPatch(IPatchService.PatchType.Prefix, this, typeof(KSA.Mod).GetMethod(nameof(Mod.PrepareSystems))!, + // KSA 2026.11.10.5801 removed Mod.PrepareSystems, and ModLibrary.PrepareAll now calls Mod.LoadSettings at its place. + var immediateLoadTarget = typeof(KSA.Mod).GetMethod("PrepareSystems") ?? typeof(KSA.Mod).GetMethod(nameof(Mod.LoadSettings)); + if (immediateLoadTarget is null) + { + Console.WriteLine($"StarMap warning: 'StarMap - {ModId} uses StarMapImmediateLoad, but KSA has no method to hook it to'"); + break; + } + + var immediateLoadPatch = patchManager.RegisterInstanceVoidPatch(IPatchService.PatchType.Prefix, this, immediateLoadTarget, (args, mod) => { if (mod.Id.Equals(ModId)) diff --git a/StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs b/StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs index 59d904b..4258d86 100644 --- a/StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs +++ b/StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs @@ -1,4 +1,5 @@ -using Brutal.GlfwApi; +using Brutal.Collections; +using Brutal.GlfwApi; using Brutal.ImGuiApi; using Brutal.VulkanApi; using Brutal.VulkanApi.Abstractions;