Remove FileSystem.ResolveAssemblyPath
This commit is contained in:
@@ -277,40 +277,6 @@ namespace OpenRA.FileSystem
|
|||||||
return !filename.StartsWith($"{modID}|", StringComparison.Ordinal);
|
return !filename.StartsWith($"{modID}|", StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Resolves a filesystem for an assembly, accounting for explicit and mod mounts.
|
|
||||||
/// Assemblies must exist in the native OS file system (not inside an OpenRA-defined package).
|
|
||||||
/// </summary>
|
|
||||||
public static string ResolveAssemblyPath(string path, Manifest manifest, InstalledMods installedMods)
|
|
||||||
{
|
|
||||||
var explicitSplit = path.IndexOf('|');
|
|
||||||
if (explicitSplit > 0 && !path.StartsWith('^'))
|
|
||||||
{
|
|
||||||
var parent = path[..explicitSplit];
|
|
||||||
var filename = path[(explicitSplit + 1)..];
|
|
||||||
|
|
||||||
var parentPath = manifest.Packages.FirstOrDefault(kv => kv.Value == parent).Key;
|
|
||||||
if (parentPath == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (parentPath.StartsWith('$'))
|
|
||||||
{
|
|
||||||
if (!installedMods.TryGetValue(parentPath[1..], out var mod))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (mod.Package is not Folder)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
path = Path.Combine(mod.Package.Name, filename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
path = Path.Combine(parentPath, filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
var resolvedPath = Platform.ResolvePath(path);
|
|
||||||
return File.Exists(resolvedPath) ? resolvedPath : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string ResolveCaseInsensitivePath(string path)
|
public static string ResolveCaseInsensitivePath(string path)
|
||||||
{
|
{
|
||||||
var resolved = Path.GetPathRoot(path);
|
var resolved = Path.GetPathRoot(path);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA
|
|||||||
public readonly ModMetadata Metadata;
|
public readonly ModMetadata Metadata;
|
||||||
public readonly string[]
|
public readonly string[]
|
||||||
Rules, ServerTraits,
|
Rules, ServerTraits,
|
||||||
Sequences, ModelSequences, Cursors, Chrome, Assemblies, ChromeLayout,
|
Sequences, ModelSequences, Cursors, Chrome, ChromeLayout,
|
||||||
Weapons, Voices, Notifications, Music, Translations, TileSets,
|
Weapons, Voices, Notifications, Music, Translations, TileSets,
|
||||||
ChromeMetrics, MapCompatibility, Missions, Hotkeys;
|
ChromeMetrics, MapCompatibility, Missions, Hotkeys;
|
||||||
|
|
||||||
@@ -70,6 +70,7 @@ namespace OpenRA
|
|||||||
public readonly MiniYaml LoadScreen;
|
public readonly MiniYaml LoadScreen;
|
||||||
public readonly string DefaultOrderGenerator;
|
public readonly string DefaultOrderGenerator;
|
||||||
|
|
||||||
|
public readonly string[] Assemblies = Array.Empty<string>();
|
||||||
public readonly string[] SoundFormats = Array.Empty<string>();
|
public readonly string[] SoundFormats = Array.Empty<string>();
|
||||||
public readonly string[] SpriteFormats = Array.Empty<string>();
|
public readonly string[] SpriteFormats = Array.Empty<string>();
|
||||||
public readonly string[] PackageFormats = Array.Empty<string>();
|
public readonly string[] PackageFormats = Array.Empty<string>();
|
||||||
@@ -130,7 +131,6 @@ namespace OpenRA
|
|||||||
ModelSequences = YamlList(yaml, "ModelSequences");
|
ModelSequences = YamlList(yaml, "ModelSequences");
|
||||||
Cursors = YamlList(yaml, "Cursors");
|
Cursors = YamlList(yaml, "Cursors");
|
||||||
Chrome = YamlList(yaml, "Chrome");
|
Chrome = YamlList(yaml, "Chrome");
|
||||||
Assemblies = YamlList(yaml, "Assemblies");
|
|
||||||
ChromeLayout = YamlList(yaml, "ChromeLayout");
|
ChromeLayout = YamlList(yaml, "ChromeLayout");
|
||||||
Weapons = YamlList(yaml, "Weapons");
|
Weapons = YamlList(yaml, "Weapons");
|
||||||
Voices = YamlList(yaml, "Voices");
|
Voices = YamlList(yaml, "Voices");
|
||||||
@@ -158,6 +158,9 @@ namespace OpenRA
|
|||||||
if (yaml.TryGetValue("DefaultOrderGenerator", out entry))
|
if (yaml.TryGetValue("DefaultOrderGenerator", out entry))
|
||||||
DefaultOrderGenerator = entry.Value;
|
DefaultOrderGenerator = entry.Value;
|
||||||
|
|
||||||
|
if (yaml.TryGetValue("Assemblies", out entry))
|
||||||
|
Assemblies = FieldLoader.GetValue<string[]>("Assemblies", entry.Value);
|
||||||
|
|
||||||
if (yaml.TryGetValue("PackageFormats", out entry))
|
if (yaml.TryGetValue("PackageFormats", out entry))
|
||||||
PackageFormats = FieldLoader.GetValue<string[]>("PackageFormats", entry.Value);
|
PackageFormats = FieldLoader.GetValue<string[]>("PackageFormats", entry.Value);
|
||||||
|
|
||||||
|
|||||||
@@ -34,16 +34,10 @@ namespace OpenRA
|
|||||||
ctorCache = new Cache<Type, ConstructorInfo>(GetCtor);
|
ctorCache = new Cache<Type, ConstructorInfo>(GetCtor);
|
||||||
|
|
||||||
// Allow mods to load types from the core Game assembly, and any additional assemblies they specify.
|
// Allow mods to load types from the core Game assembly, and any additional assemblies they specify.
|
||||||
// Assemblies can only be loaded from directories to avoid circular dependencies on package loaders.
|
// Assemblies must exist in the game binary directory next to the main game executable.
|
||||||
var assemblyList = new List<Assembly>() { typeof(Game).Assembly };
|
var assemblyList = new List<Assembly>() { typeof(Game).Assembly };
|
||||||
foreach (var path in manifest.Assemblies)
|
foreach (var filename in manifest.Assemblies)
|
||||||
{
|
LoadAssembly(assemblyList, Path.Combine(Platform.BinDir, filename));
|
||||||
var resolvedPath = FileSystem.FileSystem.ResolveAssemblyPath(path, manifest, mods);
|
|
||||||
if (resolvedPath == null)
|
|
||||||
throw new FileNotFoundException($"Assembly `{path}` not found.");
|
|
||||||
|
|
||||||
LoadAssembly(assemblyList, resolvedPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
|
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
|
||||||
assemblies = assemblyList.SelectMany(asm => asm.GetNamespaces().Select(ns => (asm, ns))).ToArray();
|
assemblies = assemblyList.SelectMany(asm => asm.GetNamespaces().Select(ns => (asm, ns))).ToArray();
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ Cursors:
|
|||||||
|
|
||||||
Chrome:
|
Chrome:
|
||||||
|
|
||||||
Assemblies:
|
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll, OpenRA.Mods.D2k.dll
|
||||||
^BinDir|OpenRA.Mods.Common.dll
|
|
||||||
^BinDir|OpenRA.Mods.Cnc.dll
|
|
||||||
^BinDir|OpenRA.Mods.D2k.dll
|
|
||||||
|
|
||||||
ChromeLayout:
|
ChromeLayout:
|
||||||
|
|
||||||
|
|||||||
@@ -89,9 +89,7 @@ Cursors:
|
|||||||
Chrome:
|
Chrome:
|
||||||
cnc|chrome.yaml
|
cnc|chrome.yaml
|
||||||
|
|
||||||
Assemblies:
|
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll
|
||||||
^BinDir|OpenRA.Mods.Common.dll
|
|
||||||
^BinDir|OpenRA.Mods.Cnc.dll
|
|
||||||
|
|
||||||
ChromeLayout:
|
ChromeLayout:
|
||||||
cnc|chrome/mainmenu.yaml
|
cnc|chrome/mainmenu.yaml
|
||||||
|
|||||||
@@ -62,10 +62,7 @@ Cursors:
|
|||||||
Chrome:
|
Chrome:
|
||||||
d2k|chrome.yaml
|
d2k|chrome.yaml
|
||||||
|
|
||||||
Assemblies:
|
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll, OpenRA.Mods.D2k.dll
|
||||||
^BinDir|OpenRA.Mods.Common.dll
|
|
||||||
^BinDir|OpenRA.Mods.Cnc.dll
|
|
||||||
^BinDir|OpenRA.Mods.D2k.dll
|
|
||||||
|
|
||||||
ChromeLayout:
|
ChromeLayout:
|
||||||
common|chrome/ingame.yaml
|
common|chrome/ingame.yaml
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ Cursors:
|
|||||||
Chrome:
|
Chrome:
|
||||||
modcontent|chrome.yaml
|
modcontent|chrome.yaml
|
||||||
|
|
||||||
Assemblies:
|
Assemblies: OpenRA.Mods.Common.dll
|
||||||
^BinDir|OpenRA.Mods.Common.dll
|
|
||||||
|
|
||||||
ChromeLayout:
|
ChromeLayout:
|
||||||
modcontent|content.yaml
|
modcontent|content.yaml
|
||||||
|
|||||||
@@ -80,9 +80,7 @@ Cursors:
|
|||||||
Chrome:
|
Chrome:
|
||||||
ra|chrome.yaml
|
ra|chrome.yaml
|
||||||
|
|
||||||
Assemblies:
|
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll
|
||||||
^BinDir|OpenRA.Mods.Common.dll
|
|
||||||
^BinDir|OpenRA.Mods.Cnc.dll
|
|
||||||
|
|
||||||
ChromeLayout:
|
ChromeLayout:
|
||||||
common|chrome/ingame.yaml
|
common|chrome/ingame.yaml
|
||||||
|
|||||||
@@ -124,9 +124,7 @@ Cursors:
|
|||||||
Chrome:
|
Chrome:
|
||||||
ts|chrome.yaml
|
ts|chrome.yaml
|
||||||
|
|
||||||
Assemblies:
|
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll
|
||||||
^BinDir|OpenRA.Mods.Common.dll
|
|
||||||
^BinDir|OpenRA.Mods.Cnc.dll
|
|
||||||
|
|
||||||
ChromeLayout:
|
ChromeLayout:
|
||||||
common|chrome/ingame.yaml
|
common|chrome/ingame.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user