From 35bd3962b88c93ed2273e5c8b9cd74849f064f12 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Mon, 8 Apr 2019 23:07:39 -0500 Subject: [PATCH] Made updater try to update even mods rejected during the loading process --- IPA.Loader/Loader/PluginLoader.cs | 27 +++++++++++++++++++----- IPA.Loader/Loader/PluginManager.cs | 2 -- IPA.Loader/Updating/BeatMods/Updater.cs | 14 ++++++++++++ Refs/UnityEngine.CoreModule.dll | Bin 613888 -> 613888 bytes 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index 54ac6e95..f3f08807 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -212,6 +212,9 @@ namespace IPA.Loader } } + // keep track of these for the updater; it should still be able to update mods not loaded + internal static HashSet ignoredPlugins = new HashSet(); + internal static void Resolve() { // resolves duplicates and conflicts, etc PluginsMetadata.Sort((a, b) => a.Version.CompareTo(b.Version)); @@ -227,6 +230,7 @@ namespace IPA.Loader { Logger.loader.Warn($"Found duplicates of {meta.Id}, using newest"); ignore.Add(meta); + ignoredPlugins.Add(meta); continue; // because of sorted order, hightest order will always be the first one } @@ -261,8 +265,13 @@ namespace IPA.Loader } } - if (ignore.Contains(meta)) continue; - if (meta.Id != null) ids.Add(meta.Id); + if (ignore.Contains(meta)) + { + ignoredPlugins.Add(meta); + continue; + } + if (meta.Id != null) + ids.Add(meta.Id); resolved.Add(meta); } @@ -296,7 +305,8 @@ namespace IPA.Loader bool load = true; foreach (var dep in meta.Manifest.Dependencies) { - if (pluginsToLoad.ContainsKey(dep.Key) && dep.Value.IsSatisfied(pluginsToLoad[dep.Key])) continue; + if (pluginsToLoad.ContainsKey(dep.Key) && dep.Value.IsSatisfied(pluginsToLoad[dep.Key])) + continue; load = false; Logger.loader.Warn($"{meta.Name} is missing dependency {dep.Key}@{dep.Value}"); @@ -308,6 +318,8 @@ namespace IPA.Loader if (meta.Id != null) pluginsToLoad.Add(meta.Id, meta.Version); } + else + ignoredPlugins.Add(meta); } PluginsMetadata = metadata; @@ -355,8 +367,8 @@ namespace IPA.Loader } foreach (var plugin in PluginsMetadata) - foreach (var feature in plugin.Features) - feature.Evaluate(); + foreach (var feature in plugin.Features) + feature.Evaluate(); } foreach (var plugin in parsedFeatures) @@ -395,6 +407,7 @@ namespace IPA.Loader { Logger.loader.Warn( $"Feature {denyingFeature?.GetType()} denied plugin {meta.Name} from loading! {denyingFeature?.InvalidMessage}"); + ignoredPlugins.Add(meta); return null; } @@ -412,6 +425,7 @@ namespace IPA.Loader { Logger.loader.Warn( $"Feature {denyingFeature?.GetType()} denied plugin {meta.Name} from initializing! {denyingFeature?.InvalidMessage}"); + ignoredPlugins.Add(meta); return null; } @@ -431,11 +445,14 @@ namespace IPA.Loader catch (AmbiguousMatchException) { Logger.loader.Error($"Only one Init allowed per plugin (ambiguous match in {meta.Name})"); + // not adding to ignoredPlugins here because this should only happen in a development context + // if someone fucks this up on release thats on them return null; } catch (Exception e) { Logger.loader.Error($"Could not init plugin {meta.Name}: {e}"); + ignoredPlugins.Add(meta); return null; } diff --git a/IPA.Loader/Loader/PluginManager.cs b/IPA.Loader/Loader/PluginManager.cs index 0177e929..6698f99c 100644 --- a/IPA.Loader/Loader/PluginManager.cs +++ b/IPA.Loader/Loader/PluginManager.cs @@ -23,8 +23,6 @@ namespace IPA.Loader { #pragma warning disable CS0618 // Type or member is obsolete (IPlugin) - - /// /// An of new Beat Saber plugins /// diff --git a/IPA.Loader/Updating/BeatMods/Updater.cs b/IPA.Loader/Updating/BeatMods/Updater.cs index 2768da53..e3e57fcb 100644 --- a/IPA.Loader/Updating/BeatMods/Updater.cs +++ b/IPA.Loader/Updating/BeatMods/Updater.cs @@ -183,6 +183,20 @@ namespace IPA.Updating.BeatMods } } + foreach (var meta in PluginLoader.ignoredPlugins.Where(m => m.Id != null)) + { + depList.Value.Add(new DependencyObject + { + Name = meta.Id, + Version = meta.Version, + Requirement = new Range($">={meta.Version}"), + LocalPluginMeta = new PluginLoader.PluginInfo + { + Metadata = meta, Plugin = null + } + }); + } + foreach (var dep in depList.Value) Logger.updater.Debug($"Phantom Dependency: {dep}"); diff --git a/Refs/UnityEngine.CoreModule.dll b/Refs/UnityEngine.CoreModule.dll index 7fda09b5b1a8caf8838ed068926d16553550044f..3c6b63166618b74cf7b319d5c6b4e8b70a46988b 100644 GIT binary patch delta 43 scmZqJquKyOEsQNpEzB(}TUf)w7`fWR!&rfs4T#x+m}7f*80SiM071D8)Bpeg delta 43 scmZqJquKyOEsQNpEzB(}TUf)w7&+U+!&rfs4T#x+m}7f*80SiM070S+(*OVf