beginning of RALint
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -83,6 +83,7 @@
|
||||
<Compile Include="Orders\GenericSelectTarget.cs" />
|
||||
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
||||
<Compile Include="Traits\DetectCloaked.cs" />
|
||||
<Compile Include="Traits\LintAttributes.cs" />
|
||||
<Compile Include="Traits\Modifiers\FrozenUnderFog.cs" />
|
||||
<Compile Include="Traits\Player\ActorGroupProxy.cs" />
|
||||
<Compile Include="Traits\Player\PlayerResources.cs" />
|
||||
@@ -277,7 +278,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Folder Include="Traits\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -29,7 +29,9 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public class AttackBaseInfo : ITraitInfo
|
||||
{
|
||||
[WeaponReference]
|
||||
public readonly string PrimaryWeapon = null;
|
||||
[WeaponReference]
|
||||
public readonly string SecondaryWeapon = null;
|
||||
public readonly int Recoil = 0;
|
||||
public readonly int[] PrimaryLocalOffset = { };
|
||||
|
||||
15
OpenRA.Game/Traits/LintAttributes.cs
Normal file
15
OpenRA.Game/Traits/LintAttributes.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
/* attributes used by RALint to understand the rules */
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class ActorReferenceAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class WeaponReferenceAttribute : Attribute { }
|
||||
}
|
||||
10
OpenRA.sln
10
OpenRA.sln
@@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Editor", "OpenRA.Edi
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.TilesetBuilder", "OpenRA.TilesetBuilder\OpenRA.TilesetBuilder.csproj", "{56B1073B-AE14-499A-BB98-43A8DE9A39CA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RALint", "RALint\RALint.csproj", "{F9FA4D9F-2302-470A-8A07-6E37F488C124}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -108,6 +110,14 @@ Global
|
||||
{56B1073B-AE14-499A-BB98-43A8DE9A39CA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{56B1073B-AE14-499A-BB98-43A8DE9A39CA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{56B1073B-AE14-499A-BB98-43A8DE9A39CA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
95
RALint/Program.cs
Normal file
95
RALint/Program.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
using System.Reflection;
|
||||
|
||||
namespace RALint
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/* todo: move this into the engine? dpstool, seqed, editor, etc all need it (or something similar) */
|
||||
static void InitializeEngineWithMods(string[] mods)
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
||||
var manifest = new Manifest(mods);
|
||||
Game.LoadModAssemblies(manifest);
|
||||
|
||||
FileSystem.UnmountAll();
|
||||
foreach (var folder in manifest.Folders) FileSystem.Mount(folder);
|
||||
foreach (var pkg in manifest.Packages) FileSystem.Mount(pkg);
|
||||
|
||||
Rules.LoadRules(manifest, new Map());
|
||||
}
|
||||
|
||||
static int errors = 0;
|
||||
|
||||
static void EmitError(string e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
++errors;
|
||||
}
|
||||
|
||||
static int Main(string[] args)
|
||||
{
|
||||
InitializeEngineWithMods(args);
|
||||
|
||||
foreach (var actorInfo in Rules.Info)
|
||||
foreach (var traitInfo in actorInfo.Value.Traits.WithInterface<ITraitInfo>())
|
||||
CheckTrait(actorInfo.Value, traitInfo);
|
||||
|
||||
if (errors > 0)
|
||||
{
|
||||
Console.WriteLine("Errors: {0}", errors);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void CheckTrait(ActorInfo actorInfo, ITraitInfo traitInfo)
|
||||
{
|
||||
var actualType = traitInfo.GetType();
|
||||
foreach (var field in actualType.GetFields())
|
||||
{
|
||||
if (field.HasAttribute<ActorReferenceAttribute>())
|
||||
CheckReference(actorInfo, traitInfo, field, Rules.Info, "actor");
|
||||
if (field.HasAttribute<WeaponReferenceAttribute>())
|
||||
CheckReference(actorInfo, traitInfo, field, Rules.Weapons, "weapon");
|
||||
}
|
||||
}
|
||||
|
||||
static string[] GetFieldValues(ITraitInfo traitInfo, FieldInfo fieldInfo)
|
||||
{
|
||||
var type = fieldInfo.FieldType;
|
||||
if (type == typeof(string))
|
||||
return new string[] { (string)fieldInfo.GetValue(traitInfo) };
|
||||
if (type == typeof(string[]))
|
||||
return (string[])fieldInfo.GetValue(traitInfo);
|
||||
|
||||
EmitError("Bad type for reference on {0}.{1}. Supported types: string, string[]"
|
||||
.F(traitInfo.GetType().Name, fieldInfo.Name));
|
||||
|
||||
return new string[] { };
|
||||
}
|
||||
|
||||
static void CheckReference<T>(ActorInfo actorInfo, ITraitInfo traitInfo, FieldInfo fieldInfo,
|
||||
Dictionary<string, T> dict, string type)
|
||||
{
|
||||
var values = GetFieldValues(traitInfo, fieldInfo);
|
||||
foreach (var v in values)
|
||||
if (v != null && !dict.ContainsKey(v.ToLowerInvariant()))
|
||||
EmitError("{0}.{1}.{2}: Missing {3} `{4}`."
|
||||
.F(actorInfo.Name, traitInfo.GetType().Name, fieldInfo.Name, type, v));
|
||||
}
|
||||
|
||||
static bool HasAttribute<T>(this MemberInfo mi)
|
||||
{
|
||||
return mi.GetCustomAttributes(typeof(T), true).Length != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
RALint/Properties/AssemblyInfo.cs
Normal file
36
RALint/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RALint")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("RALint")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("722ef098-e9f3-4e3c-b374-3388dfad8979")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
71
RALint/RALint.csproj
Normal file
71
RALint/RALint.csproj
Normal file
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F9FA4D9F-2302-470A-8A07-6E37F488C124}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RALint</RootNamespace>
|
||||
<AssemblyName>RALint</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
|
||||
<Name>OpenRA.FileFormats</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||
<Name>OpenRA.Game</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Reference in New Issue
Block a user