Register the current mod even if LaunchPath is bogus.

This commit is contained in:
Paul Chote
2017-11-25 20:44:10 +00:00
committed by abcdefg30
parent a9d1d374b8
commit 1a405b17ba

View File

@@ -70,7 +70,7 @@ namespace OpenRA
} }
} }
void LoadMod(MiniYaml yaml, string path = null) void LoadMod(MiniYaml yaml, string path = null, bool forceRegistration = false)
{ {
var mod = FieldLoader.Load<ExternalMod>(yaml); var mod = FieldLoader.Load<ExternalMod>(yaml);
var iconNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Icon"); var iconNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Icon");
@@ -83,7 +83,7 @@ namespace OpenRA
// Avoid possibly overwriting a valid mod with an obviously bogus one // Avoid possibly overwriting a valid mod with an obviously bogus one
var key = ExternalMod.MakeKey(mod); var key = ExternalMod.MakeKey(mod);
if (File.Exists(mod.LaunchPath) && (path == null || Path.GetFileNameWithoutExtension(path) == key)) if ((forceRegistration || File.Exists(mod.LaunchPath)) && (path == null || Path.GetFileNameWithoutExtension(path) == key))
mods[key] = mod; mods[key] = mod;
} }
@@ -119,7 +119,7 @@ namespace OpenRA
sources.Add(Platform.SupportDir); sources.Add(Platform.SupportDir);
// Make sure the mod is available for this session, even if saving it fails // Make sure the mod is available for this session, even if saving it fails
LoadMod(yaml.First().Value); LoadMod(yaml.First().Value, forceRegistration: true);
foreach (var source in sources.Distinct()) foreach (var source in sources.Distinct())
{ {
@@ -154,6 +154,7 @@ namespace OpenRA
if (registration.HasFlag(ModRegistration.User)) if (registration.HasFlag(ModRegistration.User))
sources.Add(Platform.SupportDir); sources.Add(Platform.SupportDir);
var activeModKey = ExternalMod.MakeKey(activeMod);
foreach (var source in sources.Distinct()) foreach (var source in sources.Distinct())
{ {
var metadataPath = Path.Combine(source, "ModMetadata"); var metadataPath = Path.Combine(source, "ModMetadata");
@@ -169,6 +170,10 @@ namespace OpenRA
var m = FieldLoader.Load<ExternalMod>(yaml); var m = FieldLoader.Load<ExternalMod>(yaml);
modKey = ExternalMod.MakeKey(m); modKey = ExternalMod.MakeKey(m);
// Continue to the next entry if it is the active mod (even if the LaunchPath is bogus)
if (modKey == activeModKey)
continue;
// Continue to the next entry if this one is valid // Continue to the next entry if this one is valid
if (File.Exists(m.LaunchPath) && Path.GetFileNameWithoutExtension(path) == modKey && if (File.Exists(m.LaunchPath) && Path.GetFileNameWithoutExtension(path) == modKey &&
!(activeMod != null && m.LaunchPath == activeMod.LaunchPath && m.Id == activeMod.Id && m.Version != activeMod.Version)) !(activeMod != null && m.LaunchPath == activeMod.LaunchPath && m.Id == activeMod.Id && m.Version != activeMod.Version))