From ee043d6c81dbae13d39d42aa4bc4f083c4aa4773 Mon Sep 17 00:00:00 2001 From: CptMoore <39010654+CptMoore@users.noreply.github.com> Date: Mon, 23 Jan 2023 03:48:45 +0100 Subject: [PATCH] Avoid AssembliesOverride if not found. --- ModTekPreloader/Injector/AssemblyCache.cs | 6 +++++- ModTekPreloader/Loader/Preloader.cs | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ModTekPreloader/Injector/AssemblyCache.cs b/ModTekPreloader/Injector/AssemblyCache.cs index 42978df..e5f1ac0 100644 --- a/ModTekPreloader/Injector/AssemblyCache.cs +++ b/ModTekPreloader/Injector/AssemblyCache.cs @@ -16,10 +16,14 @@ internal AssemblyCache() { searchDirectories = new List { - Paths.AssembliesOverrideDirectory, Paths.ModTekDirectory, Paths.ManagedDirectory }; + + if (Directory.Exists(Paths.AssembliesOverrideDirectory)) + { + searchDirectories.Insert(0, Paths.AssembliesOverrideDirectory); + } } public AssemblyDefinition Resolve(AssemblyNameReference name) diff --git a/ModTekPreloader/Loader/Preloader.cs b/ModTekPreloader/Loader/Preloader.cs index 6a2e6f7..3728be5 100644 --- a/ModTekPreloader/Loader/Preloader.cs +++ b/ModTekPreloader/Loader/Preloader.cs @@ -48,6 +48,11 @@ private static void PreloadAssembliesInjected() private static void PreloadAssembliesOverride() { + if (!Directory.Exists(Paths.AssembliesOverrideDirectory)) + { + return; + } + Logger.Main.Log($"Preloading override assemblies from `{Paths.GetRelativePath(Paths.AssembliesOverrideDirectory)}`:"); foreach (var file in Directory.GetFiles(Paths.AssembliesOverrideDirectory, "*.dll").OrderBy(p => p)) {