Remove unnecessary loading mod exceptions, log missing icon.png

This commit is contained in:
rob-v
2017-05-27 15:07:24 +02:00
committed by reaperrr
parent 04033e5c79
commit f75115a645
3 changed files with 30 additions and 18 deletions

View File

@@ -69,26 +69,38 @@ namespace OpenRA
try
{
if (!Directory.Exists(path))
throw new InvalidDataException(path + " is not a valid mod package");
{
Log.Write("debug", path + " is not a valid mod package");
return null;
}
package = new Folder(path);
if (!package.Contains("mod.yaml"))
throw new InvalidDataException(path + " is not a valid mod package");
if (package.Contains("mod.yaml"))
{
var manifest = new Manifest(id, package);
using (var stream = package.GetStream("icon.png"))
if (stream != null)
using (var bitmap = new Bitmap(stream))
icons[id] = sheetBuilder.Add(bitmap);
if (package.Contains("icon.png"))
{
using (var stream = package.GetStream("icon.png"))
if (stream != null)
using (var bitmap = new Bitmap(stream))
icons[id] = sheetBuilder.Add(bitmap);
}
else if (!manifest.Metadata.Hidden)
Log.Write("debug", "Mod '{0}' is missing 'icon.png'.".F(path));
return new Manifest(id, package);
return manifest;
}
}
catch (Exception)
catch (Exception e)
{
if (package != null)
package.Dispose();
return null;
Log.Write("debug", "Load mod '{0}': {1}".F(path, e));
}
if (package != null)
package.Dispose();
return null;
}
Dictionary<string, Manifest> GetInstalledMods(IEnumerable<string> searchPaths, IEnumerable<string> explicitPaths)
@@ -100,9 +112,6 @@ namespace OpenRA
foreach (var pair in candidates)
{
var mod = LoadMod(pair.First, pair.Second);
// Mods in the support directory and oramod packages (which are listed later
// in the CandidateMods list) override mods in the main install.
if (mod != null)
ret[pair.First] = mod;
}