From e344b95a6f8942b8d86e6e131c871cb227597edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 18 Jan 2014 15:45:22 +0100 Subject: [PATCH 1/2] simplified Lua syntax for GDI02 --- mods/cnc/maps/gdi02/gdi02.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mods/cnc/maps/gdi02/gdi02.lua b/mods/cnc/maps/gdi02/gdi02.lua index 6b2d9afe81..978fcf0265 100644 --- a/mods/cnc/maps/gdi02/gdi02.lua +++ b/mods/cnc/maps/gdi02/gdi02.lua @@ -28,9 +28,8 @@ end NodAttack = function() local nodUnits = Mission.GetGroundAttackersOf(enemy) - local nodUnitsLeft = table.getn(nodUnits) - if (nodUnitsLeft > AttackerSquadSize * 2) then - attackers = Utils.Skip(nodUnits, nodUnitsLeft - AttackerSquadSize) + if #nodUnits > AttackerSquadSize * 2 then + attackers = Utils.Skip(nodUnits, #nodUnits - AttackerSquadSize) local attackSquad = Team.New(attackers) Team.Do(attackSquad, function(unit) Actor.AttackMove(unit, waypoint2.location) From 16ddecdcbf2ecc310bb7c7ffb2dc4e8433cc6da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 26 Jan 2014 07:54:52 +0100 Subject: [PATCH 2/2] StyleCop --- OpenRA.Game/ActorInitializer.cs | 30 ++++++++++++++++-------------- OpenRA.Mods.RA/Cargo.cs | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/OpenRA.Game/ActorInitializer.cs b/OpenRA.Game/ActorInitializer.cs index 56502cc00b..72a0d200aa 100755 --- a/OpenRA.Game/ActorInitializer.cs +++ b/OpenRA.Game/ActorInitializer.cs @@ -21,45 +21,45 @@ namespace OpenRA internal TypeDictionary dict; - public ActorInitializer( Actor actor, TypeDictionary dict ) + public ActorInitializer(Actor actor, TypeDictionary dict) { this.self = actor; this.dict = dict; } public T Get() where T : IActorInit { return dict.Get(); } - public U Get() where T : IActorInit { return dict.Get().Value( world ); } + public U Get() where T : IActorInit { return dict.Get().Value(world); } public bool Contains() where T : IActorInit { return dict.Contains(); } } - public interface IActorInit {} + public interface IActorInit { } public interface IActorInit : IActorInit { - T Value( World world ); + T Value(World world); } public class FacingInit : IActorInit { [FieldFromYamlKey] public readonly int value = 128; public FacingInit() { } - public FacingInit( int init ) { value = init; } - public int Value( World world ) { return value; } + public FacingInit(int init) { value = init; } + public int Value(World world) { return value; } } public class TurretFacingInit : IActorInit { [FieldFromYamlKey] public readonly int value = 128; public TurretFacingInit() { } - public TurretFacingInit( int init ) { value = init; } - public int Value( World world ) { return value; } + public TurretFacingInit(int init) { value = init; } + public int Value(World world) { return value; } } public class LocationInit : IActorInit { [FieldFromYamlKey] public readonly int2 value = int2.Zero; public LocationInit() { } - public LocationInit( CPos init ) { value = init.ToInt2(); } + public LocationInit(CPos init) { value = init.ToInt2(); } public CPos Value(World world) { return (CPos)value; } } @@ -86,18 +86,20 @@ namespace OpenRA Player player; public OwnerInit() { } - public OwnerInit( string playerName ) { this.PlayerName = playerName; } + public OwnerInit(string playerName) { this.PlayerName = playerName; } - public OwnerInit( Player player ) { + public OwnerInit(Player player) + { this.player = player; this.PlayerName = player.InternalName; } - public Player Value( World world ) + public Player Value(World world) { - if( player != null ) + if (player != null) return player; - return world.Players.First( x => x.InternalName == PlayerName ); + + return world.Players.First(x => x.InternalName == PlayerName); } } } diff --git a/OpenRA.Mods.RA/Cargo.cs b/OpenRA.Mods.RA/Cargo.cs index e202cba0d7..c0363d3386 100644 --- a/OpenRA.Mods.RA/Cargo.cs +++ b/OpenRA.Mods.RA/Cargo.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA if (init.Contains()) { - cargo = init.Get().ToList(); + cargo = init.Get().ToList(); totalWeight = cargo.Sum(c => GetWeight(c)); } else