diff --git a/.editorconfig b/.editorconfig index d543a2eb07..ae322722d9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -144,6 +144,9 @@ dotnet_diagnostic.IDE0040.severity = warning # Make field readonly. dotnet_diagnostic.IDE0044.severity = warning +# Unused private member. +dotnet_diagnostic.IDE0052.severity = warning + # Unused parameter. dotnet_diagnostic.IDE0060.severity = warning diff --git a/OpenRA.Game/InstalledMods.cs b/OpenRA.Game/InstalledMods.cs index f3492373b3..7d7f3be976 100644 --- a/OpenRA.Game/InstalledMods.cs +++ b/OpenRA.Game/InstalledMods.cs @@ -15,21 +15,18 @@ using System.Collections.Generic; using System.IO; using System.Linq; using OpenRA.FileSystem; -using OpenRA.Graphics; namespace OpenRA { public class InstalledMods : IReadOnlyDictionary { readonly Dictionary mods; - readonly SheetBuilder sheetBuilder; /// Initializes the collection of locally installed mods. /// Filesystem paths to search for mod packages. /// Filesystem paths to additional mod packages. public InstalledMods(IEnumerable searchPaths, IEnumerable explicitPaths) { - sheetBuilder = new SheetBuilder(SheetType.BGRA, 256); mods = GetInstalledMods(searchPaths, explicitPaths); } diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 6fd59e1a41..9600d080ae 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -1479,7 +1479,11 @@ namespace OpenRA.Server { readonly Connection connection; readonly int[] pingHistory; + + // TODO: future net code changes + #pragma warning disable IDE0052 readonly byte queueLength; + #pragma warning restore IDE0052 public ConnectionPingEvent(Connection connection, int[] pingHistory, byte queueLength) { diff --git a/OpenRA.Game/Traits/Player/Shroud.cs b/OpenRA.Game/Traits/Player/Shroud.cs index 3a0f6444e9..d0dcb83ab7 100644 --- a/OpenRA.Game/Traits/Player/Shroud.cs +++ b/OpenRA.Game/Traits/Player/Shroud.cs @@ -87,7 +87,6 @@ namespace OpenRA.Traits [Flags] public enum CellVisibility : byte { Hidden = 0x0, Explored = 0x1, Visible = 0x2 } - readonly Actor self; readonly ShroudInfo info; readonly Map map; @@ -134,7 +133,6 @@ namespace OpenRA.Traits public Shroud(Actor self, ShroudInfo info) { - this.self = self; this.info = info; map = self.World.Map; diff --git a/OpenRA.Mods.Cnc/Effects/GpsDotEffect.cs b/OpenRA.Mods.Cnc/Effects/GpsDotEffect.cs index 2eba71bd67..8072a05ada 100644 --- a/OpenRA.Mods.Cnc/Effects/GpsDotEffect.cs +++ b/OpenRA.Mods.Cnc/Effects/GpsDotEffect.cs @@ -26,7 +26,6 @@ namespace OpenRA.Mods.Cnc.Effects readonly Animation anim; readonly PlayerDictionary dotStates; - readonly IDefaultVisibility visibility; readonly IVisibilityModifier[] visibilityModifiers; class DotState @@ -52,7 +51,6 @@ namespace OpenRA.Mods.Cnc.Effects anim = new Animation(actor.World, info.Image); anim.PlayRepeating(info.String); - visibility = actor.Trait(); visibilityModifiers = actor.TraitsImplementing().ToArray(); dotStates = new PlayerDictionary(actor.World, diff --git a/OpenRA.Mods.Cnc/UtilityCommands/ImportTSMapCommand.cs b/OpenRA.Mods.Cnc/UtilityCommands/ImportTSMapCommand.cs index 5681c86d41..70ffb4cc0b 100644 --- a/OpenRA.Mods.Cnc/UtilityCommands/ImportTSMapCommand.cs +++ b/OpenRA.Mods.Cnc/UtilityCommands/ImportTSMapCommand.cs @@ -239,9 +239,6 @@ namespace OpenRA.Mods.Cnc.UtilityCommands { 0x03, new byte[] { 0x7E } } }; - // Veins and vein holes - static readonly int[] ValidVeinNeighbours = { 0x7E, 0xA7, 0xB2 }; - static readonly Dictionary DeployableActors = new Dictionary() { { "gadpsa", "lpst" }, diff --git a/OpenRA.Mods.Common/Activities/DeliverUnit.cs b/OpenRA.Mods.Common/Activities/DeliverUnit.cs index cf10bed5e6..8d4adab131 100644 --- a/OpenRA.Mods.Common/Activities/DeliverUnit.cs +++ b/OpenRA.Mods.Common/Activities/DeliverUnit.cs @@ -20,7 +20,6 @@ namespace OpenRA.Mods.Common.Activities public class DeliverUnit : Activity { readonly Carryall carryall; - readonly BodyOrientation body; readonly bool assignTargetOnFirstRun; readonly WDist deliverRange; readonly Color? targetLineColor; @@ -40,7 +39,6 @@ namespace OpenRA.Mods.Common.Activities this.targetLineColor = targetLineColor; carryall = self.Trait(); - body = self.Trait(); } protected override void OnFirstRun(Actor self) diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs index a75166d812..6afda127c7 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Widgets editorActionManager = world.WorldActor.Trait(); editorCursor = world.WorldActor.Trait(); resourceLayer = world.WorldActor.Trait(); - action = new AddResourcesEditorAction(world.Map, resourceType, resourceLayer); + action = new AddResourcesEditorAction(resourceType, resourceLayer); cursorToken = editorCursor.SetResource(wr, resourceType); } @@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Widgets else if (resourceAdded && mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up) { editorActionManager.Add(action); - action = new AddResourcesEditorAction(world.Map, ResourceType, resourceLayer); + action = new AddResourcesEditorAction(ResourceType, resourceLayer); resourceAdded = false; } @@ -107,14 +107,12 @@ namespace OpenRA.Mods.Common.Widgets { public string Text { get; private set; } - readonly Map map; readonly IResourceLayer resourceLayer; readonly string resourceType; readonly List cellResources = new List(); - public AddResourcesEditorAction(Map map, string resourceType, IResourceLayer resourceLayer) + public AddResourcesEditorAction(string resourceType, IResourceLayer resourceLayer) { - this.map = map; this.resourceType = resourceType; this.resourceLayer = resourceLayer; } diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index f2318dfecb..c39b4d11ee 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -1231,13 +1231,11 @@ namespace OpenRA.Mods.Common.Traits class AssociateWithAirfieldActivity : Activity { - readonly Actor self; readonly Aircraft aircraft; readonly int delay; public AssociateWithAirfieldActivity(Actor self, int delay = 0) { - this.self = self; aircraft = self.Trait(); IsInterruptible = false; this.delay = delay; diff --git a/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs index 1e2322a61a..de09596e38 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs @@ -61,8 +61,6 @@ namespace OpenRA.Mods.Common.Traits readonly World world; readonly Player player; - readonly Predicate unitCannotBeOrdered; - IBotPositionsUpdated[] notifyPositionsUpdated; IBotRequestUnitProduction[] requestUnitProduction; @@ -75,7 +73,6 @@ namespace OpenRA.Mods.Common.Traits { world = self.World; player = self.Owner; - unitCannotBeOrdered = a => a.Owner != player || a.IsDead || !a.IsInWorld; } protected override void Created(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteControlGroupDecoration.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteControlGroupDecoration.cs index 7d0f5f91de..f35518fa16 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteControlGroupDecoration.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteControlGroupDecoration.cs @@ -40,14 +40,11 @@ namespace OpenRA.Mods.Common.Traits.Render public class WithSpriteControlGroupDecoration : IDecoration { public readonly WithSpriteControlGroupDecorationInfo Info; - readonly Actor self; readonly Animation anim; public WithSpriteControlGroupDecoration(Actor self, WithSpriteControlGroupDecorationInfo info) { Info = info; - this.self = self; - anim = new Animation(self.World, Info.Image); } diff --git a/OpenRA.Mods.Common/Traits/Render/WithTextControlGroupDecoration.cs b/OpenRA.Mods.Common/Traits/Render/WithTextControlGroupDecoration.cs index 9612b1f7a6..0c7dc74346 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithTextControlGroupDecoration.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithTextControlGroupDecoration.cs @@ -49,7 +49,6 @@ namespace OpenRA.Mods.Common.Traits.Render { readonly WithTextControlGroupDecorationInfo info; readonly SpriteFont font; - readonly Actor self; readonly CachedTransform label; Color color; @@ -57,7 +56,6 @@ namespace OpenRA.Mods.Common.Traits.Render public WithTextControlGroupDecoration(Actor self, WithTextControlGroupDecorationInfo info) { this.info = info; - this.self = self; font = Game.Renderer.Fonts[info.Font]; color = info.UsePlayerColor ? self.Owner.Color : info.Color; diff --git a/OpenRA.Mods.Common/Traits/Render/WithVoxelTurret.cs b/OpenRA.Mods.Common/Traits/Render/WithVoxelTurret.cs index 82e29437b6..a07fa6bfbb 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithVoxelTurret.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithVoxelTurret.cs @@ -49,15 +49,11 @@ namespace OpenRA.Mods.Common.Traits.Render public class WithVoxelTurret : ConditionalTrait { - readonly Actor self; readonly Turreted turreted; - readonly BodyOrientation body; public WithVoxelTurret(Actor self, WithVoxelTurretInfo info) : base(info) { - this.self = self; - body = self.Trait(); turreted = self.TraitsImplementing() .First(tt => tt.Name == Info.Turret); diff --git a/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs b/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs index c4dd6e691d..c39611976b 100644 --- a/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs +++ b/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs @@ -95,7 +95,6 @@ namespace OpenRA.Mods.Common.Traits { readonly TimeLimitManagerInfo info; readonly int ticksPerSecond; - MapOptions mapOptions; LabelWidget countdownLabel; CachedTransform countdown; int ticksRemaining; @@ -119,7 +118,6 @@ namespace OpenRA.Mods.Common.Traits void IWorldLoaded.WorldLoaded(World w, OpenRA.Graphics.WorldRenderer wr) { - mapOptions = w.WorldActor.Trait(); if (string.IsNullOrWhiteSpace(info.CountdownLabel) || string.IsNullOrWhiteSpace(info.CountdownText)) return;