Merge pull request #5769 from Mailaender/actor-lint

Added a new OpenRA.Lint check for invalid actor definitions
This commit is contained in:
Paul Chote
2014-06-28 22:00:40 +12:00
6 changed files with 41 additions and 96 deletions

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Lint
{
static int errors = 0;
// mimic Windows compiler error format
static void EmitError(string e)
{
Console.WriteLine("OpenRA.Lint(1,1): Error: {0}", e);
@@ -68,16 +69,8 @@ namespace OpenRA.Lint
foreach (var testMap in maps)
{
if (testMap.RuleDefinitions.Count < 1)
{
if (verbose)
Console.WriteLine("No custom rules detected. Omitting Map: {0}".F(testMap.Title));
continue;
}
if (verbose)
Console.WriteLine("Map: {0}".F(testMap.Title));
Console.WriteLine("Testing map: {0}".F(testMap.Title));
testMap.PreloadRules();
foreach (var customPassType in Game.modData.ObjectCreator
@@ -88,14 +81,11 @@ namespace OpenRA.Lint
var customPass = (ILintPass)Game.modData.ObjectCreator
.CreateBasic(customPassType);
if (verbose)
Console.WriteLine("Pass: {0}".F(customPassType.ToString()));
customPass.Run(EmitError, EmitWarning, testMap);
}
catch (Exception e)
{
EmitError("Failed with exception: {0}".F(e));
EmitError("{0} failed with exception: {0}".F(customPassType, e));
}
}
}

View File

@@ -0,0 +1,28 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 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.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class CheckActors : ILintPass
{
public void Run(Action<string> emitError, Action<string> emitWarning, Map map)
{
var actorTypes = map.Actors.Value.Values.Select(a => a.Type);
foreach (var actor in actorTypes)
if (!map.Rules.Actors.Keys.Contains(actor.ToLowerInvariant()))
emitError("Actor {0} is not defined by any rule.".F(actor));
}
}
}

View File

@@ -518,6 +518,7 @@
<Compile Include="Activities\MoveWithinRange.cs" />
<Compile Include="Lint\CheckPlayers.cs" />
<Compile Include="Player\ProvidesCustomPrerequisite.cs" />
<Compile Include="Lint\CheckActors.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">

View File

@@ -439,7 +439,7 @@ Actors:
Actor167: powr
Location: 54,74
Owner: Allies
Actor39: pbox.e1
Actor39: pbox
Location: 70,89
Owner: Allies
AlliedTechnologyCenter: miss
@@ -452,10 +452,10 @@ Actors:
Actor150: apwr
Location: 94,90
Owner: Allies
Actor35: pbox.e1
Actor35: pbox
Location: 68,85
Owner: Allies
Actor178: pbox.e1
Actor178: pbox
Location: 77,76
Owner: Allies
Actor300: brik
@@ -495,7 +495,7 @@ Actors:
AlliedWarFactory1: weap
Location: 75,81
Owner: Allies
Actor156: pbox.e1
Actor156: pbox
Location: 52,71
Owner: Allies
Actor343: brik
@@ -628,10 +628,10 @@ Actors:
Location: 82,69
Owner: Allies
Facing: 0
Actor30: pbox.e1
Actor30: pbox
Location: 47,77
Owner: Allies
Actor29: pbox.e1
Actor29: pbox
Location: 42,75
Owner: Allies
Actor217: sbag
@@ -1001,7 +1001,7 @@ Actors:
Actor212: brik
Location: 61,80
Owner: Allies
Actor361: pbox.e1
Actor361: pbox
Location: 71,96
Owner: Allies
Actor365: hpad
@@ -1016,7 +1016,7 @@ Actors:
Actor193: fix
Location: 69,70
Owner: Allies
Actor42: pbox.e1
Actor42: pbox
Location: 67,70
Owner: Allies
Actor262: fenc
@@ -1217,7 +1217,7 @@ Actors:
LstUnload: waypoint
Location: 60,93
Owner: Neutral
Actor184: pbox.e1
Actor184: pbox
Location: 96,79
Owner: Allies
Paradrop1: waypoint

View File

@@ -459,43 +459,6 @@ PBOX:
FallbackRange: 6c0
AutoTarget:
# Legacy definitions to keep compatibility with outdated maps
PBOX.E1:
Inherits: PBOX
-Buildable:
RenderBuilding:
Image: PBOX
PBOX.E3:
Inherits: PBOX
-Buildable:
RenderBuilding:
Image: PBOX
PBOX.E4:
Inherits: PBOX
-Buildable:
RenderBuilding:
Image: PBOX
PBOX.E7:
Inherits: PBOX
-Buildable:
RenderBuilding:
Image: PBOX
PBOX.SHOK:
Inherits: PBOX
-Buildable:
RenderBuilding:
Image: PBOX
PBOX.SNIPER:
Inherits: PBOX
-Buildable:
RenderBuilding:
Image: PBOX
HBOX:
Inherits: ^Building
Tooltip:
@@ -545,43 +508,6 @@ HBOX:
PortYaws: 0, 176, 341, 512, 682, 853
PortCones: 86, 86, 86, 86, 86, 86
# Legacy definitions to keep compatibility with outdated maps
HBOX.E1:
Inherits: HBOX
-Buildable:
RenderBuilding:
Image: HBOX
HBOX.E3:
Inherits: HBOX
-Buildable:
RenderBuilding:
Image: HBOX
HBOX.E4:
Inherits: HBOX
-Buildable:
RenderBuilding:
Image: HBOX
HBOX.E7:
Inherits: HBOX
-Buildable:
RenderBuilding:
Image: HBOX
HBOX.SHOK:
Inherits: HBOX
-Buildable:
RenderBuilding:
Image: HBOX
HBOX.SNIPER:
Inherits: HBOX
-Buildable:
RenderBuilding:
Image: HBOX
GUN:
Inherits: ^Building
Buildable: