Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • ds/Rocket.Unturned
1 result
Select Git revision
Loading items
Show changes

Commits on Source 3

......@@ -2,6 +2,11 @@
All notable changes should be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## 4.9.3.14 - 2022-04-01
### Changed
- Assembly resolve looks for dependency with requested version number. Thanks @Sl4vP0weR in issue #49.
## 4.9.3.13 - 2021-04-23
### Changed
......
......@@ -6,4 +6,4 @@ using System.Runtime.InteropServices;
[assembly: AssemblyProduct("Rocket.Unturned")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: Guid("8870d132-f877-4fbd-9e73-49c8b1af8b3f")]
[assembly: AssemblyVersion("4.9.3.13")]
\ No newline at end of file
[assembly: AssemblyVersion("4.9.3.14")]
\ No newline at end of file
{
"Name": "Rocket.Unturned",
"Version": "4.9.3.13",
"Version": "4.9.3.14",
"Assemblies":
[
{
......
......@@ -6,4 +6,4 @@ using System.Runtime.InteropServices;
[assembly: AssemblyProduct("Rocket.API")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: Guid("8870d132-f877-4fbd-9e73-49c8b1af8b3f")]
[assembly: AssemblyVersion("4.9.3.4")]
\ No newline at end of file
[assembly: AssemblyVersion("4.9.3.14")]
\ No newline at end of file
......@@ -18,7 +18,11 @@ namespace Rocket.Core.Plugins
private static List<Assembly> pluginAssemblies;
private static List<GameObject> plugins = new List<GameObject>();
internal static List<IRocketPlugin> Plugins { get { return plugins.Select(g => g.GetComponent<IRocketPlugin>()).Where(p => p != null).ToList<IRocketPlugin>(); } }
private Dictionary<string, string> libraries = new Dictionary<string, string>();
/// <summary>
/// Maps assembly name to .dll file path.
/// </summary>
private Dictionary<AssemblyName, string> libraries = new Dictionary<AssemblyName, string>();
public List<IRocketPlugin> GetPlugins()
{
......@@ -38,15 +42,21 @@ namespace Rocket.Core.Plugins
private void Awake() {
AppDomain.CurrentDomain.AssemblyResolve += delegate (object sender, ResolveEventArgs args)
{
string file;
if (libraries.TryGetValue(args.Name, out file))
try
{
AssemblyName requestedName = new AssemblyName(args.Name);
var bestMatch = libraries.FirstOrDefault(lib => string.Equals(lib.Key.Name, requestedName.Name) && lib.Key.Version >= requestedName.Version);
if (!string.IsNullOrEmpty(bestMatch.Value))
{
return Assembly.Load(File.ReadAllBytes(file));
return Assembly.Load(File.ReadAllBytes(bestMatch.Value));
}
else
}
catch (Exception ex)
{
Logging.Logger.LogError("Could not find dependency: " + args.Name);
Logging.Logger.LogException(ex, "Caught exception resolving dependency: " + args.Name);
}
Logging.Logger.LogError("Could not find dependency: " + args.Name);
return null;
};
}
......@@ -63,8 +73,8 @@ namespace Rocket.Core.Plugins
private void loadPlugins()
{
libraries = GetAssembliesFromDirectory(Environment.LibrariesDirectory);
foreach(KeyValuePair<string,string> pair in GetAssembliesFromDirectory(Environment.PluginsDirectory))
libraries = FindAssembliesInDirectory(Environment.LibrariesDirectory);
foreach(KeyValuePair<AssemblyName,string> pair in FindAssembliesInDirectory(Environment.PluginsDirectory))
{
if(!libraries.ContainsKey(pair.Key))
libraries.Add(pair.Key,pair.Value);
......@@ -111,6 +121,25 @@ namespace Rocket.Core.Plugins
return l;
}
/// <summary>
/// Replacement for GetAssembliesFromDirectory using AssemblyName as key rather than string.
/// </summary>
private static Dictionary<AssemblyName, string> FindAssembliesInDirectory(string directory)
{
Dictionary<AssemblyName, string> l = new Dictionary<AssemblyName, string>();
IEnumerable<FileInfo> libraries = new DirectoryInfo(directory).GetFiles("*.dll", SearchOption.AllDirectories);
foreach (FileInfo library in libraries)
{
try
{
AssemblyName name = AssemblyName.GetAssemblyName(library.FullName);
l.Add(name, library.FullName);
}
catch { }
}
return l;
}
public static List<Assembly> LoadAssembliesFromDirectory(string directory, string extension = "*.dll")
{
List<Assembly> assemblies = new List<Assembly>();
......
......@@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyProduct("Rocket.Core")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: Guid("8870d132-f877-4fbd-9e73-49c8b1af8b3f")]
[assembly: AssemblyVersion("4.9.3.4")]
[assembly: AssemblyVersion("4.9.3.14")]
[assembly: InternalsVisibleTo("Rocket.Core.Tests")]
[assembly: InternalsVisibleTo("Rocket.Core.Explorables")]