test and correct the ActorDataByActorCode

This commit is contained in:
Matthias Mailänder
2016-01-10 07:12:06 +01:00
parent bef6f40759
commit 4012433e10
3 changed files with 36 additions and 7 deletions

View File

@@ -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<string> emitError, Action<string> 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));
}
}
}
}

View File

@@ -108,6 +108,7 @@
<Compile Include="Traits\Render\WithAttackOverlay.cs" />
<Compile Include="Traits\Render\WithDecorationCarryable.cs" />
<Compile Include="Traits\World\D2kEditorResourceLayer.cs" />
<Compile Include="Lint\CheckImportActors.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View File

@@ -17,11 +17,11 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.D2k.UtilityCommands
{
class D2kMapImporter
public class D2kMapImporter
{
const int MapCordonWidth = 2;
readonly Dictionary<int, Pair<string, string>> actorDataByActorCode = new Dictionary<int, Pair<string, string>>
public static Dictionary<int, Pair<string, string>> ActorDataByActorCode = new Dictionary<int, Pair<string, string>>
{
{ 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));