diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 00df96503e..678df47f0d 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -217,7 +217,7 @@ namespace OpenRA.Traits Stance oldStance, Stance newStance); } - public interface ILintPass { void Run(Action emitError); } + public interface ILintPass { void Run(Action emitError, Action emitWarning); } public interface IObjectivesPanel { string ObjectivesPanel { get; } } } diff --git a/OpenRA.Mods.RA/AttackBase.cs b/OpenRA.Mods.RA/AttackBase.cs index a5dbc91cda..ac913aa0da 100644 --- a/OpenRA.Mods.RA/AttackBase.cs +++ b/OpenRA.Mods.RA/AttackBase.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA } } - public abstract class AttackBase : IIssueOrder, IResolveOrder, ITick, IExplodeModifier, IOrderVoice, ISync + public abstract class AttackBase : IIssueOrder, IResolveOrder, ITick, IExplodeModifier, IOrderVoice { public bool IsAttacking { get; internal set; } diff --git a/OpenRA.Mods.RA/Lint/CheckAutotargetWiring.cs b/OpenRA.Mods.RA/Lint/CheckAutotargetWiring.cs index f5aa9cff64..49f835668f 100644 --- a/OpenRA.Mods.RA/Lint/CheckAutotargetWiring.cs +++ b/OpenRA.Mods.RA/Lint/CheckAutotargetWiring.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA { class CheckAutotargetWiring : ILintPass { - public void Run(Action emitError) + public void Run(Action emitError, Action emitWarning) { foreach( var i in Rules.Info ) { diff --git a/OpenRA.Mods.RA/Lint/CheckSyncAnnotations.cs b/OpenRA.Mods.RA/Lint/CheckSyncAnnotations.cs new file mode 100644 index 0000000000..84feceb60d --- /dev/null +++ b/OpenRA.Mods.RA/Lint/CheckSyncAnnotations.cs @@ -0,0 +1,42 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 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.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using OpenRA.FileFormats; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class CheckSyncAnnotations : ILintPass + { + public void Run(Action emitError, Action emitWarning) + { + /* first, check all the types implementing ISync */ + foreach (var t in Game.modData.ObjectCreator.GetTypesImplementing()) + if (!HasAnySyncFields(t)) + emitWarning("{0} has ISync but nothing marked with [Sync]".F(t.Name)); + } + + bool HasAnySyncFields(Type t) + { + var flags = BindingFlags.Public | BindingFlags.NonPublic + | BindingFlags.Instance | BindingFlags.FlattenHierarchy; + + var fs = t.GetFields(flags); + var ps = t.GetProperties(flags); + return fs.Any(f => f.HasAttribute()) || + ps.Any(p => p.HasAttribute()); + } + } +} diff --git a/OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs b/OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs index c263fd9523..bd220c3d18 100644 --- a/OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs +++ b/OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA { class LintBuildablePrerequisites : ILintPass { - public void Run(Action emitError) + public void Run(Action emitError, Action emitWarning) { var providedPrereqs = Rules.Info.Keys.Concat( Rules.Info.SelectMany( a => a.Value.Traits diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 3306530481..244f2e109f 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -71,6 +71,7 @@ + diff --git a/OpenRA.Mods.RA/SupportPowers/GpsPower.cs b/OpenRA.Mods.RA/SupportPowers/GpsPower.cs index e7cf00b2e4..e8fe5942fb 100755 --- a/OpenRA.Mods.RA/SupportPowers/GpsPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/GpsPower.cs @@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA public override object Create(ActorInitializer init) { return new GpsPower(init.self, this); } } - class GpsPower : SupportPower, INotifyKilled, ISync, INotifyStanceChanged, INotifySold, INotifyCapture + class GpsPower : SupportPower, INotifyKilled, INotifyStanceChanged, INotifySold, INotifyCapture { GpsWatcher owner; diff --git a/RALint/RALint.cs b/RALint/RALint.cs index a396aad1dc..f4a09dd9ac 100644 --- a/RALint/RALint.cs +++ b/RALint/RALint.cs @@ -28,6 +28,11 @@ namespace RALint ++errors; } + static void EmitWarning(string e) + { + Console.WriteLine("RALint(1,1): Warning: {0}", e); + } + static int Main(string[] args) { try @@ -52,7 +57,7 @@ namespace RALint Console.WriteLine("CustomPass: {0}".F(customPassType.ToString())); - customPass.Run(EmitError); + customPass.Run(EmitError, EmitWarning); } if (errors > 0)