From aa780f7d4b5784ad2ad9444ae3e41099028411f8 Mon Sep 17 00:00:00 2001 From: Lexi Date: Thu, 12 Oct 2023 10:01:14 -0400 Subject: [PATCH 1/3] 1.5.1 patch, fixes breaking bug with loading on fresh install, as well as spurious errors in the mods list. --- SpaceWarp.Core/API/Mods/JSON/SpecVersion.cs | 1 + SpaceWarp.Core/API/Mods/PluginList.cs | 1 + SpaceWarp.Core/Backend/Modding/PluginRegister.cs | 10 +++++++--- .../LoadingActions/FunctionalLoadingActions.cs | 2 +- SpaceWarp.Core/SpaceWarpPlugin.cs | 4 +++- SpaceWarp.VersionChecking/Modules/VersionChecking.cs | 12 +++++++++++- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/SpaceWarp.Core/API/Mods/JSON/SpecVersion.cs b/SpaceWarp.Core/API/Mods/JSON/SpecVersion.cs index 6d527c15..aa4c00dc 100644 --- a/SpaceWarp.Core/API/Mods/JSON/SpecVersion.cs +++ b/SpaceWarp.Core/API/Mods/JSON/SpecVersion.cs @@ -86,6 +86,7 @@ public SpecVersion(string version = null) public static bool operator <=(SpecVersion a, SpecVersion b) => Compare(a, b) <= 0; public static bool operator >=(SpecVersion a, SpecVersion b) => Compare(a, b) >= 0; + private static int Compare(SpecVersion a, SpecVersion b) { if (a.Major != b.Major) diff --git a/SpaceWarp.Core/API/Mods/PluginList.cs b/SpaceWarp.Core/API/Mods/PluginList.cs index 97ea2079..73c7f22d 100644 --- a/SpaceWarp.Core/API/Mods/PluginList.cs +++ b/SpaceWarp.Core/API/Mods/PluginList.cs @@ -167,6 +167,7 @@ public static void Disable(string guid) public static SpaceWarpErrorDescription GetErrorDescriptor(SpaceWarpPluginDescriptor plugin) { + if (_allErroredPlugins.Any(x => x.Plugin == plugin)) { return _allErroredPlugins.First(x => x.Plugin == plugin); diff --git a/SpaceWarp.Core/Backend/Modding/PluginRegister.cs b/SpaceWarp.Core/Backend/Modding/PluginRegister.cs index 82cbe719..88d24c1c 100644 --- a/SpaceWarp.Core/Backend/Modding/PluginRegister.cs +++ b/SpaceWarp.Core/Backend/Modding/PluginRegister.cs @@ -187,9 +187,10 @@ ModInfo metadata private static string ClearPrerelease(string version) { var semver = new SemanticVersion(version); - return $"{semver.Major}.{semver.Minor}.{semver.Patch}{(semver.VersionNumbers.Count > 3 ? $".{semver.VersionNumbers[3]}" : "")}"; + return + $"{semver.Major}.{semver.Minor}.{semver.Patch}{(semver.VersionNumbers.Count > 3 ? $".{semver.VersionNumbers[3]}" : "")}"; } - + private static bool AssertMatchingVersions( SpaceWarpPluginDescriptor descriptor, BaseUnityPlugin plugin, @@ -460,7 +461,10 @@ private static void RegisterAllErroredMods() { info.Location = plugin.Key; if (PluginList.AllPlugins.Any( - x => string.Equals(x.Guid, info.Metadata.GUID, StringComparison.InvariantCultureIgnoreCase) + x => string.Equals(x.Guid, info.Metadata.GUID, StringComparison.InvariantCultureIgnoreCase) || + (x.Plugin is BaseUnityPlugin baseUnityPlugin && string.Equals( + baseUnityPlugin.Info.Metadata.GUID, info.Metadata.GUID, + StringComparison.InvariantCultureIgnoreCase)) )) continue; var descriptor = new SpaceWarpPluginDescriptor( diff --git a/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs b/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs index ac4eec67..6f53e861 100644 --- a/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs +++ b/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs @@ -16,7 +16,7 @@ string filename if (assetBundle == null) { throw new Exception( - $"Failed to load AssetBundle {internalPath}"); + $"Failed to load AssetBundle {internalPath} ({filename})"); } internalPath = internalPath.Replace(".bundle", ""); diff --git a/SpaceWarp.Core/SpaceWarpPlugin.cs b/SpaceWarp.Core/SpaceWarpPlugin.cs index 92abfd40..f472d6c0 100644 --- a/SpaceWarp.Core/SpaceWarpPlugin.cs +++ b/SpaceWarp.Core/SpaceWarpPlugin.cs @@ -41,6 +41,9 @@ public sealed class SpaceWarpPlugin : BaseSpaceWarpPlugin public SpaceWarpPlugin() { + BepInEx.Bootstrap.Chainloader.ManagerObject.Persist(); + BepInEx.Configuration.ConfigFile.CoreConfig["Chainloader", "HideManagerGameObject"].BoxedValue = true; + // Load the type forwarders Assembly.LoadFile( $"{new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName}\\SpaceWarp.dll"); Logger = base.Logger; @@ -98,7 +101,6 @@ private void SetupLuaState() public override void OnPreInitialized() { // Persist all game objects so I don't need to stomp on config - BepInEx.Bootstrap.Chainloader.ManagerObject.Persist(); ModuleManager.PreInitializeAllModules(); } diff --git a/SpaceWarp.VersionChecking/Modules/VersionChecking.cs b/SpaceWarp.VersionChecking/Modules/VersionChecking.cs index e3998a34..84677fed 100644 --- a/SpaceWarp.VersionChecking/Modules/VersionChecking.cs +++ b/SpaceWarp.VersionChecking/Modules/VersionChecking.cs @@ -111,11 +111,16 @@ private IEnumerator CheckVersion(string guid, SpaceWarpPluginDescriptor info) { ModuleLogger.LogError($"Unable to check version for {guid} due to error {e}"); } - + info.Outdated = isOutdated; info.Unsupported = unsupported; + if (isOutdated) + { + ModuleLogger.LogWarning($"{guid} is outdated"); + } if (unsupported) { + ModuleLogger.LogWarning($"{guid} is unsupported"); info.SWInfo.SupportedKsp2Versions = newKSP2Versions; } } @@ -206,6 +211,11 @@ private void CheckModKspVersion(string guid, SpaceWarpPluginDescriptor info, str ModuleLogger.LogError($"Unable to check KSP version for {guid} due to error {e}"); } + if (unsupported) + { + ModuleLogger.LogWarning($"{guid} is unsupported"); + } + info.Unsupported = info.Unsupported || unsupported; } } \ No newline at end of file From 3abe8b154928829bc5fd6ba7a05f6ccca4b12d32 Mon Sep 17 00:00:00 2001 From: Lexi Date: Thu, 12 Oct 2023 10:01:30 -0400 Subject: [PATCH 2/3] Bump version to 1.5.1 --- SpaceWarpBuildTemplate/swinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpaceWarpBuildTemplate/swinfo.json b/SpaceWarpBuildTemplate/swinfo.json index 98344e8f..7facc128 100644 --- a/SpaceWarpBuildTemplate/swinfo.json +++ b/SpaceWarpBuildTemplate/swinfo.json @@ -6,7 +6,7 @@ "description": "Space-Warp is an API for KSP2 mod developers.", "source": "https://github.com/SpaceWarpDev/SpaceWarp", "version_check": "https://raw.githubusercontent.com/SpaceWarpDev/SpaceWarp/main/SpaceWarpBuildTemplate/swinfo.json", - "version": "1.5.0", + "version": "1.5.1", "dependencies": [ { "id": "UitkForKsp2", From 463a4f6df5cdf618767b04b8ea74e3e45739847a Mon Sep 17 00:00:00 2001 From: Lexi Date: Thu, 12 Oct 2023 10:16:08 -0400 Subject: [PATCH 3/3] Fixed crashing in plugin register --- Directory.Build.props | 2 +- SpaceWarp.Core/SpaceWarpPlugin.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 582628b6..01b58844 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 1.5.0 + 1.5.1 netstandard2.0 SpaceWarp 11 diff --git a/SpaceWarp.Core/SpaceWarpPlugin.cs b/SpaceWarp.Core/SpaceWarpPlugin.cs index f472d6c0..a4bdec41 100644 --- a/SpaceWarp.Core/SpaceWarpPlugin.cs +++ b/SpaceWarp.Core/SpaceWarpPlugin.cs @@ -41,8 +41,6 @@ public sealed class SpaceWarpPlugin : BaseSpaceWarpPlugin public SpaceWarpPlugin() { - BepInEx.Bootstrap.Chainloader.ManagerObject.Persist(); - BepInEx.Configuration.ConfigFile.CoreConfig["Chainloader", "HideManagerGameObject"].BoxedValue = true; // Load the type forwarders Assembly.LoadFile( $"{new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName}\\SpaceWarp.dll"); @@ -62,6 +60,7 @@ private static void OnLanguageSourceAssetLoaded(LanguageSourceAsset asset) } public void Awake() { + BepInEx.Bootstrap.Chainloader.ManagerObject.Persist(); IOProvider.Init(); Harmony.CreateAndPatchAll(typeof(SpaceWarpPlugin).Assembly, ModGuid);