From 2682dc8d833835115d8b90e0cc84cb1efd059ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Wed, 17 Apr 2013 12:59:27 +0200 Subject: [PATCH] added RALint check for missing sequence definitions closes #2283 --- OpenRA.Mods.RA/Lint/CheckSequences.cs | 38 +++++++++++++++++++++++++++ OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + 2 files changed, 39 insertions(+) create mode 100644 OpenRA.Mods.RA/Lint/CheckSequences.cs diff --git a/OpenRA.Mods.RA/Lint/CheckSequences.cs b/OpenRA.Mods.RA/Lint/CheckSequences.cs new file mode 100644 index 0000000000..b2feb9f9ed --- /dev/null +++ b/OpenRA.Mods.RA/Lint/CheckSequences.cs @@ -0,0 +1,38 @@ +#region Copyright & License Information +/* + * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using OpenRA.FileFormats; +using OpenRA.Graphics; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class CheckSequences : ILintPass + { + public void Run(Action emitError, Action emitWarning) + { + var sequences = Game.modData.Manifest.Sequences + .Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal); + + foreach (var actorInfo in Rules.Info) + foreach (var renderInfo in actorInfo.Value.Traits.WithInterface()) + { + var image = renderInfo.Image ?? actorInfo.Value.Name; + if (!sequences.Any(s => s.Key == image.ToLower()) && !actorInfo.Value.Name.Contains("^")) + emitWarning("Sprite image {0} from actor {1} has no sequence definition.".F(image, actorInfo.Value.Name)); + } + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index b4d529fd2d..7f6c9ee5d3 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -426,6 +426,7 @@ +