Skip to content

Commit

Permalink
Register the current mod even if LaunchPath is bogus.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed Dec 16, 2017
1 parent 5b51f2a commit 35c153b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions OpenRA.Game/ExternalMods.cs
Expand Up @@ -70,7 +70,7 @@ public ExternalMods()
}
}

void LoadMod(MiniYaml yaml, string path = null)
void LoadMod(MiniYaml yaml, string path = null, bool forceRegistration = false)
{
var mod = FieldLoader.Load<ExternalMod>(yaml);
var iconNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Icon");
Expand All @@ -83,7 +83,7 @@ void LoadMod(MiniYaml yaml, string path = null)

// Avoid possibly overwriting a valid mod with an obviously bogus one
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;
}

Expand Down Expand Up @@ -119,7 +119,7 @@ internal void Register(Manifest mod, string launchPath, ModRegistration registra
sources.Add(Platform.SupportDir);

// 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())
{
Expand Down Expand Up @@ -154,6 +154,7 @@ internal void ClearInvalidRegistrations(ExternalMod activeMod, ModRegistration r
if (registration.HasFlag(ModRegistration.User))
sources.Add(Platform.SupportDir);

var activeModKey = ExternalMod.MakeKey(activeMod);
foreach (var source in sources.Distinct())
{
var metadataPath = Path.Combine(source, "ModMetadata");
Expand All @@ -169,6 +170,10 @@ internal void ClearInvalidRegistrations(ExternalMod activeMod, ModRegistration r
var m = FieldLoader.Load<ExternalMod>(yaml);
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
if (File.Exists(m.LaunchPath) && Path.GetFileNameWithoutExtension(path) == modKey &&
!(activeMod != null && m.LaunchPath == activeMod.LaunchPath && m.Id == activeMod.Id && m.Version != activeMod.Version))
Expand Down

0 comments on commit 35c153b

Please sign in to comment.