From 4012433e1007c99908c83c77cf00c300f8224726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 10 Jan 2016 07:12:06 +0100 Subject: [PATCH] test and correct the ActorDataByActorCode --- OpenRA.Mods.D2k/Lint/CheckImportActors.cs | 28 +++++++++++++++++++ OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj | 1 + .../UtilityCommands/D2kMapImporter.cs | 14 +++++----- 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 OpenRA.Mods.D2k/Lint/CheckImportActors.cs diff --git a/OpenRA.Mods.D2k/Lint/CheckImportActors.cs b/OpenRA.Mods.D2k/Lint/CheckImportActors.cs new file mode 100644 index 0000000000..afb568a3ba --- /dev/null +++ b/OpenRA.Mods.D2k/Lint/CheckImportActors.cs @@ -0,0 +1,28 @@ +#region Copyright & License Information +/* + * Copyright 2007-2015 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 OpenRA.Mods.D2k.UtilityCommands; +using OpenRA.Traits; + +namespace OpenRA.Mods.D2k.Lint +{ + public class CheckImportActors : ILintRulesPass + { + public void Run(Action emitError, Action emitWarning, Ruleset rules) + { + foreach (var actorData in D2kMapImporter.ActorDataByActorCode.Values) + { + if (!rules.Actors.ContainsKey(actorData.First)) + emitError("Undefined actor {0} in map import code.".F(actorData.First)); + } + } + } +} diff --git a/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj b/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj index 0a64324e53..fa658f4327 100644 --- a/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj +++ b/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj @@ -108,6 +108,7 @@ + diff --git a/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs b/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs index dea08c2bd7..59fb7dbfd4 100644 --- a/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs +++ b/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs @@ -17,11 +17,11 @@ using OpenRA.Primitives; namespace OpenRA.Mods.D2k.UtilityCommands { - class D2kMapImporter + public class D2kMapImporter { const int MapCordonWidth = 2; - readonly Dictionary> actorDataByActorCode = new Dictionary> + public static Dictionary> ActorDataByActorCode = new Dictionary> { { 20, Pair.New("wormspawner", "Creeps") }, { 23, Pair.New("mpspawn", "Neutral") }, @@ -93,7 +93,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands { 370, Pair.New("missile_tank", "Harkonnen") }, { 371, Pair.New("siege_tank", "Harkonnen") }, { 372, Pair.New("carryall", "Harkonnen") }, - { 374, Pair.New("devast", "Harkonnen") }, + { 374, Pair.New("devastator", "Harkonnen") }, // Ordos: { 404, Pair.New("wall", "Ordos") }, @@ -125,7 +125,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands { 570, Pair.New("missile_tank", "Ordos") }, { 571, Pair.New("siege_tank", "Ordos") }, { 572, Pair.New("carryall", "Ordos") }, - { 574, Pair.New("deviatortank", "Ordos") }, + { 574, Pair.New("deviator", "Ordos") }, // Corrino: { 580, Pair.New("wall", "Corrino") }, @@ -167,7 +167,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands { 624, Pair.New("refinery", "Fremen") }, { 625, Pair.New("outpost", "Fremen") }, { 627, Pair.New("light_factory", "Fremen") }, - { 628, Pair.New("palacec", "Fremen") }, + { 628, Pair.New("palace", "Fremen") }, { 629, Pair.New("silo", "Fremen") }, { 630, Pair.New("heavy_factory", "Fremen") }, { 631, Pair.New("repair_pad", "Fremen") }, @@ -344,9 +344,9 @@ namespace OpenRA.Mods.D2k.UtilityCommands map.MapResources.Value[locationOnMap] = new ResourceTile(1, 2); // Actors - if (actorDataByActorCode.ContainsKey(tileSpecialInfo)) + if (ActorDataByActorCode.ContainsKey(tileSpecialInfo)) { - var kvp = actorDataByActorCode[tileSpecialInfo]; + var kvp = ActorDataByActorCode[tileSpecialInfo]; if (!rules.Actors.ContainsKey(kvp.First.ToLower())) throw new InvalidOperationException("Actor with name {0} could not be found in the rules YAML file!".F(kvp.First));