Skip to content

Commit

Permalink
Remove unused parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender authored and abcdefg30 committed Apr 1, 2022
1 parent ea243b8 commit 0e7ad43
Show file tree
Hide file tree
Showing 205 changed files with 451 additions and 455 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Expand Up @@ -141,6 +141,9 @@ dotnet_diagnostic.IDE0040.severity = warning
# Make field readonly.
dotnet_diagnostic.IDE0044.severity = warning

# Unused parameter.
dotnet_diagnostic.IDE0060.severity = warning

# Naming rule violation.
dotnet_diagnostic.IDE1006.severity = warning

Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Game/GameRules/Ruleset.cs
Expand Up @@ -131,7 +131,7 @@ public static Ruleset LoadDefaults(ModData modData)
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
var weapons = MergeOrDefault("Manifest,Weapons", fs, m.Weapons, null, null,
k => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
k => new WeaponInfo(k.Value));
var voices = MergeOrDefault("Manifest,Voices", fs, m.Voices, null, null,
k => new SoundInfo(k.Value));
Expand Down Expand Up @@ -190,7 +190,7 @@ public static Ruleset LoadDefaultsForTileSet(ModData modData, string tileSet)
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
var weapons = MergeOrDefault("Weapons", fileSystem, m.Weapons, mapWeapons, dr.Weapons,
k => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
k => new WeaponInfo(k.Value));
var voices = MergeOrDefault("Voices", fileSystem, m.Voices, mapVoices, dr.Voices,
k => new SoundInfo(k.Value));
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/GameRules/WeaponInfo.cs
Expand Up @@ -127,7 +127,7 @@ public sealed class WeaponInfo
[FieldLoader.LoadUsing(nameof(LoadWarheads))]
public readonly List<IWarhead> Warheads = new List<IWarhead>();

public WeaponInfo(string name, MiniYaml content)
public WeaponInfo(MiniYaml content)
{
// Resolve any weapon-level yaml inheritance or removals
// HACK: The "Defaults" sequence syntax prevents us from doing this generally during yaml parsing
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Graphics/AnimationWithOffset.cs
Expand Up @@ -35,7 +35,7 @@ public AnimationWithOffset(Animation a, Func<WVec> offset, Func<bool> disable, F
ZOffset = zOffset;
}

public IRenderable[] Render(Actor self, WorldRenderer wr, PaletteReference pal)
public IRenderable[] Render(Actor self, PaletteReference pal)
{
var center = self.CenterPosition;
var offset = OffsetFunc?.Invoke() ?? WVec.Zero;
Expand Down
1 change: 1 addition & 0 deletions OpenRA.Game/Graphics/Model.cs
Expand Up @@ -84,6 +84,7 @@ public bool HasModelSequence(string model, string sequence)
}
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
public PlaceholderModelSequenceLoader(ModData modData) { }

public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelDefinitions)
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Graphics/ModelRenderer.cs
Expand Up @@ -65,7 +65,7 @@ public void SetPalette(ITexture palette)
shader.SetTexture("Palette", palette);
}

public void SetViewportParams(Size screen, int2 scroll)
public void SetViewportParams()
{
var a = 2f / renderer.SheetSize;
var view = new[]
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Graphics/RgbaColorRenderer.cs
Expand Up @@ -261,7 +261,7 @@ static Vertex VertexWithColor(in float3 xyz, Color color)
return new Vertex(xyz, cr, cg, cb, ca, 0, 0);
}

public void FillEllipse(in float3 tl, in float3 br, Color color, int vertices = 32, BlendMode blendMode = BlendMode.Alpha)
public void FillEllipse(in float3 tl, in float3 br, Color color, BlendMode blendMode = BlendMode.Alpha)
{
// TODO: Create an ellipse polygon instead
var a = (br.X - tl.X) / 2;
Expand Down
6 changes: 3 additions & 3 deletions OpenRA.Game/Graphics/TargetLineRenderable.cs
Expand Up @@ -56,14 +56,14 @@ public void Render(WorldRenderer wr)
foreach (var b in waypoints.Skip(1).Select(pos => wr.Viewport.WorldToViewPx(wr.Screen3DPosition(pos))))
{
Game.Renderer.RgbaColorRenderer.DrawLine(a, b, width, color);
DrawTargetMarker(wr, color, b, markerSize);
DrawTargetMarker(color, b, markerSize);
a = b;
}

DrawTargetMarker(wr, color, first);
DrawTargetMarker(color, first);
}

