From ef619a186c2c85703c739fef9257033cb109277b Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:27:09 +0100 Subject: [PATCH 01/20] Make ExternalCapturableBar fields readonly. --- OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs b/OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs index 02651c10f9..2634392f15 100644 --- a/OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs +++ b/OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs @@ -21,20 +21,20 @@ namespace OpenRA.Mods.Common.Traits class ExternalCapturableBar : ISelectionBar { - ExternalCapturable cap; + readonly ExternalCapturable capturable; public ExternalCapturableBar(Actor self) { - this.cap = self.Trait(); + capturable = self.Trait(); } public float GetValue() { // only show when building is being captured - if (!cap.CaptureInProgress) + if (!capturable.CaptureInProgress) return 0f; - return (float)cap.CaptureProgressTime / (cap.Info.CaptureCompleteTime * 25); + return (float)capturable.CaptureProgressTime / (capturable.Info.CaptureCompleteTime * 25); } public Color GetColor() { return Color.Orange; } From 080f1880b9e89aef840699bbb98acd32b054871e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:27:40 +0100 Subject: [PATCH 02/20] Make RenderBuildingTurreted fields readonly. --- .../Traits/Render/RenderBuildingTurreted.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs b/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs index 337847128a..413ee3f180 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits class RenderBuildingTurreted : RenderBuilding { - Turreted t; + readonly Turreted turreted; static Func MakeTurretFacingFunc(Actor self) { @@ -48,14 +48,14 @@ namespace OpenRA.Mods.Common.Traits public RenderBuildingTurreted(ActorInitializer init, RenderBuildingInfo info) : base(init, info, MakeTurretFacingFunc(init.Self)) { - t = init.Self.TraitsImplementing().FirstOrDefault(); - t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings; + turreted = init.Self.TraitsImplementing().FirstOrDefault(); + turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings; } public override void DamageStateChanged(Actor self, AttackInfo e) { base.DamageStateChanged(self, e); - t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings; + turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings; } } } From 4b4cc52aa04fb6fd3ec155a1ccf691238e49cb25 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:27:57 +0100 Subject: [PATCH 03/20] Make RenderDetectionCircle fields readonly. --- OpenRA.Mods.Common/Traits/Render/RenderDetectionCircle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Render/RenderDetectionCircle.cs b/OpenRA.Mods.Common/Traits/Render/RenderDetectionCircle.cs index 2c5e25b266..33f49144ef 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderDetectionCircle.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderDetectionCircle.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits class RenderDetectionCircle : IPostRenderSelection { - Actor self; + readonly Actor self; public RenderDetectionCircle(Actor self) { this.self = self; } From c6ecd772c4c40adeb693ab40aa4409f1d7e1fed5 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:28:19 +0100 Subject: [PATCH 04/20] Make RenderRangeCircle fields readonly. --- OpenRA.Mods.Common/Traits/Render/RenderRangeCircle.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/RenderRangeCircle.cs b/OpenRA.Mods.Common/Traits/Render/RenderRangeCircle.cs index 387a98b926..bf205f39b8 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderRangeCircle.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderRangeCircle.cs @@ -56,8 +56,8 @@ namespace OpenRA.Mods.Common.Traits class RenderRangeCircle : IPostRenderSelection { - Actor self; - AttackBase attack; + readonly Actor self; + readonly AttackBase attack; public RenderRangeCircle(Actor self) { From 6a586fe501fa94999e96b7a79a52f547e8420ee2 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:28:56 +0100 Subject: [PATCH 05/20] Make RenderVoxels fields readonly. --- OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs b/OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs index 0895f1654f..42adab4235 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs @@ -73,11 +73,11 @@ namespace OpenRA.Mods.Common.Traits public class RenderVoxels : IRender, INotifyOwnerChanged { readonly List components = new List(); - Actor self; - RenderVoxelsInfo info; - IBodyOrientation body; - WRot camera; - WRot lightSource; + readonly Actor self; + readonly RenderVoxelsInfo info; + readonly IBodyOrientation body; + readonly WRot camera; + readonly WRot lightSource; public RenderVoxels(Actor self, RenderVoxelsInfo info) { From eeb101c040c61e67ea6a5c9318e60c3c6bd0f901 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:29:15 +0100 Subject: [PATCH 06/20] Make Contrail fields readonly. --- OpenRA.Mods.Common/Effects/Contrail.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Effects/Contrail.cs b/OpenRA.Mods.Common/Effects/Contrail.cs index 0a784df1a3..c5c54df60b 100644 --- a/OpenRA.Mods.Common/Effects/Contrail.cs +++ b/OpenRA.Mods.Common/Effects/Contrail.cs @@ -36,9 +36,11 @@ namespace OpenRA.Mods.Common.Effects class Contrail : ITick, IRender { - ContrailInfo info; + readonly ContrailInfo info; + readonly IBodyOrientation body; + + // This is a mutable struct, so it can't be readonly. ContrailRenderable trail; - IBodyOrientation body; public Contrail(Actor self, ContrailInfo info) { From 0065d27c6875328cf0d55f238ca01fc926182efc Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:29:38 +0100 Subject: [PATCH 07/20] Make WithBuildingExplosion fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs index c5f90e386b..bd9e55d052 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs @@ -35,8 +35,8 @@ namespace OpenRA.Mods.Common.Traits class WithBuildingExplosion : INotifyKilled { - WithBuildingExplosionInfo info; - BuildingInfo buildingInfo; + readonly WithBuildingExplosionInfo info; + readonly BuildingInfo buildingInfo; public WithBuildingExplosion(Actor self, WithBuildingExplosionInfo info) { From 8e6b76428497d8a33452382ce026353e0daa6773 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:29:55 +0100 Subject: [PATCH 08/20] Make WithBuildingPlacedAnimation fields readonly. --- .../Traits/Render/WithBuildingPlacedAnimation.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs index 783a3c6a4b..0e5b19bd93 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs @@ -23,8 +23,8 @@ namespace OpenRA.Mods.Common.Traits public class WithBuildingPlacedAnimation : INotifyBuildingPlaced, INotifyBuildComplete { - WithBuildingPlacedAnimationInfo info; - RenderSimple renderSimple; + readonly WithBuildingPlacedAnimationInfo info; + readonly RenderSimple renderSimple; bool buildComplete; public WithBuildingPlacedAnimation(Actor self, WithBuildingPlacedAnimationInfo info) From a2d069ce551fed1755aacd478223f7822ebbae41 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:30:11 +0100 Subject: [PATCH 09/20] Make WithHarvestOverlay fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithHarvestOverlay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithHarvestOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithHarvestOverlay.cs index ce6ed88fa1..295eadc1bb 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithHarvestOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithHarvestOverlay.cs @@ -30,8 +30,8 @@ namespace OpenRA.Mods.Common.Traits class WithHarvestOverlay : INotifyHarvesterAction { - WithHarvestOverlayInfo info; - Animation anim; + readonly WithHarvestOverlayInfo info; + readonly Animation anim; bool visible; public WithHarvestOverlay(Actor self, WithHarvestOverlayInfo info) From c5becaab9becebc218356dad852dfd7aedc1f68d Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:30:46 +0100 Subject: [PATCH 10/20] Make WithIdleOverlay fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs index 5a8014f3a3..e1e148a937 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs @@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits public class WithIdleOverlay : UpgradableTrait, INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyTransform { - Animation overlay; + readonly Animation overlay; bool buildComplete; public WithIdleOverlay(Actor self, WithIdleOverlayInfo info) From bb092ec07b251fb2730a56de73ad730466ef0628 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:31:00 +0100 Subject: [PATCH 11/20] Make WithRepairAnimation fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs index 7e4eecd030..d42abf1a1a 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits public class WithRepairAnimation : INotifyRepair { - WithRepairAnimationInfo info; + readonly WithRepairAnimationInfo info; public WithRepairAnimation(Actor self, WithRepairAnimationInfo info) { From f91b28a2a01a12f0ba1d5be09af04e056a248250 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:31:17 +0100 Subject: [PATCH 12/20] Make WithRepairOverlay fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs index bb3d8b9b9b..fccd3e285f 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits public class WithRepairOverlay : INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyRepair { - Animation overlay; + readonly Animation overlay; bool buildComplete; public WithRepairOverlay(Actor self, WithRepairOverlayInfo info) From d20819735c8ffae4126ddc519ae757be11caa333 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:31:38 +0100 Subject: [PATCH 13/20] Make WithRotor fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithRotor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithRotor.cs b/OpenRA.Mods.Common/Traits/Render/WithRotor.cs index 8db1df98a1..6a7f98693c 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRotor.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRotor.cs @@ -45,9 +45,9 @@ namespace OpenRA.Mods.Common.Traits public class WithRotor : ITick { - WithRotorInfo info; - Animation rotorAnim; - IMove movement; + readonly WithRotorInfo info; + readonly Animation rotorAnim; + readonly IMove movement; public WithRotor(Actor self, WithRotorInfo info) { From 4e27ac9aac539d9958ba974af01ffefd3610c4fc Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:32:05 +0100 Subject: [PATCH 14/20] Make WithTurret fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithTurret.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithTurret.cs b/OpenRA.Mods.Common/Traits/Render/WithTurret.cs index 8ff1251a6e..2259e1aa3e 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithTurret.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithTurret.cs @@ -58,11 +58,11 @@ namespace OpenRA.Mods.Common.Traits public class WithTurret : UpgradableTrait, ITick, INotifyDamageStateChanged { - RenderSprites rs; - IBodyOrientation body; - AttackBase ab; - Turreted t; - Armament[] arms; + readonly RenderSprites rs; + readonly IBodyOrientation body; + readonly AttackBase ab; + readonly Turreted t; + readonly Armament[] arms; public readonly Animation DefaultAnimation; public WithTurret(Actor self, WithTurretInfo info) From 038e8018b9f3394555be67b73d70f02d3279b0b1 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:32:21 +0100 Subject: [PATCH 15/20] Make WithBuildingPlacedOverlay fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedOverlay.cs index f886e826a7..87cf8a5ae6 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedOverlay.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits public class WithBuildingPlacedOverlay : INotifyBuildComplete, INotifySold, INotifyDamageStateChanged, INotifyBuildingPlaced, INotifyTransform { - Animation overlay; + readonly Animation overlay; bool buildComplete; public WithBuildingPlacedOverlay(Actor self, WithBuildingPlacedOverlayInfo info) From 322d941332cb503af97e3f88d0823f4c79895b50 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:32:40 +0100 Subject: [PATCH 16/20] Make WithProductionOverlay fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs index 2bf8988f92..da73cf03dd 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits public class WithProductionOverlay : INotifyDamageStateChanged, ITick, INotifyBuildComplete, INotifySold { - Animation overlay; + readonly Animation overlay; ProductionQueue queue; bool buildComplete; From a127c6b050b5aa3143140d57d3347657ef87e0d0 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:33:20 +0100 Subject: [PATCH 17/20] Make WithVoxelBarrel fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithVoxelBarrel.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithVoxelBarrel.cs b/OpenRA.Mods.Common/Traits/Render/WithVoxelBarrel.cs index 621af1dce1..4aaf785543 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithVoxelBarrel.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithVoxelBarrel.cs @@ -48,11 +48,11 @@ namespace OpenRA.Mods.Common.Traits public class WithVoxelBarrel { - WithVoxelBarrelInfo info; - Actor self; - Armament armament; - Turreted turreted; - IBodyOrientation body; + readonly WithVoxelBarrelInfo info; + readonly Actor self; + readonly Armament armament; + readonly Turreted turreted; + readonly IBodyOrientation body; public WithVoxelBarrel(Actor self, WithVoxelBarrelInfo info) { From 60305face7eaa2894b407e022fa185cac7daae31 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:33:34 +0100 Subject: [PATCH 18/20] Make WithVoxelBody fields readonly. --- OpenRA.Mods.Common/Traits/Render/WithVoxelBody.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithVoxelBody.cs b/OpenRA.Mods.Common/Traits/Render/WithVoxelBody.cs index ea840465b4..0f44be7fae 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithVoxelBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithVoxelBody.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits public class WithVoxelBody : IAutoSelectionSize { - int2 size; + readonly int2 size; public WithVoxelBody(Actor self, WithVoxelBodyInfo info) { From 6f60b16f060bd31d05ee399fa4098636a47893f5 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:35:17 +0100 Subject: [PATCH 19/20] Make SmokeTrailWhenDamaged fields readonly. --- OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs b/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs index a62020d088..26ca8f5d0b 100644 --- a/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs +++ b/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs @@ -28,8 +28,8 @@ namespace OpenRA.Mods.Common.Traits class SmokeTrailWhenDamaged : ITick { - IBodyOrientation body; - SmokeTrailWhenDamagedInfo info; + readonly SmokeTrailWhenDamagedInfo info; + readonly IBodyOrientation body; int ticks; public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info) From 3dda305524d243738d35422b9707b79a18db9d72 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Aug 2015 13:35:41 +0100 Subject: [PATCH 20/20] Make NukePower fields readonly. --- OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs index ac3548ffdd..cf4d141ab7 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits class NukePower : SupportPower { readonly NukePowerInfo info; - IBodyOrientation body; + readonly IBodyOrientation body; public NukePower(Actor self, NukePowerInfo info) : base(self, info)