diff --git a/OpenRA.Game/FileSystem/FileSystem.cs b/OpenRA.Game/FileSystem/FileSystem.cs index 0b17496d69..f5ef8af7b3 100644 --- a/OpenRA.Game/FileSystem/FileSystem.cs +++ b/OpenRA.Game/FileSystem/FileSystem.cs @@ -277,40 +277,6 @@ namespace OpenRA.FileSystem return !filename.StartsWith($"{modID}|", StringComparison.Ordinal); } - /// - /// 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). - /// - 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); diff --git a/OpenRA.Game/Manifest.cs b/OpenRA.Game/Manifest.cs index 9f8b183938..32c45eed57 100644 --- a/OpenRA.Game/Manifest.cs +++ b/OpenRA.Game/Manifest.cs @@ -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(); public readonly string[] SoundFormats = Array.Empty(); public readonly string[] SpriteFormats = Array.Empty(); public readonly string[] PackageFormats = Array.Empty(); @@ -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("Assemblies", entry.Value); + if (yaml.TryGetValue("PackageFormats", out entry)) PackageFormats = FieldLoader.GetValue("PackageFormats", entry.Value); diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index 5e382908b8..e972332b7e 100644 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -34,16 +34,10 @@ namespace OpenRA ctorCache = new Cache(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() { 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(); diff --git a/mods/all/mod.yaml b/mods/all/mod.yaml index 1429b17a5a..736d9f77aa 100644 --- a/mods/all/mod.yaml +++ b/mods/all/mod.yaml @@ -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: diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index b86e3a5970..05291b9d8f 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -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 diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index 5256b7d1c2..4056b5b98e 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.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 diff --git a/mods/modcontent/mod.yaml b/mods/modcontent/mod.yaml index 585c6a003b..64e8d5c5b0 100644 --- a/mods/modcontent/mod.yaml +++ b/mods/modcontent/mod.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 diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index b188ed1a83..6a2aa8f7ff 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.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 diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index cdf0521df0..65407b2350 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.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