Ver código fonte

Sort patcher assemblies by name

Bepis 6 anos atrás
pai
commit
8a806a5516
1 arquivos alterados com 11 adições e 4 exclusões
  1. 11 4
      BepInEx/Bootstrap/Preloader.cs

+ 11 - 4
BepInEx/Bootstrap/Preloader.cs

@@ -184,20 +184,27 @@ namespace BepInEx.Bootstrap
 
                 AddPatcher(new [] { "UnityEngine.dll" }, PatchEntrypoint);
 
-                if (Directory.Exists(PatcherPluginPath))
-                    foreach (string assemblyPath in Directory.GetFiles(PatcherPluginPath, "*.dll"))
+	            if (Directory.Exists(PatcherPluginPath))
+	            {
+		            SortedDictionary<string, KeyValuePair<AssemblyPatcherDelegate, IEnumerable<string>>> sortedPatchers = new SortedDictionary<string, KeyValuePair<AssemblyPatcherDelegate, IEnumerable<string>>>();
+
+					foreach (string assemblyPath in Directory.GetFiles(PatcherPluginPath, "*.dll"))
                     {
                         try
                         {
                             var assembly = Assembly.LoadFrom(assemblyPath);
 
-                            foreach (var kv in GetPatcherMethods(assembly))
-                                AddPatcher(kv.Value, kv.Key);
+	                        foreach (var kv in GetPatcherMethods(assembly))
+		                        sortedPatchers.Add(assembly.GetName().Name, kv);
                         }
                         catch (BadImageFormatException) { } //unmanaged DLL
                         catch (ReflectionTypeLoadException) { } //invalid references
                     }
 
+		            foreach (var kv in sortedPatchers)
+			            AddPatcher(kv.Value.Value, kv.Value.Key);
+	            }
+
                 AssemblyPatcher.PatchAll(ManagedPath, PatcherDictionary, Initializers, Finalizers);
             }
             catch (Exception ex)