add RALint checking to nearly everything

This commit is contained in:
Chris Forbes
2010-07-01 18:57:10 +12:00
parent 8974fb7ae8
commit 5bec019d55
30 changed files with 56 additions and 44 deletions

View File

@@ -63,9 +63,9 @@ namespace OpenRA.Traits
} }
self.CancelActivity(); self.CancelActivity();
// Pick the closed deploy direction to turn to
if (self.traits.Contains<Unit>()) if (self.traits.Contains<Unit>()) // Pick the closest deploy direction to turn to
{ {
// TODO: Pick the closest deploy direction // TODO: Pick the closest deploy direction
var bestDir = info.DeployDirections[0]; var bestDir = info.DeployDirections[0];

View File

@@ -16,13 +16,13 @@
* 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;
using System.Linq; using System.Drawing;
using System.Drawing; using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.FileFormats;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

@@ -26,6 +26,7 @@ namespace OpenRA.Mods.Cnc
{ {
class PoisonedByTiberiumInfo : ITraitInfo class PoisonedByTiberiumInfo : ITraitInfo
{ {
[WeaponReference]
public readonly string Weapon = "Tiberium"; public readonly string Weapon = "Tiberium";
public readonly string[] Resources = { "Tiberium" }; public readonly string[] Resources = { "Tiberium" };

View File

@@ -28,7 +28,9 @@ namespace OpenRA.Mods.RA
public class AircraftInfo : ITraitInfo public class AircraftInfo : ITraitInfo
{ {
public readonly int CruiseAltitude = 20; public readonly int CruiseAltitude = 20;
[ActorReference]
public readonly string[] RepairBuildings = { "fix" }; public readonly string[] RepairBuildings = { "fix" };
[ActorReference]
public readonly string[] RearmBuildings = { "hpad", "afld" }; public readonly string[] RearmBuildings = { "hpad", "afld" };
public virtual object Create( ActorInitializer init ) { return new Aircraft( init ); } public virtual object Create( ActorInitializer init ) { return new Aircraft( init ); }

View File

@@ -27,7 +27,9 @@ namespace OpenRA.Mods.RA
{ {
class AirstrikePowerInfo : SupportPowerInfo class AirstrikePowerInfo : SupportPowerInfo
{ {
[ActorReference]
public readonly string UnitType = "badr.bomber"; public readonly string UnitType = "badr.bomber";
[ActorReference]
public readonly string FlareType = null; public readonly string FlareType = null;
public override object Create(ActorInitializer init) { return new AirstrikePower(init.self, this); } public override object Create(ActorInitializer init) { return new AirstrikePower(init.self, this); }

View File

@@ -21,9 +21,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.GameRules;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;

View File

@@ -20,14 +20,15 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.GameRules;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class BridgeLayerInfo : ITraitInfo class BridgeLayerInfo : ITraitInfo
{ {
[ActorReference]
public readonly string[] Bridges = {"bridge1", "bridge2"}; public readonly string[] Bridges = {"bridge1", "bridge2"};
public object Create(ActorInitializer init) { return new BridgeLayer(init.self, this); } public object Create(ActorInitializer init) { return new BridgeLayer(init.self, this); }
} }

View File

@@ -25,6 +25,7 @@ namespace OpenRA.Mods.RA
{ {
class CarpetBombInfo : TraitInfo<CarpetBomb> class CarpetBombInfo : TraitInfo<CarpetBomb>
{ {
[WeaponReference]
public readonly string Weapon = null; public readonly string Weapon = null;
public readonly int Range = 0; public readonly int Range = 0;
} }

View File

@@ -21,7 +21,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.GameRules;
using OpenRA.Traits; using OpenRA.Traits;
/* /*

View File

@@ -9,7 +9,9 @@ namespace OpenRA.Mods.RA
{ {
class ExplodeCrateActionInfo : CrateActionInfo class ExplodeCrateActionInfo : CrateActionInfo
{ {
[WeaponReference]
public string Weapon = null; public string Weapon = null;
public override object Create(ActorInitializer init) { return new ExplodeCrateAction(init.self, this); } public override object Create(ActorInitializer init) { return new ExplodeCrateAction(init.self, this); }
} }

View File

@@ -29,6 +29,8 @@ namespace OpenRA.Mods.RA
{ {
public readonly float ValueFraction = .4f; public readonly float ValueFraction = .4f;
public readonly float MinHpFraction = .3f; public readonly float MinHpFraction = .3f;
[ActorReference]
public readonly string[] ActorTypes = { "e1" }; public readonly string[] ActorTypes = { "e1" };
} }

View File

@@ -24,7 +24,9 @@ namespace OpenRA.Mods.RA
{ {
class ExplodesInfo : TraitInfo<Explodes> class ExplodesInfo : TraitInfo<Explodes>
{ {
[WeaponReference]
public readonly string Weapon = "UnitExplode"; public readonly string Weapon = "UnitExplode";
[WeaponReference]
public readonly string EmptyWeapon = "UnitExplode"; public readonly string EmptyWeapon = "UnitExplode";
} }

View File

@@ -31,8 +31,8 @@ namespace OpenRA.Mods.RA
if (e.DamageState == DamageState.Dead) if (e.DamageState == DamageState.Dead)
{ {
// Prevent TK from giving exp // Prevent TK from giving exp
//if (e.Attacker == null || e.Attacker.Owner.Stances[ self.Owner ] == Stance.Ally ) if (e.Attacker == null || e.Attacker.Owner.Stances[ self.Owner ] == Stance.Ally )
// return; return;
var info = self.Info.Traits.Get<GivesExperienceInfo>(); var info = self.Info.Traits.Get<GivesExperienceInfo>();
var valued = self.Info.Traits.GetOrDefault<ValuedInfo>(); var valued = self.Info.Traits.GetOrDefault<ValuedInfo>();

View File

@@ -32,6 +32,7 @@ namespace OpenRA.Mods.RA
public readonly int PipCount = 7; public readonly int PipCount = 7;
public readonly PipType PipColor = PipType.Yellow; public readonly PipType PipColor = PipType.Yellow;
public readonly string[] Resources = { }; public readonly string[] Resources = { };
[WeaponReference]
public readonly string DeathWeapon = null; public readonly string DeathWeapon = null;
public object Create(ActorInitializer init) { return new Harvester(init.self, this); } public object Create(ActorInitializer init) { return new Harvester(init.self, this); }

View File

@@ -24,6 +24,7 @@ namespace OpenRA.Mods.RA
{ {
public class FreeActorInfo : ITraitInfo public class FreeActorInfo : ITraitInfo
{ {
[ActorReference]
public readonly string Actor = null; public readonly string Actor = null;
public readonly string InitialActivity = null; public readonly string InitialActivity = null;
public readonly int2 SpawnOffset = int2.Zero; public readonly int2 SpawnOffset = int2.Zero;

View File

@@ -22,7 +22,11 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class LeavesHuskInfo : TraitInfo<LeavesHusk> { public readonly string HuskActor = null; } class LeavesHuskInfo : TraitInfo<LeavesHusk>
{
[ActorReference]
public readonly string HuskActor = null;
}
class LeavesHusk : INotifyDamage class LeavesHusk : INotifyDamage
{ {

View File

@@ -29,6 +29,7 @@ namespace OpenRA.Mods.RA
class MineInfo : ITraitInfo class MineInfo : ITraitInfo
{ {
public readonly string[] CrushClasses = { }; public readonly string[] CrushClasses = { };
[WeaponReference]
public readonly string Weapon = "ATMine"; public readonly string Weapon = "ATMine";
public readonly bool AvoidFriendly = true; public readonly bool AvoidFriendly = true;

View File

@@ -29,8 +29,10 @@ namespace OpenRA.Mods.RA
{ {
class MinelayerInfo : TraitInfo<Minelayer> class MinelayerInfo : TraitInfo<Minelayer>
{ {
[ActorReference]
public readonly string Mine = "minv"; public readonly string Mine = "minv";
public readonly float MinefieldDepth = 1.5f; public readonly float MinefieldDepth = 1.5f;
[ActorReference]
public readonly string[] RearmBuildings = { "fix" }; public readonly string[] RearmBuildings = { "fix" };
} }

View File

@@ -67,6 +67,7 @@ namespace OpenRA.Mods.RA
// tag trait for the building // tag trait for the building
class NukeSiloInfo : ITraitInfo class NukeSiloInfo : ITraitInfo
{ {
[WeaponReference]
public readonly string MissileWeapon = ""; public readonly string MissileWeapon = "";
public object Create(ActorInitializer init) { return new NukeSilo(init.self); } public object Create(ActorInitializer init) { return new NukeSilo(init.self); }
} }

View File

@@ -36,6 +36,7 @@ namespace OpenRA.Mods.RA
public readonly int Capacity = 0; public readonly int Capacity = 0;
public readonly int ProcessTick = 25; public readonly int ProcessTick = 25;
public readonly int ProcessAmount = 50; public readonly int ProcessAmount = 50;
[WeaponReference]
public readonly string DeathWeapon = null; public readonly string DeathWeapon = null;
public object Create(ActorInitializer init) { return new OreRefinery(init.self, this); } public object Create(ActorInitializer init) { return new OreRefinery(init.self, this); }

View File

@@ -16,11 +16,8 @@
* 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.Linq;
using System.Collections.Generic;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Traits.Activities; using OpenRA.Traits.Activities;

View File

@@ -27,8 +27,11 @@ namespace OpenRA.Mods.RA
{ {
class ParatroopersPowerInfo : SupportPowerInfo class ParatroopersPowerInfo : SupportPowerInfo
{ {
[ActorReference]
public string[] DropItems = { }; public string[] DropItems = { };
[ActorReference]
public string UnitType = "badr"; public string UnitType = "badr";
[ActorReference]
public string FlareType = "flare"; public string FlareType = "flare";
public override object Create(ActorInitializer init) { return new ParatroopersPower(init.self, this); } public override object Create(ActorInitializer init) { return new ParatroopersPower(init.self, this); }

View File

@@ -20,10 +20,8 @@
using System; using System;
using System.Linq; using System.Linq;
using OpenRA.Traits.Activities;
using OpenRA.GameRules;
using OpenRA.Traits;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {

View File

@@ -16,15 +16,12 @@
* 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.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Traits.Activities;
using OpenRA.Mods.RA.Activities;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
public class ProducesHelicoptersInfo : ProductionInfo public class ProducesHelicoptersInfo : ProductionInfo

View File

@@ -27,6 +27,7 @@ namespace OpenRA.Mods.RA
{ {
class RepairableNearInfo : TraitInfo<RepairableNear> class RepairableNearInfo : TraitInfo<RepairableNear>
{ {
[ActorReference]
public readonly string[] Buildings = { "spen", "syrd" }; public readonly string[] Buildings = { "spen", "syrd" };
} }

View File

@@ -16,16 +16,17 @@
* 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 OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class ReplaceWithActorInfo : ITraitInfo class ReplaceWithActorInfo : ITraitInfo
{ {
[ActorReference]
public readonly string Actor = null; public readonly string Actor = null;
public object Create(ActorInitializer init) { return new ReplaceWithActor(init.self, this); } public object Create(ActorInitializer init) { return new ReplaceWithActor(init.self, this); }
} }

View File

@@ -18,11 +18,8 @@
*/ */
#endregion #endregion
using System;
using OpenRA.Traits.Activities;
using System.Drawing;
using OpenRA.Traits;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {

View File

@@ -19,8 +19,8 @@
#endregion #endregion
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA

View File

@@ -18,11 +18,10 @@
*/ */
#endregion #endregion
using System.Collections.Generic; using OpenRA.Mods.RA.Activities;
using OpenRA.Orders;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Traits.Activities; using OpenRA.Traits.Activities;
using OpenRA.Orders;
using OpenRA.Mods.RA.Activities;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {

View File

@@ -19,8 +19,6 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA