Skip to content

Commit

Permalink
Report custom map rule errors in the lint output.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed Jun 12, 2018
1 parent 0fc466d commit 312ae7f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions OpenRA.Game/Map/Map.cs
Expand Up @@ -215,6 +215,7 @@ public class Map : IReadOnlyFileSystem

public Ruleset Rules { get; private set; }
public bool InvalidCustomRules { get; private set; }
public Exception InvalidCustomRulesException { get; private set; }

/// <summary>
/// The top-left of the playable area in projected world coordinates
Expand Down Expand Up @@ -405,6 +406,7 @@ void PostInit()
{
Log.Write("debug", "Failed to load rules for {0} with error {1}", Title, e);
InvalidCustomRules = true;
InvalidCustomRulesException = e;
Rules = Ruleset.LoadDefaultsForTileSet(modData, Tileset);
}

Expand Down
3 changes: 0 additions & 3 deletions OpenRA.Mods.Common/Lint/CheckMapMetadata.cs
Expand Up @@ -31,9 +31,6 @@ public void Run(Action<string> emitError, Action<string> emitWarning, Map map)

if (!map.Categories.Any())
emitError("Map does not define any categories.");

if (map.InvalidCustomRules)
emitError("Map contains invalid custom rules.");
}
}
}
8 changes: 8 additions & 0 deletions OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs
Expand Up @@ -87,6 +87,14 @@ void IUtilityCommand.Run(Utility utility, string[] args)
{
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);
Expand Down

0 comments on commit 312ae7f

Please sign in to comment.