From 1fe5c1d60f186192e52984ca6b0054c254cc1507 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 20 Aug 2011 14:13:52 +1200 Subject: [PATCH] catch map load failures --- OpenRA.Game/ModData.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index a864ba81a9..c3865e46eb 100755 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -105,14 +106,19 @@ namespace OpenRA var paths = mods.SelectMany(p => FindMapsIn("mods{0}{1}{0}maps{0}".F(Path.DirectorySeparatorChar, p))) .Concat(mods.SelectMany(p => FindMapsIn("{1}maps{0}{2}{0}".F(Path.DirectorySeparatorChar, Platform.SupportDir, p)))); - Dictionary ret = new Dictionary(); + var ret = new Dictionary(); foreach (var path in paths) { - var map = new Map(path); - if (ret.ContainsKey(map.Uid)) - System.Console.WriteLine("Ignoring duplicate map: {0}", path); - else + try + { + var map = new Map(path); ret.Add(map.Uid, map); + } + catch(Exception e) + { + Console.WriteLine("Failed to load map: {0}", path); + Console.WriteLine("Details: {0}", e.ToString()); + } } return ret; }