public static void DrawTargetMarker(WorldRenderer wr, Color color, int2 screenPos, int size = 1)
public static void DrawTargetMarker(Color color, int2 screenPos, int size = 1)
{
var offset = new int2(size, size);
var tl = screenPos - offset;
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/ModData.cs
Expand Up @@ -87,7 +87,7 @@ public ModData(Manifest mod, InstalledMods mods, bool useLoadScreen = false)

var sequenceFormat = Manifest.Get<SpriteSequenceFormat>();
var sequenceLoader = ObjectCreator.FindType(sequenceFormat.Type + "Loader");
var sequenceCtor = sequenceLoader != null ? sequenceLoader.GetConstructor(new[] { typeof(ModData) }) : null;
var sequenceCtor = sequenceLoader?.GetConstructor(new[] { typeof(ModData) });
if (sequenceLoader == null || !sequenceLoader.GetInterfaces().Contains(typeof(ISpriteSequenceLoader)) || sequenceCtor == null)
throw new InvalidOperationException($"Unable to find a sequence loader for type '{sequenceFormat.Type}'.");

Expand Down
12 changes: 5 additions & 7 deletions OpenRA.Game/Orders/UnitOrderGenerator.cs
Expand Up @@ -44,9 +44,8 @@ static Target TargetForInput(World world, CPos cell, int2 worldPixel, MouseInput
public virtual IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
var target = TargetForInput(world, cell, worldPixel, mi);
var actorsAt = world.ActorMap.GetActorsAt(cell).ToList();
var orders = world.Selection.Actors
.Select(a => OrderForUnit(a, target, actorsAt, cell, mi))
.Select(a => OrderForUnit(a, target, cell, mi))
.Where(o => o != null)
.ToList();

Expand All @@ -70,15 +69,14 @@ public virtual IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel,
public virtual string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
var target = TargetForInput(world, cell, worldPixel, mi);
var actorsAt = world.ActorMap.GetActorsAt(cell).ToList();

bool useSelect;
if (Game.Settings.Game.UseClassicMouseStyle && !InputOverridesSelection(world, worldPixel, mi))
useSelect = target.Type == TargetType.Actor && target.Actor.Info.HasTraitInfo<ISelectableInfo>();
else
{
var ordersWithCursor = world.Selection.Actors
.Select(a => OrderForUnit(a, target, actorsAt, cell, mi))
.Select(a => OrderForUnit(a, target, cell, mi))
.Where(o => o != null && o.Cursor != null);

var cursorOrder = ordersWithCursor.MaxByOrDefault(o => o.Order.OrderPriority);
Expand Down Expand Up @@ -120,7 +118,7 @@ public virtual bool InputOverridesSelection(World world, int2 xy, MouseInput mi)

foreach (var a in world.Selection.Actors)
{
var o = OrderForUnit(a, target, actorsAt, cell, mi);
var o = OrderForUnit(a, target, cell, mi);
if (o != null && o.Order.TargetOverridesSelection(a, target, actorsAt, cell, modifiers))
return true;
}
Expand All @@ -135,7 +133,7 @@ public virtual bool InputOverridesSelection(World world, int2 xy, MouseInput mi)
/// First priority is given to orders that interact with the given actors.
/// Second priority is given to actors in the given cell.
/// </summary>
static UnitOrderResult OrderForUnit(Actor self, Target target, List<Actor> actorsAt, CPos xy, MouseInput mi)
static UnitOrderResult OrderForUnit(Actor self, Target target, CPos xy, MouseInput mi)
{
if (mi.Button != Game.Settings.Game.MouseButtonPreference.Action)
return null;
Expand Down Expand Up @@ -174,7 +172,7 @@ static UnitOrderResult OrderForUnit(Actor self, Target target, List<Actor> actor
{
var localModifiers = modifiers;
string cursor = null;
if (o.Order.CanTarget(self, target, actorsAt, ref localModifiers, ref cursor))
if (o.Order.CanTarget(self, target, ref localModifiers, ref cursor))
return new UnitOrderResult(self, o.Order, o.Trait, cursor, target);
}

Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Renderer.cs
Expand Up @@ -254,7 +254,7 @@ public void BeginWorld(Rectangle worldViewport)
if (lastWorldViewport != worldViewport)
{
WorldSpriteRenderer.SetViewportParams(worldSheet.Size, worldDownscaleFactor, depthMargin, worldViewport.Location);
WorldModelRenderer.SetViewportParams(worldSheet.Size, worldViewport.Location);
WorldModelRenderer.SetViewportParams();

lastWorldViewport = worldViewport;
}
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Scripting/ScriptContext.cs
Expand Up @@ -252,7 +252,7 @@ public void WorldLoaded()
worldLoaded.Call().Dispose();
}

public void Tick(Actor self)
public void Tick()
{
if (FatalErrorOccurred || disposed)
return;
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Scripting/ScriptMemberWrapper.cs
Expand Up @@ -108,7 +108,7 @@ public LuaValue Get(LuaRuntime runtime)
throw new LuaException($"The property '{Member.Name}' is write-only");
}

public void Set(LuaRuntime runtime, LuaValue value)
public void Set(LuaValue value)
{
if (IsSetProperty)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Scripting/ScriptObjectWrapper.cs
Expand Up @@ -63,7 +63,7 @@ protected void Bind(IEnumerable<object> clrObjects)
if (!members.TryGetValue(name, out var wrapper))
throw new LuaException(MemberNotFoundError(name));

wrapper.Set(runtime, value);
wrapper.Set(value);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Game/Server/Server.cs
Expand Up @@ -1032,7 +1032,7 @@ void InterpretServerOrder(Connection conn, Order o)
}
}

public void ReceivePing(Connection conn, int[] pingHistory, byte queueLength)
public void ReceivePing(Connection conn, int[] pingHistory)
{
// Levels set relative to the default order lag of 3 net ticks (360ms)
// TODO: Adjust this once dynamic lag is implemented
Expand Down Expand Up @@ -1389,7 +1389,7 @@ public ConnectionPingEvent(Connection connection, int[] pingHistory, byte queueL

void IServerEvent.Invoke(Server server)
{
server.ReceivePing(connection, pingHistory, queueLength);
server.ReceivePing(connection, pingHistory);
}
}

Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Game/Traits/Player/FrozenActorLayer.cs
Expand Up @@ -195,7 +195,7 @@ public void Flash(float3 tint)
flashAlpha = null;
}

public IEnumerable<IRenderable> Render(WorldRenderer wr)
public IEnumerable<IRenderable> Render()
{
if (Shrouded)
return NoRenderables;
Expand Down Expand Up @@ -323,7 +323,7 @@ public virtual IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr)
{
return world.ScreenMap.RenderableFrozenActorsInBox(owner, wr.Viewport.TopLeft, wr.Viewport.BottomRight)
.Where(f => f.Visible)
.SelectMany(ff => ff.Render(wr));
.SelectMany(ff => ff.Render());
}

public IEnumerable<Rectangle> ScreenBounds(Actor self, WorldRenderer wr)
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Traits/Player/Shroud.cs
Expand Up @@ -299,7 +299,7 @@ public void RemoveSource(object key)
sources.Remove(key);
}

public void ExploreProjectedCells(World world, IEnumerable<PPos> cells)
public void ExploreProjectedCells(IEnumerable<PPos> cells)
{
foreach (var puv in cells)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Traits/TraitsInterfaces.cs
Expand Up @@ -138,7 +138,7 @@ public interface IOrderTargeter
{
string OrderID { get; }
int OrderPriority { get; }
bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor);
bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor);
bool IsQueued { get; }
bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers);
}
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/VoiceExts.cs
Expand Up @@ -49,7 +49,7 @@ public static bool HasVoice(this Actor self, string voice)
return self.TraitsImplementing<IVoiced>().Any(x => x.HasVoice(self, voice));
}

