From 4d664d4f74bf9af3254577a44f51544b2bc018c6 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 12 Jun 2018 18:31:52 +0000 Subject: [PATCH] Report custom map rule errors in the lint output. --- OpenRA.Game/Map/Map.cs | 2 ++ OpenRA.Mods.Common/Lint/CheckMapMetadata.cs | 3 --- OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs | 8 ++++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 0bec97beb8..afc43fd302 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -215,6 +215,7 @@ namespace OpenRA public Ruleset Rules { get; private set; } public bool InvalidCustomRules { get; private set; } + public Exception InvalidCustomRulesException { get; private set; } /// /// The top-left of the playable area in projected world coordinates @@ -405,6 +406,7 @@ namespace OpenRA { Log.Write("debug", "Failed to load rules for {0} with error {1}", Title, e); InvalidCustomRules = true; + InvalidCustomRulesException = e; Rules = Ruleset.LoadDefaultsForTileSet(modData, Tileset); } diff --git a/OpenRA.Mods.Common/Lint/CheckMapMetadata.cs b/OpenRA.Mods.Common/Lint/CheckMapMetadata.cs index 4354b5d052..feb797ecae 100644 --- a/OpenRA.Mods.Common/Lint/CheckMapMetadata.cs +++ b/OpenRA.Mods.Common/Lint/CheckMapMetadata.cs @@ -31,9 +31,6 @@ namespace OpenRA.Mods.Common.Lint if (!map.Categories.Any()) emitError("Map does not define any categories."); - - if (map.InvalidCustomRules) - emitError("Map contains invalid custom rules."); } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs index 316c77a244..f78dd21aed 100644 --- a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs +++ b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs @@ -87,6 +87,14 @@ namespace OpenRA.Mods.Common.UtilityCommands { Console.WriteLine("Testing map: {0}".F(testMap.Title)); + // Lint tests can't be trusted if the map rules are bogus + // so report that problem then skip the tests + if (testMap.InvalidCustomRules) + { + EmitError(testMap.InvalidCustomRulesException.ToString()); + continue; + } + // Run all rule checks on the map if it defines custom rules. if (testMap.RuleDefinitions != null || testMap.VoiceDefinitions != null || testMap.WeaponDefinitions != null) CheckRules(modData, testMap.Rules, testMap);