From 5bec019d55293b1a5c7734014041f1b425117f57 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 1 Jul 2010 18:57:10 +1200 Subject: [PATCH] add RALint checking to nearly everything --- OpenRA.Game/Traits/TransformsOnDeploy.cs | 6 +++--- OpenRA.Game/Traits/World/BibLayer.cs | 12 ++++++------ OpenRA.Mods.Cnc/PoisonedByTiberium.cs | 1 + OpenRA.Mods.RA/Aircraft.cs | 2 ++ OpenRA.Mods.RA/AirstrikePower.cs | 2 ++ OpenRA.Mods.RA/Bridge.cs | 2 -- OpenRA.Mods.RA/BridgeLayer.cs | 3 ++- OpenRA.Mods.RA/CarpetBomb.cs | 1 + OpenRA.Mods.RA/Crate.cs | 1 - OpenRA.Mods.RA/Crates/ExplodeCrateAction.cs | 2 ++ OpenRA.Mods.RA/EmitInfantryOnSell.cs | 2 ++ OpenRA.Mods.RA/Explodes.cs | 2 ++ OpenRA.Mods.RA/GivesExperience.cs | 4 ++-- OpenRA.Mods.RA/Harvester.cs | 1 + OpenRA.Mods.RA/HasUnitOnBuild.cs | 1 + OpenRA.Mods.RA/LeavesHusk.cs | 6 +++++- OpenRA.Mods.RA/Mine.cs | 1 + OpenRA.Mods.RA/Minelayer.cs | 2 ++ OpenRA.Mods.RA/NukePower.cs | 1 + OpenRA.Mods.RA/OreRefinery.cs | 1 + OpenRA.Mods.RA/OreRefineryDockAction.cs | 7 ++----- OpenRA.Mods.RA/ParatroopersPower.cs | 3 +++ OpenRA.Mods.RA/Plane.cs | 4 +--- OpenRA.Mods.RA/ProducesHelicopters.cs | 11 ++++------- OpenRA.Mods.RA/RepairableNear.cs | 1 + OpenRA.Mods.RA/ReplaceWithActor.cs | 7 ++++--- OpenRA.Mods.RA/ReturnOnIdle.cs | 5 +---- OpenRA.Mods.RA/SeedsResource.cs | 2 +- OpenRA.Mods.RA/SpyPlanePower.cs | 5 ++--- OpenRA.Mods.RA/Wall.cs | 2 -- 30 files changed, 56 insertions(+), 44 deletions(-) diff --git a/OpenRA.Game/Traits/TransformsOnDeploy.cs b/OpenRA.Game/Traits/TransformsOnDeploy.cs index 70ed138d92..85a20016b9 100644 --- a/OpenRA.Game/Traits/TransformsOnDeploy.cs +++ b/OpenRA.Game/Traits/TransformsOnDeploy.cs @@ -63,9 +63,9 @@ namespace OpenRA.Traits } self.CancelActivity(); - - // Pick the closed deploy direction to turn to - if (self.traits.Contains()) + + + if (self.traits.Contains()) // Pick the closest deploy direction to turn to { // TODO: Pick the closest deploy direction var bestDir = info.DeployDirections[0]; diff --git a/OpenRA.Game/Traits/World/BibLayer.cs b/OpenRA.Game/Traits/World/BibLayer.cs index b774e4743c..99da346d9e 100644 --- a/OpenRA.Game/Traits/World/BibLayer.cs +++ b/OpenRA.Game/Traits/World/BibLayer.cs @@ -16,13 +16,13 @@ * You should have received a copy of the GNU General Public License * along with OpenRA. If not, see . */ -#endregion - -using System; -using System.Linq; -using System.Drawing; +#endregion + +using System; +using System.Drawing; +using System.Linq; +using OpenRA.FileFormats; using OpenRA.Graphics; -using OpenRA.FileFormats; namespace OpenRA.Traits { diff --git a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs index 79e843884f..3459cce13e 100644 --- a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs +++ b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs @@ -26,6 +26,7 @@ namespace OpenRA.Mods.Cnc { class PoisonedByTiberiumInfo : ITraitInfo { + [WeaponReference] public readonly string Weapon = "Tiberium"; public readonly string[] Resources = { "Tiberium" }; diff --git a/OpenRA.Mods.RA/Aircraft.cs b/OpenRA.Mods.RA/Aircraft.cs index fe9f3c4e1e..0905fa413e 100755 --- a/OpenRA.Mods.RA/Aircraft.cs +++ b/OpenRA.Mods.RA/Aircraft.cs @@ -28,7 +28,9 @@ namespace OpenRA.Mods.RA public class AircraftInfo : ITraitInfo { public readonly int CruiseAltitude = 20; + [ActorReference] public readonly string[] RepairBuildings = { "fix" }; + [ActorReference] public readonly string[] RearmBuildings = { "hpad", "afld" }; public virtual object Create( ActorInitializer init ) { return new Aircraft( init ); } diff --git a/OpenRA.Mods.RA/AirstrikePower.cs b/OpenRA.Mods.RA/AirstrikePower.cs index 173b2753ef..49cd6d166f 100644 --- a/OpenRA.Mods.RA/AirstrikePower.cs +++ b/OpenRA.Mods.RA/AirstrikePower.cs @@ -27,7 +27,9 @@ namespace OpenRA.Mods.RA { class AirstrikePowerInfo : SupportPowerInfo { + [ActorReference] public readonly string UnitType = "badr.bomber"; + [ActorReference] public readonly string FlareType = null; public override object Create(ActorInitializer init) { return new AirstrikePower(init.self, this); } diff --git a/OpenRA.Mods.RA/Bridge.cs b/OpenRA.Mods.RA/Bridge.cs index 4ae4a0df3f..1d1526eb7e 100644 --- a/OpenRA.Mods.RA/Bridge.cs +++ b/OpenRA.Mods.RA/Bridge.cs @@ -21,9 +21,7 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; -using System; using OpenRA.FileFormats; -using OpenRA.GameRules; using OpenRA.Graphics; using OpenRA.Traits; diff --git a/OpenRA.Mods.RA/BridgeLayer.cs b/OpenRA.Mods.RA/BridgeLayer.cs index b684b80c02..fe51fb2eb4 100644 --- a/OpenRA.Mods.RA/BridgeLayer.cs +++ b/OpenRA.Mods.RA/BridgeLayer.cs @@ -20,14 +20,15 @@ using System.Collections.Generic; using System.Linq; -using OpenRA.GameRules; using OpenRA.Traits; namespace OpenRA.Mods.RA { class BridgeLayerInfo : ITraitInfo { + [ActorReference] public readonly string[] Bridges = {"bridge1", "bridge2"}; + public object Create(ActorInitializer init) { return new BridgeLayer(init.self, this); } } diff --git a/OpenRA.Mods.RA/CarpetBomb.cs b/OpenRA.Mods.RA/CarpetBomb.cs index 399fa8caa8..8540f62351 100644 --- a/OpenRA.Mods.RA/CarpetBomb.cs +++ b/OpenRA.Mods.RA/CarpetBomb.cs @@ -25,6 +25,7 @@ namespace OpenRA.Mods.RA { class CarpetBombInfo : TraitInfo { + [WeaponReference] public readonly string Weapon = null; public readonly int Range = 0; } diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index affa820b44..2e114b2701 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -21,7 +21,6 @@ using System.Collections.Generic; using System.Linq; using OpenRA.FileFormats; -using OpenRA.GameRules; using OpenRA.Traits; /* diff --git a/OpenRA.Mods.RA/Crates/ExplodeCrateAction.cs b/OpenRA.Mods.RA/Crates/ExplodeCrateAction.cs index 1b3250341f..b40651dbb5 100644 --- a/OpenRA.Mods.RA/Crates/ExplodeCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/ExplodeCrateAction.cs @@ -9,7 +9,9 @@ namespace OpenRA.Mods.RA { class ExplodeCrateActionInfo : CrateActionInfo { + [WeaponReference] public string Weapon = null; + public override object Create(ActorInitializer init) { return new ExplodeCrateAction(init.self, this); } } diff --git a/OpenRA.Mods.RA/EmitInfantryOnSell.cs b/OpenRA.Mods.RA/EmitInfantryOnSell.cs index 3b1248e836..d97efc8c02 100644 --- a/OpenRA.Mods.RA/EmitInfantryOnSell.cs +++ b/OpenRA.Mods.RA/EmitInfantryOnSell.cs @@ -29,6 +29,8 @@ namespace OpenRA.Mods.RA { public readonly float ValueFraction = .4f; public readonly float MinHpFraction = .3f; + + [ActorReference] public readonly string[] ActorTypes = { "e1" }; } diff --git a/OpenRA.Mods.RA/Explodes.cs b/OpenRA.Mods.RA/Explodes.cs index 26ba72ba9a..fb9fcf561a 100644 --- a/OpenRA.Mods.RA/Explodes.cs +++ b/OpenRA.Mods.RA/Explodes.cs @@ -24,7 +24,9 @@ namespace OpenRA.Mods.RA { class ExplodesInfo : TraitInfo { + [WeaponReference] public readonly string Weapon = "UnitExplode"; + [WeaponReference] public readonly string EmptyWeapon = "UnitExplode"; } diff --git a/OpenRA.Mods.RA/GivesExperience.cs b/OpenRA.Mods.RA/GivesExperience.cs index b73f503b07..94d61776c3 100644 --- a/OpenRA.Mods.RA/GivesExperience.cs +++ b/OpenRA.Mods.RA/GivesExperience.cs @@ -31,8 +31,8 @@ namespace OpenRA.Mods.RA if (e.DamageState == DamageState.Dead) { // Prevent TK from giving exp - //if (e.Attacker == null || e.Attacker.Owner.Stances[ self.Owner ] == Stance.Ally ) - // return; + if (e.Attacker == null || e.Attacker.Owner.Stances[ self.Owner ] == Stance.Ally ) + return; var info = self.Info.Traits.Get(); var valued = self.Info.Traits.GetOrDefault(); diff --git a/OpenRA.Mods.RA/Harvester.cs b/OpenRA.Mods.RA/Harvester.cs index 643145f5e9..a01e862dc6 100755 --- a/OpenRA.Mods.RA/Harvester.cs +++ b/OpenRA.Mods.RA/Harvester.cs @@ -32,6 +32,7 @@ namespace OpenRA.Mods.RA public readonly int PipCount = 7; public readonly PipType PipColor = PipType.Yellow; public readonly string[] Resources = { }; + [WeaponReference] public readonly string DeathWeapon = null; public object Create(ActorInitializer init) { return new Harvester(init.self, this); } diff --git a/OpenRA.Mods.RA/HasUnitOnBuild.cs b/OpenRA.Mods.RA/HasUnitOnBuild.cs index c309d4dc5d..22b223c05d 100644 --- a/OpenRA.Mods.RA/HasUnitOnBuild.cs +++ b/OpenRA.Mods.RA/HasUnitOnBuild.cs @@ -24,6 +24,7 @@ namespace OpenRA.Mods.RA { public class FreeActorInfo : ITraitInfo { + [ActorReference] public readonly string Actor = null; public readonly string InitialActivity = null; public readonly int2 SpawnOffset = int2.Zero; diff --git a/OpenRA.Mods.RA/LeavesHusk.cs b/OpenRA.Mods.RA/LeavesHusk.cs index c615a6d2ea..617b31b549 100644 --- a/OpenRA.Mods.RA/LeavesHusk.cs +++ b/OpenRA.Mods.RA/LeavesHusk.cs @@ -22,7 +22,11 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class LeavesHuskInfo : TraitInfo { public readonly string HuskActor = null; } + class LeavesHuskInfo : TraitInfo + { + [ActorReference] + public readonly string HuskActor = null; + } class LeavesHusk : INotifyDamage { diff --git a/OpenRA.Mods.RA/Mine.cs b/OpenRA.Mods.RA/Mine.cs index a99fddba9f..c459a5b232 100644 --- a/OpenRA.Mods.RA/Mine.cs +++ b/OpenRA.Mods.RA/Mine.cs @@ -29,6 +29,7 @@ namespace OpenRA.Mods.RA class MineInfo : ITraitInfo { public readonly string[] CrushClasses = { }; + [WeaponReference] public readonly string Weapon = "ATMine"; public readonly bool AvoidFriendly = true; diff --git a/OpenRA.Mods.RA/Minelayer.cs b/OpenRA.Mods.RA/Minelayer.cs index 4e3b9ec787..57640b2538 100644 --- a/OpenRA.Mods.RA/Minelayer.cs +++ b/OpenRA.Mods.RA/Minelayer.cs @@ -29,8 +29,10 @@ namespace OpenRA.Mods.RA { class MinelayerInfo : TraitInfo { + [ActorReference] public readonly string Mine = "minv"; public readonly float MinefieldDepth = 1.5f; + [ActorReference] public readonly string[] RearmBuildings = { "fix" }; } diff --git a/OpenRA.Mods.RA/NukePower.cs b/OpenRA.Mods.RA/NukePower.cs index 4867352982..d8d811a798 100644 --- a/OpenRA.Mods.RA/NukePower.cs +++ b/OpenRA.Mods.RA/NukePower.cs @@ -67,6 +67,7 @@ namespace OpenRA.Mods.RA // tag trait for the building class NukeSiloInfo : ITraitInfo { + [WeaponReference] public readonly string MissileWeapon = ""; public object Create(ActorInitializer init) { return new NukeSilo(init.self); } } diff --git a/OpenRA.Mods.RA/OreRefinery.cs b/OpenRA.Mods.RA/OreRefinery.cs index 781cf34796..268e919852 100755 --- a/OpenRA.Mods.RA/OreRefinery.cs +++ b/OpenRA.Mods.RA/OreRefinery.cs @@ -36,6 +36,7 @@ namespace OpenRA.Mods.RA public readonly int Capacity = 0; public readonly int ProcessTick = 25; public readonly int ProcessAmount = 50; + [WeaponReference] public readonly string DeathWeapon = null; public object Create(ActorInitializer init) { return new OreRefinery(init.self, this); } diff --git a/OpenRA.Mods.RA/OreRefineryDockAction.cs b/OpenRA.Mods.RA/OreRefineryDockAction.cs index 9e5c9d54a7..bb1194f72f 100644 --- a/OpenRA.Mods.RA/OreRefineryDockAction.cs +++ b/OpenRA.Mods.RA/OreRefineryDockAction.cs @@ -16,11 +16,8 @@ * You should have received a copy of the GNU General Public License * along with OpenRA. If not, see . */ -#endregion - -using System; -using System.Linq; -using System.Collections.Generic; +#endregion + using OpenRA.Mods.RA.Activities; using OpenRA.Traits; using OpenRA.Traits.Activities; diff --git a/OpenRA.Mods.RA/ParatroopersPower.cs b/OpenRA.Mods.RA/ParatroopersPower.cs index b78103bb55..16a7ad588e 100644 --- a/OpenRA.Mods.RA/ParatroopersPower.cs +++ b/OpenRA.Mods.RA/ParatroopersPower.cs @@ -27,8 +27,11 @@ namespace OpenRA.Mods.RA { class ParatroopersPowerInfo : SupportPowerInfo { + [ActorReference] public string[] DropItems = { }; + [ActorReference] public string UnitType = "badr"; + [ActorReference] public string FlareType = "flare"; public override object Create(ActorInitializer init) { return new ParatroopersPower(init.self, this); } diff --git a/OpenRA.Mods.RA/Plane.cs b/OpenRA.Mods.RA/Plane.cs index 7dbcd08996..b316971316 100644 --- a/OpenRA.Mods.RA/Plane.cs +++ b/OpenRA.Mods.RA/Plane.cs @@ -20,10 +20,8 @@ using System; using System.Linq; -using OpenRA.Traits.Activities; -using OpenRA.GameRules; -using OpenRA.Traits; using OpenRA.Mods.RA.Activities; +using OpenRA.Traits; namespace OpenRA.Mods.RA { diff --git a/OpenRA.Mods.RA/ProducesHelicopters.cs b/OpenRA.Mods.RA/ProducesHelicopters.cs index 44ef01f3ca..237e5ee09d 100644 --- a/OpenRA.Mods.RA/ProducesHelicopters.cs +++ b/OpenRA.Mods.RA/ProducesHelicopters.cs @@ -16,15 +16,12 @@ * You should have received a copy of the GNU General Public License * along with OpenRA. If not, see . */ -#endregion - -using System.Collections.Generic; +#endregion + using System.Linq; using OpenRA.GameRules; -using OpenRA.Traits; -using OpenRA.Traits.Activities; -using OpenRA.Mods.RA.Activities; - +using OpenRA.Traits; + namespace OpenRA.Mods.RA { public class ProducesHelicoptersInfo : ProductionInfo diff --git a/OpenRA.Mods.RA/RepairableNear.cs b/OpenRA.Mods.RA/RepairableNear.cs index 64a099345d..5d414a23ff 100644 --- a/OpenRA.Mods.RA/RepairableNear.cs +++ b/OpenRA.Mods.RA/RepairableNear.cs @@ -27,6 +27,7 @@ namespace OpenRA.Mods.RA { class RepairableNearInfo : TraitInfo { + [ActorReference] public readonly string[] Buildings = { "spen", "syrd" }; } diff --git a/OpenRA.Mods.RA/ReplaceWithActor.cs b/OpenRA.Mods.RA/ReplaceWithActor.cs index e5c931d036..53a64901f4 100644 --- a/OpenRA.Mods.RA/ReplaceWithActor.cs +++ b/OpenRA.Mods.RA/ReplaceWithActor.cs @@ -16,16 +16,17 @@ * You should have received a copy of the GNU General Public License * along with OpenRA. If not, see . */ -#endregion - -using OpenRA.Graphics; +#endregion + using OpenRA.Traits; namespace OpenRA.Mods.RA { class ReplaceWithActorInfo : ITraitInfo { + [ActorReference] public readonly string Actor = null; + public object Create(ActorInitializer init) { return new ReplaceWithActor(init.self, this); } } diff --git a/OpenRA.Mods.RA/ReturnOnIdle.cs b/OpenRA.Mods.RA/ReturnOnIdle.cs index 295a9996ac..81c69fc46e 100644 --- a/OpenRA.Mods.RA/ReturnOnIdle.cs +++ b/OpenRA.Mods.RA/ReturnOnIdle.cs @@ -18,11 +18,8 @@ */ #endregion -using System; -using OpenRA.Traits.Activities; -using System.Drawing; -using OpenRA.Traits; using OpenRA.Mods.RA.Activities; +using OpenRA.Traits; namespace OpenRA.Mods.RA { diff --git a/OpenRA.Mods.RA/SeedsResource.cs b/OpenRA.Mods.RA/SeedsResource.cs index bb891776da..f62d714eba 100644 --- a/OpenRA.Mods.RA/SeedsResource.cs +++ b/OpenRA.Mods.RA/SeedsResource.cs @@ -19,8 +19,8 @@ #endregion using System; -using System.Linq; using System.Collections.Generic; +using System.Linq; using OpenRA.Traits; namespace OpenRA.Mods.RA diff --git a/OpenRA.Mods.RA/SpyPlanePower.cs b/OpenRA.Mods.RA/SpyPlanePower.cs index 9d7e5e04a8..9e3dbab887 100644 --- a/OpenRA.Mods.RA/SpyPlanePower.cs +++ b/OpenRA.Mods.RA/SpyPlanePower.cs @@ -18,11 +18,10 @@ */ #endregion -using System.Collections.Generic; +using OpenRA.Mods.RA.Activities; +using OpenRA.Orders; using OpenRA.Traits; using OpenRA.Traits.Activities; -using OpenRA.Orders; -using OpenRA.Mods.RA.Activities; namespace OpenRA.Mods.RA { diff --git a/OpenRA.Mods.RA/Wall.cs b/OpenRA.Mods.RA/Wall.cs index 951d2ef1a4..18ec1af071 100644 --- a/OpenRA.Mods.RA/Wall.cs +++ b/OpenRA.Mods.RA/Wall.cs @@ -19,8 +19,6 @@ #endregion using System.Collections.Generic; -using System.Linq; -using OpenRA.GameRules; using OpenRA.Traits; namespace OpenRA.Mods.RA