public static void PlayVoiceForOrders(this World w, Order[] orders)
public static void PlayVoiceForOrders(this Order[] orders)
{
// Find the first actor with a phrase to say
foreach (var o in orders)
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Cnc/Activities/Leap.cs
Expand Up @@ -36,7 +36,7 @@ public class Leap : Activity
int ticks = 0;
WPos targetPosition;

public Leap(Actor self, in Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible)
public Leap(in Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible)
{
this.mobile = mobile;
this.targetMobile = targetMobile;
Expand Down Expand Up @@ -93,7 +93,7 @@ public override bool Tick(Actor self)

// Update movement which results in movementType set to MovementType.None.
// This is needed to prevent the move animation from playing.
mobile.UpdateMovement(self);
mobile.UpdateMovement();

// Revoke the condition before attacking, as it is usually used to pause the attack trait
attack.RevokeLeapCondition(self);
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Cnc/Activities/LeapAttack.cs
Expand Up @@ -138,7 +138,7 @@ public override bool Tick(Actor self)
return false;
}

QueueChild(new Leap(self, target, mobile, targetMobile, info.Speed.Length, attack, edible));
QueueChild(new Leap(target, mobile, targetMobile, info.Speed.Length, attack, edible));

// Re-queue the child activities to kill the target if it didn't die in one go
return false;
Expand Down
1 change: 1 addition & 0 deletions OpenRA.Mods.Cnc/Graphics/VoxelModelSequenceLoader.cs
Expand Up @@ -21,6 +21,7 @@ public class VoxelModelSequenceLoader : IModelSequenceLoader
{
public Action<string> OnMissingModelError { get; set; }

[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
public VoxelModelSequenceLoader(ModData modData) { }

public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelSequences)
Expand Down
6 changes: 3 additions & 3 deletions OpenRA.Mods.Cnc/Traits/Attack/AttackTDGunboatTurreted.cs
Expand Up @@ -31,7 +31,7 @@ public AttackTDGunboatTurreted(Actor self, AttackTDGunboatTurretedInfo info)

public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
return new AttackTDGunboatTurretedActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
return new AttackTDGunboatTurretedActivity(self, newTarget, forceAttack, targetLineColor);
}

class AttackTDGunboatTurretedActivity : Activity
Expand All @@ -42,7 +42,7 @@ class AttackTDGunboatTurretedActivity : Activity
readonly Color? targetLineColor;
bool hasTicked;

public AttackTDGunboatTurretedActivity(Actor self, in Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
public AttackTDGunboatTurretedActivity(Actor self, in Target target, bool forceAttack, Color? targetLineColor = null)
{
attack = self.Trait<AttackTDGunboatTurreted>();
this.target = target;
Expand All @@ -66,7 +66,7 @@ public override bool Tick(Actor self)
if (hasTicked && attack.RequestedTarget.Type == TargetType.Invalid)
return true;

attack.SetRequestedTarget(self, target);
attack.SetRequestedTarget(target);
hasTicked = true;
}

Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Cnc/Traits/DrainPrerequisitePowerOnDamage.cs
Expand Up @@ -26,14 +26,14 @@ public class DrainPrerequisitePowerOnDamageInfo : ConditionalTraitInfo
[Desc("Damage is divided by this number when converting damage to drain ticks.")]
public readonly int DamageDivisor = 600;

public override object Create(ActorInitializer init) { return new DrainPrerequisitePowerOnDamage(init.Self, this); }
public override object Create(ActorInitializer init) { return new DrainPrerequisitePowerOnDamage(this); }
}

public class DrainPrerequisitePowerOnDamage : ConditionalTrait<DrainPrerequisitePowerOnDamageInfo>, INotifyOwnerChanged, IDamageModifier
{
SupportPowerManager spm;

public DrainPrerequisitePowerOnDamage(Actor self, DrainPrerequisitePowerOnDamageInfo info)
public DrainPrerequisitePowerOnDamage(DrainPrerequisitePowerOnDamageInfo info)
: base(info) { }

protected override void Created(Actor self)
Expand Down
Expand Up @@ -30,14 +30,14 @@ class InfiltrateForExplorationInfo : TraitInfo
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;

public override object Create(ActorInitializer init) { return new InfiltrateForExploration(init.Self, this); }
public override object Create(ActorInitializer init) { return new InfiltrateForExploration(this); }
}

class InfiltrateForExploration : INotifyInfiltrated
{
readonly InfiltrateForExplorationInfo info;

public InfiltrateForExploration(Actor self, InfiltrateForExplorationInfo info)
public InfiltrateForExploration(InfiltrateForExplorationInfo info)
{
this.info = info;
}
Expand Down
6 changes: 3 additions & 3 deletions OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs
Expand Up @@ -75,7 +75,7 @@ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool
return new Order(order.OrderID, self, target, queued);
}

bool IsValidOrder(Actor self, Order order)
bool IsValidOrder(Order order)
{
if (IsTraitDisabled)
return false;
Expand All @@ -92,7 +92,7 @@ bool IsValidOrder(Actor self, Order order)

public string VoicePhraseForOrder(Actor self, Order order)
{
return order.OrderString == "Infiltrate" && IsValidOrder(self, order)
return order.OrderString == "Infiltrate" && IsValidOrder(order)
? Info.Voice : null;
}

Expand All @@ -113,7 +113,7 @@ public bool CanInfiltrateTarget(Actor self, in Target target)

public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString != "Infiltrate" || !IsValidOrder(self, order) || IsTraitDisabled)
if (order.OrderString != "Infiltrate" || !IsValidOrder(order) || IsTraitDisabled)
return;

if (!CanInfiltrateTarget(self, order.Target))
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Cnc/Traits/Minelayer.cs
Expand Up @@ -360,7 +360,7 @@ public BeginMinefieldOrderTargeter(string cursor)

public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }

public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Terrain)
return false;
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Cnc/Traits/PortableChrono.cs
Expand Up @@ -178,7 +178,7 @@ public PortableChronoOrderTargeter(string targetCursor)
public bool IsQueued { get; protected set; }
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }

public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{
if (modifiers.HasModifier(TargetModifiers.ForceMove))
{
Expand Down

0 comments on commit 0e7ad43

Please sign in to comment.