diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 8011442a2d..a52b79a341 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -81,6 +81,9 @@ namespace OpenRA ModAssemblies = asms.ToArray(); } + public static Action MissingTypeAction = + s => { throw new InvalidOperationException("Cannot locate type: {0}".F(s)); }; + public static T CreateObject(string classname) { foreach (var mod in ModAssemblies) @@ -91,7 +94,8 @@ namespace OpenRA return (T)obj; } - throw new InvalidOperationException("Cannot locate type: {0}".F(classname)); + MissingTypeAction(classname); + return default(T); } public static Dictionary AvailableMaps; diff --git a/RALint/RALint.cs b/RALint/RALint.cs index 323fc70cc8..634e12b63e 100644 --- a/RALint/RALint.cs +++ b/RALint/RALint.cs @@ -15,6 +15,7 @@ using System.Reflection; using OpenRA; using OpenRA.GameRules; using OpenRA.Traits; +using OpenRA.FileFormats; namespace RALint { @@ -32,8 +33,12 @@ namespace RALint static int Main(string[] args) { - Game.InitializeEngineWithMods(args); + // bind some nonfatal error handling into FieldLoader, so we don't just *explode*. + Game.MissingTypeAction = s => EmitError("Missing Type: {0}".F(s)); + FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name)); + Game.InitializeEngineWithMods(args); + // all the @something names which actually EXIST. var psuedoPrereqs = Rules.Info.Values.Select(a => a.Traits.GetOrDefault()).Where(b => b != null) .Select(b => b.AlternateName).Where(n => n != null).SelectMany(a => a).Select(a => a.ToLowerInvariant()).Distinct();