Remove FileSystem.ResolveAssemblyPath
This commit is contained in:
@@ -277,40 +277,6 @@ namespace OpenRA.FileSystem
|
||||
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)
|
||||
{
|
||||
var resolved = Path.GetPathRoot(path);
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA
|
||||
public readonly ModMetadata Metadata;
|
||||
public readonly string[]
|
||||
Rules, ServerTraits,
|
||||
Sequences, ModelSequences, Cursors, Chrome, Assemblies, ChromeLayout,
|
||||
Sequences, ModelSequences, Cursors, Chrome, ChromeLayout,
|
||||
Weapons, Voices, Notifications, Music, Translations, TileSets,
|
||||
ChromeMetrics, MapCompatibility, Missions, Hotkeys;
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace OpenRA
|
||||
public readonly MiniYaml LoadScreen;
|
||||
public readonly string DefaultOrderGenerator;
|
||||
|
||||
public readonly string[] Assemblies = Array.Empty<string>();
|
||||
public readonly string[] SoundFormats = Array.Empty<string>();
|
||||
public readonly string[] SpriteFormats = Array.Empty<string>();
|
||||
public readonly string[] PackageFormats = Array.Empty<string>();
|
||||
@@ -130,7 +131,6 @@ namespace OpenRA
|
||||
ModelSequences = YamlList(yaml, "ModelSequences");
|
||||
Cursors = YamlList(yaml, "Cursors");
|
||||
Chrome = YamlList(yaml, "Chrome");
|
||||
Assemblies = YamlList(yaml, "Assemblies");
|
||||
ChromeLayout = YamlList(yaml, "ChromeLayout");
|
||||
Weapons = YamlList(yaml, "Weapons");
|
||||
Voices = YamlList(yaml, "Voices");
|
||||
@@ -158,6 +158,9 @@ namespace OpenRA
|
||||
if (yaml.TryGetValue("DefaultOrderGenerator", out entry))
|
||||
DefaultOrderGenerator = entry.Value;
|
||||
|
||||
if (yaml.TryGetValue("Assemblies", out entry))
|
||||
Assemblies = FieldLoader.GetValue<string[]>("Assemblies", entry.Value);
|
||||
|
||||
if (yaml.TryGetValue("PackageFormats", out entry))
|
||||
PackageFormats = FieldLoader.GetValue<string[]>("PackageFormats", entry.Value);
|
||||
|
||||
|
||||
@@ -34,16 +34,10 @@ namespace OpenRA
|
||||
ctorCache = new Cache<Type, ConstructorInfo>(GetCtor);
|
||||
|
||||
// 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 };
|
||||
foreach (var path in manifest.Assemblies)
|
||||
{
|
||||
var resolvedPath = FileSystem.FileSystem.ResolveAssemblyPath(path, manifest, mods);
|
||||
if (resolvedPath == null)
|
||||
throw new FileNotFoundException($"Assembly `{path}` not found.");
|
||||
|
||||
LoadAssembly(assemblyList, resolvedPath);
|
||||
}
|
||||
foreach (var filename in manifest.Assemblies)
|
||||
LoadAssembly(assemblyList, Path.Combine(Platform.BinDir, filename));
|
||||
|
||||
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
|
||||
assemblies = assemblyList.SelectMany(asm => asm.GetNamespaces().Select(ns => (asm, ns))).ToArray();
|
||||
|
||||
@@ -10,10 +10,7 @@ Cursors:
|
||||
|
||||
Chrome:
|
||||
|
||||
Assemblies:
|
||||
^BinDir|OpenRA.Mods.Common.dll
|
||||
^BinDir|OpenRA.Mods.Cnc.dll
|
||||
^BinDir|OpenRA.Mods.D2k.dll
|
||||
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll, OpenRA.Mods.D2k.dll
|
||||
|
||||
ChromeLayout:
|
||||
|
||||
|
||||
@@ -89,9 +89,7 @@ Cursors:
|
||||
Chrome:
|
||||
cnc|chrome.yaml
|
||||
|
||||
Assemblies:
|
||||
^BinDir|OpenRA.Mods.Common.dll
|
||||
^BinDir|OpenRA.Mods.Cnc.dll
|
||||
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll
|
||||
|
||||
ChromeLayout:
|
||||
cnc|chrome/mainmenu.yaml
|
||||
|
||||
@@ -62,10 +62,7 @@ Cursors:
|
||||
Chrome:
|
||||
d2k|chrome.yaml
|
||||
|
||||
Assemblies:
|
||||
^BinDir|OpenRA.Mods.Common.dll
|
||||
^BinDir|OpenRA.Mods.Cnc.dll
|
||||
^BinDir|OpenRA.Mods.D2k.dll
|
||||
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll, OpenRA.Mods.D2k.dll
|
||||
|
||||
ChromeLayout:
|
||||
common|chrome/ingame.yaml
|
||||
|
||||
@@ -17,8 +17,7 @@ Cursors:
|
||||
Chrome:
|
||||
modcontent|chrome.yaml
|
||||
|
||||
Assemblies:
|
||||
^BinDir|OpenRA.Mods.Common.dll
|
||||
Assemblies: OpenRA.Mods.Common.dll
|
||||
|
||||
ChromeLayout:
|
||||
modcontent|content.yaml
|
||||
|
||||
@@ -80,9 +80,7 @@ Cursors:
|
||||
Chrome:
|
||||
ra|chrome.yaml
|
||||
|
||||
Assemblies:
|
||||
^BinDir|OpenRA.Mods.Common.dll
|
||||
^BinDir|OpenRA.Mods.Cnc.dll
|
||||
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll
|
||||
|
||||
ChromeLayout:
|
||||
common|chrome/ingame.yaml
|
||||
|
||||
@@ -124,9 +124,7 @@ Cursors:
|
||||
Chrome:
|
||||
ts|chrome.yaml
|
||||
|
||||
Assemblies:
|
||||
^BinDir|OpenRA.Mods.Common.dll
|
||||
^BinDir|OpenRA.Mods.Cnc.dll
|
||||
Assemblies: OpenRA.Mods.Common.dll, OpenRA.Mods.Cnc.dll
|
||||
|
||||
ChromeLayout:
|
||||
common|chrome/ingame.yaml
|
||||
|
||||
Reference in New Issue
Block a user