diff --git a/OpenRA.Mods.Common/Lint/CheckSequences.cs b/OpenRA.Mods.Common/Lint/CheckSequences.cs index 34dc6775ef..ef236dee31 100644 --- a/OpenRA.Mods.Common/Lint/CheckSequences.cs +++ b/OpenRA.Mods.Common/Lint/CheckSequences.cs @@ -18,24 +18,9 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Lint { - class CheckSequences : ILintRulesPass + class CheckSequences : ILintSequencesPass { - void ILintRulesPass.Run(Action emitError, Action emitWarning, ModData modData, Ruleset rules) - { - // Custom maps define rules.Sequences, default mod rules leave it null. - if (rules.Sequences == null) - { - foreach (var kv in modData.DefaultSequences) - { - Console.WriteLine("Testing default sequences for {0}", kv.Key); - Run(emitError, emitWarning, rules, kv.Value); - } - } - else if (!modData.DefaultSequences.Values.Contains(rules.Sequences)) - Run(emitError, emitWarning, rules, rules.Sequences); - } - - void Run(Action emitError, Action emitWarning, Ruleset rules, SequenceProvider sequences) + void ILintSequencesPass.Run(Action emitError, Action emitWarning, ModData modData, Ruleset rules, SequenceProvider sequences) { var factions = rules.Actors[SystemActors.World].TraitInfos().Select(f => f.InternalName).ToArray(); foreach (var actorInfo in rules.Actors) diff --git a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs index 58b5457e8e..0046adad16 100644 --- a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs +++ b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.Linq; using OpenRA.FileSystem; +using OpenRA.Graphics; using OpenRA.Mods.Common.Lint; namespace OpenRA.Mods.Common.UtilityCommands @@ -62,6 +63,13 @@ namespace OpenRA.Mods.Common.UtilityCommands // Run all rule checks on the default mod rules. CheckRules(modData, modData.DefaultRules); + foreach (var tileset in modData.DefaultTerrainInfo.Keys) + { + Console.WriteLine($"Testing default sequences for {tileset}"); + + var sequences = new SequenceProvider(modData.DefaultFileSystem, modData, tileset, null); + CheckSequences(modData, modData.DefaultRules, sequences); + } // Run all generic (not mod-level) checks here. foreach (var customPassType in modData.ObjectCreator.GetTypesImplementing()) @@ -120,7 +128,11 @@ namespace OpenRA.Mods.Common.UtilityCommands // Run all rule checks on the map if it defines custom rules. if (map.RuleDefinitions != null || map.VoiceDefinitions != null || map.WeaponDefinitions != null) + { CheckRules(modData, map.Rules); + if (map.SequenceDefinitions != null) + CheckSequences(modData, modData.DefaultRules, map.Sequences); + } // Run all map-level checks here. foreach (var customMapPassType in modData.ObjectCreator.GetTypesImplementing()) @@ -152,5 +164,21 @@ namespace OpenRA.Mods.Common.UtilityCommands } } } + + void CheckSequences(ModData modData, Ruleset rules, SequenceProvider sequences) + { + foreach (var customSequencesPassType in modData.ObjectCreator.GetTypesImplementing()) + { + try + { + var customRulesPass = (ILintSequencesPass)modData.ObjectCreator.CreateBasic(customSequencesPassType); + customRulesPass.Run(EmitError, EmitWarning, modData, rules, sequences); + } + catch (Exception e) + { + EmitError($"{customSequencesPassType} failed with exception: {e}"); + } + } + } } } diff --git a/OpenRA.Mods.Common/UtilityCommands/LintInterfaces.cs b/OpenRA.Mods.Common/UtilityCommands/LintInterfaces.cs index 199b076c61..d5227f4430 100644 --- a/OpenRA.Mods.Common/UtilityCommands/LintInterfaces.cs +++ b/OpenRA.Mods.Common/UtilityCommands/LintInterfaces.cs @@ -10,10 +10,12 @@ #endregion using System; +using OpenRA.Graphics; namespace OpenRA.Mods.Common.Lint { public interface ILintPass { void Run(Action emitError, Action emitWarning, ModData modData); } public interface ILintMapPass { void Run(Action emitError, Action emitWarning, ModData modData, Map map); } public interface ILintRulesPass { void Run(Action emitError, Action emitWarning, ModData modData, Ruleset rules); } + public interface ILintSequencesPass { void Run(Action emitError, Action emitWarning, ModData modData, Ruleset rules, SequenceProvider sequences); } }