ralint: verify voices, support (and still verify) @-form prerequisites.

This commit is contained in:
Chris Forbes
2010-07-04 14:50:26 +12:00
parent 8e68449af1
commit 68b63dc89e
9 changed files with 25 additions and 15 deletions

View File

@@ -21,7 +21,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Support;
using OpenRA.Traits; using OpenRA.Traits;
using Tao.OpenAl; using Tao.OpenAl;

View File

@@ -30,9 +30,9 @@ namespace OpenRA.Traits
public virtual object Create(ActorInitializer init) { return new Valued(); } public virtual object Create(ActorInitializer init) { return new Valued(); }
} }
class BuildableInfo : ValuedInfo public class BuildableInfo : ValuedInfo
{ {
public readonly string[] Prerequisites = { }; [ActorReference]public readonly string[] Prerequisites = { };
[ActorReference] public readonly string[] BuiltAt = { }; [ActorReference] public readonly string[] BuiltAt = { };
public readonly string Icon = null; public readonly string Icon = null;

View File

@@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
@@ -12,4 +9,7 @@ namespace OpenRA.Traits
[AttributeUsage(AttributeTargets.Field)] [AttributeUsage(AttributeTargets.Field)]
public class WeaponReferenceAttribute : Attribute { } public class WeaponReferenceAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field)]
public class VoiceReferenceAttribute : Attribute { }
} }

View File

@@ -24,6 +24,7 @@ namespace OpenRA.Traits
{ {
public readonly int Priority = 10; public readonly int Priority = 10;
public readonly int[] Bounds = null; public readonly int[] Bounds = null;
[VoiceReference]
public readonly string Voice = null; public readonly string Voice = null;
public readonly float Radius = 10; public readonly float Radius = 10;
} }

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Traits
public readonly string Image = null; public readonly string Image = null;
public readonly string Description = ""; public readonly string Description = "";
public readonly string LongDesc = ""; public readonly string LongDesc = "";
[ActorReference]
public readonly string[] Prerequisites = { }; public readonly string[] Prerequisites = { };
public readonly int TechLevel = -1; public readonly int TechLevel = -1;
public readonly bool GivenAuto = true; public readonly bool GivenAuto = true;

View File

@@ -24,6 +24,7 @@ namespace OpenRA.Traits
{ {
class TransformsOnDeployInfo : TraitInfo<TransformsOnDeploy> class TransformsOnDeployInfo : TraitInfo<TransformsOnDeploy>
{ {
[ActorReference]
public readonly string TransformsInto = null; public readonly string TransformsInto = null;
public readonly int[] Offset = null; public readonly int[] Offset = null;
public readonly int[] DeployDirections = new int[] {96}; public readonly int[] DeployDirections = new int[] {96};

View File

@@ -16,11 +16,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>. * along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/ */
#endregion #endregion
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
@@ -34,7 +32,6 @@ namespace OpenRA.Traits
public class HazardLayer : ITerrainCost public class HazardLayer : ITerrainCost
{ {
List<Pair<Actor, Hazard>>[,] hazards; List<Pair<Actor, Hazard>>[,] hazards;
Map map;
public HazardLayer( World world ) public HazardLayer( World world )
{ {

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Linq;
using OpenRA; using OpenRA;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.GameRules; using OpenRA.GameRules;
@@ -8,7 +9,7 @@ using OpenRA.Traits;
namespace RALint namespace RALint
{ {
static class Program static class RALint
{ {
/* todo: move this into the engine? dpstool, seqed, editor, etc all need it (or something similar) */ /* todo: move this into the engine? dpstool, seqed, editor, etc all need it (or something similar) */
static void InitializeEngineWithMods(string[] mods) static void InitializeEngineWithMods(string[] mods)
@@ -32,10 +33,18 @@ namespace RALint
++errors; ++errors;
} }
static Dictionary<string, int> ValidPrereqs;
static int Main(string[] args) static int Main(string[] args)
{ {
InitializeEngineWithMods(args); InitializeEngineWithMods(args);
// all the @something names which actually EXIST.
var psuedoPrereqs = Rules.Info.Values.Select(a => a.Traits.GetOrDefault<BuildableInfo>()).Where(b => b != null)
.Select(b => b.AlternateName).Where(n => n != null).SelectMany(a => a).Select(a => a.ToLowerInvariant()).Distinct();
ValidPrereqs = Rules.Info.Keys.Concat(psuedoPrereqs).ToDictionary(a => a, a => 0);
foreach (var actorInfo in Rules.Info) foreach (var actorInfo in Rules.Info)
foreach (var traitInfo in actorInfo.Value.Traits.WithInterface<ITraitInfo>()) foreach (var traitInfo in actorInfo.Value.Traits.WithInterface<ITraitInfo>())
CheckTrait(actorInfo.Value, traitInfo); CheckTrait(actorInfo.Value, traitInfo);
@@ -55,9 +64,11 @@ namespace RALint
foreach (var field in actualType.GetFields()) foreach (var field in actualType.GetFields())
{ {
if (field.HasAttribute<ActorReferenceAttribute>()) if (field.HasAttribute<ActorReferenceAttribute>())
CheckReference(actorInfo, traitInfo, field, Rules.Info, "actor"); CheckReference(actorInfo, traitInfo, field, ValidPrereqs, "actor");
if (field.HasAttribute<WeaponReferenceAttribute>()) if (field.HasAttribute<WeaponReferenceAttribute>())
CheckReference(actorInfo, traitInfo, field, Rules.Weapons, "weapon"); CheckReference(actorInfo, traitInfo, field, Rules.Weapons, "weapon");
if (field.HasAttribute<VoiceReferenceAttribute>())
CheckReference(actorInfo, traitInfo, field, Rules.Voices, "voice");
} }
} }

View File

@@ -47,7 +47,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Program.cs" /> <Compile Include="RALint.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>