Skip to content

Commit 12de007

Browse files
committed
修复:Program.cs模组字典加载失败,适配copilot模组启动
1 parent 4d22cef commit 12de007

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

OpenRA.Server/Program.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ static void Run(string[] args)
4040
var engineDirArg = arguments.GetValue("Engine.EngineDir", null);
4141
if (!string.IsNullOrEmpty(engineDirArg))
4242
Platform.OverrideEngineDir(engineDirArg);
43+
else
44+
{
45+
var binDir = Platform.BinDir;
46+
var binMods = Path.Combine(binDir, "mods");
47+
var parentMods = Path.Combine(binDir, "..", "mods");
48+
if (!Directory.Exists(binMods) && Directory.Exists(parentMods))
49+
Platform.OverrideEngineDir(Path.GetFullPath(Path.Combine(binDir, "..")));
50+
}
4351

4452
var supportDirArg = arguments.GetValue("Engine.SupportDir", null);
4553
if (!string.IsNullOrEmpty(supportDirArg))
@@ -51,16 +59,23 @@ static void Run(string[] args)
5159
Log.AddChannel("nat", "dedicated-nat.log", true);
5260
Log.AddChannel("geoip", "dedicated-geoip.log", true);
5361

54-
// Special case handling of Game.Mod argument: if it matches a real filesystem path
55-
// then we use this to override the mod search path, and replace it with the mod id
56-
var modID = arguments.GetValue("Game.Mod", null);
57-
var explicitModPaths = Array.Empty<string>();
62+
var modID = arguments.GetValue("Game.Mod", "copilot");
63+
var explicitModPaths = new List<string>();
5864
if (modID != null && (File.Exists(modID) || Directory.Exists(modID)))
5965
{
60-
explicitModPaths = new[] { modID };
66+
explicitModPaths.Add(modID);
6167
modID = Path.GetFileNameWithoutExtension(modID);
6268
}
6369

70+
if (modID == "copilot")
71+
{
72+
var copilotPath = Path.Combine(Platform.EngineDir, "mods", "copilot");
73+
if (Directory.Exists(copilotPath))
74+
{
75+
explicitModPaths.Add(copilotPath);
76+
}
77+
}
78+
6479
if (modID == null)
6580
throw new InvalidOperationException("Game.Mod argument missing or mod could not be found.");
6681

0 commit comments

Comments
 (0)