dont crash on missing maps/ dirs
This commit is contained in:
@@ -105,26 +105,17 @@ namespace OpenRA
|
|||||||
public static Dictionary<string,MapStub> AvailableMaps;
|
public static Dictionary<string,MapStub> AvailableMaps;
|
||||||
|
|
||||||
// TODO: Do this nicer
|
// TODO: Do this nicer
|
||||||
public static Dictionary<string,MapStub> FindMaps(string[] mods)
|
public static Dictionary<string, MapStub> FindMaps(string[] mods)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Finding maps");
|
Console.WriteLine("Finding maps");
|
||||||
foreach (var mod in mods)
|
foreach (var mod in mods)
|
||||||
Console.WriteLine(mod);
|
Console.WriteLine(mod);
|
||||||
|
|
||||||
|
var paths = new[] { "maps/" }.Concat(mods.Select(m => "mods/" + m + "/maps/"))
|
||||||
List<string> paths = new List<string>();
|
.Where(p => Directory.Exists(p))
|
||||||
foreach (var mod in mods)
|
.SelectMany(p => Directory.GetDirectories(p)).ToList();
|
||||||
paths.AddRange(Directory.GetDirectories("mods/"+mod+"/maps/"));
|
|
||||||
|
return paths.Select(p => new MapStub(new Folder(p))).ToDictionary(m => m.Uid);
|
||||||
paths.AddRange(Directory.GetDirectories("maps/"));
|
|
||||||
|
|
||||||
Dictionary<string,MapStub> maps = new Dictionary<string, MapStub>();
|
|
||||||
foreach (var path in paths)
|
|
||||||
{
|
|
||||||
MapStub stub = new MapStub(new Folder(path));
|
|
||||||
maps.Add(stub.Uid,stub);
|
|
||||||
}
|
|
||||||
return maps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ChangeMods()
|
public static void ChangeMods()
|
||||||
|
|||||||
Reference in New Issue
Block a user