Remove unnecessary value assignment (IDE0059)
This commit is contained in:
committed by
Gustas
parent
757c4d84c7
commit
6bd631618c
@@ -147,6 +147,9 @@ dotnet_diagnostic.IDE0044.severity = warning
|
||||
# Unused private member.
|
||||
dotnet_diagnostic.IDE0052.severity = warning
|
||||
|
||||
# Unnecessary value assignment.
|
||||
dotnet_diagnostic.IDE0059.severity = warning
|
||||
|
||||
# Unused parameter.
|
||||
dotnet_diagnostic.IDE0060.severity = warning
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA
|
||||
s = s.ToLowerInvariant();
|
||||
var components = s.Split('c');
|
||||
var cell = 0;
|
||||
var subcell = 0;
|
||||
int subcell;
|
||||
|
||||
switch (components.Length)
|
||||
{
|
||||
|
||||
@@ -224,13 +224,11 @@ namespace OpenRA.Mods.Cnc.FileFormats
|
||||
uint nTwoByteLen, bit;
|
||||
int nTwoBitLen;
|
||||
|
||||
var j = 0;
|
||||
|
||||
InitBigNum(nTmp, 0, len);
|
||||
InitBigNum(n1, 0, len);
|
||||
nTwoBitLen = (int)BitLenBigNum(n2, len);
|
||||
bit = 1U << (nTwoBitLen % 32);
|
||||
j = ((nTwoBitLen + 32) / 32) - 1;
|
||||
var j = ((nTwoBitLen + 32) / 32) - 1;
|
||||
nTwoByteLen = (uint)((nTwoBitLen - 1) / 32) * 4;
|
||||
nTmp[nTwoByteLen / 4] |= 1U << ((nTwoBitLen - 1) & 0x1f);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
|
||||
Width = stream.ReadUInt16();
|
||||
Height = stream.ReadUInt16();
|
||||
|
||||
var delta = stream.ReadUInt16() + 37;
|
||||
/*var delta = */stream.ReadUInt16(); /* + 37*/
|
||||
var flags = stream.ReadUInt16();
|
||||
|
||||
frameOffsets = new uint[FrameCount + 2];
|
||||
|
||||
@@ -109,7 +109,6 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
|
||||
static IEnumerable<IFinalizedRenderable> DrawZapWandering(WorldRenderer wr, float2 from, float2 to, ISpriteSequence s, string pal)
|
||||
{
|
||||
var z = float2.Zero; /* hack */
|
||||
var dist = to - from;
|
||||
var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X);
|
||||
|
||||
@@ -121,14 +120,14 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
|
||||
renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal));
|
||||
renderables.AddRange(DrawZap(wr, p1, p2, s, out p2, pal));
|
||||
renderables.AddRange(DrawZap(wr, p2, to, s, out z, pal));
|
||||
renderables.AddRange(DrawZap(wr, p2, to, s, out _, pal));
|
||||
}
|
||||
else
|
||||
{
|
||||
var p1 = from + (1 / 2f) * dist + WDist.FromPDF(Game.CosmeticRandom, 2).Length * dist.Length / 4096 * norm;
|
||||
|
||||
renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal));
|
||||
renderables.AddRange(DrawZap(wr, p1, to, s, out z, pal));
|
||||
renderables.AddRange(DrawZap(wr, p1, to, s, out _, pal));
|
||||
}
|
||||
|
||||
return renderables;
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (!Disguised || self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||
return color;
|
||||
|
||||
return color = Game.Settings.Game.UsePlayerStanceColors ? AsPlayer.PlayerRelationshipColor(self) : AsPlayer.Color;
|
||||
return Game.Settings.Game.UsePlayerStanceColors ? AsPlayer.PlayerRelationshipColor(self) : AsPlayer.Color;
|
||||
}
|
||||
|
||||
public void DisguiseAs(Actor target)
|
||||
|
||||
@@ -621,8 +621,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
}
|
||||
|
||||
// Merge Ground into Ambient
|
||||
float ground = 0;
|
||||
if (parsed.TryGetValue("Ground", out ground))
|
||||
if (parsed.TryGetValue("Ground", out var ground))
|
||||
{
|
||||
if (!parsed.ContainsKey("Ambient"))
|
||||
parsed["Ambient"] = 1f;
|
||||
|
||||
@@ -40,15 +40,15 @@ namespace OpenRA.Mods.Cnc.VideoLoaders
|
||||
if (frames <= 1) // TODO: find a better way to differentiate .shp icons
|
||||
return false;
|
||||
|
||||
var x = s.ReadUInt16();
|
||||
var y = s.ReadUInt16();
|
||||
/* var x = */ s.ReadUInt16();
|
||||
/* var y = */ s.ReadUInt16();
|
||||
var width = s.ReadUInt16();
|
||||
var height = s.ReadUInt16();
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return false;
|
||||
|
||||
var delta = s.ReadUInt16() + 37;
|
||||
/*var delta = */ s.ReadUInt16(); /* + 37;*/
|
||||
|
||||
var flags = s.ReadUInt16();
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Cnc.VideoLoaders
|
||||
|
||||
if (flags == 1)
|
||||
{
|
||||
var palette = s.ReadBytes(768);
|
||||
/* var palette = */ s.ReadBytes(768);
|
||||
for (var i = 0; i < offsets.Length; i++)
|
||||
offsets[i] += 768;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
||||
lastVisibleTarget = Target.FromTargetPositions(target);
|
||||
|
||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||
|
||||
// Cancel immediately if the target died while we were entering it
|
||||
|
||||
@@ -355,13 +355,12 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
var tarDistVec = targetPosition + offset - pos;
|
||||
var relTarHorDist = tarDistVec.HorizontalLength;
|
||||
|
||||
int predClfHgt = 0;
|
||||
int predClfDist = 0;
|
||||
int lastHtChg = 0;
|
||||
int lastHt = 0;
|
||||
var predClfHgt = 0;
|
||||
var predClfDist = 0;
|
||||
var lastHt = 0;
|
||||
|
||||
if (info.TerrainHeightAware)
|
||||
InclineLookahead(world, relTarHorDist, out predClfHgt, out predClfDist, out lastHtChg, out lastHt);
|
||||
InclineLookahead(world, relTarHorDist, out predClfHgt, out predClfDist, out _, out lastHt);
|
||||
|
||||
// Height difference between the incline height and missile height
|
||||
var diffClfMslHgt = predClfHgt - pos.Z;
|
||||
@@ -590,7 +589,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
int HomingInnerTick(int predClfDist, int diffClfMslHgt, int relTarHorDist, int lastHtChg, int lastHt,
|
||||
int relTarHgt, int vFacing, bool targetPassedBy)
|
||||
{
|
||||
int desiredVFacing = vFacing;
|
||||
int desiredVFacing;
|
||||
|
||||
// Incline coming up -> attempt to reach the incline so that after predClfDist
|
||||
// the height above the terrain is positive but as close to 0 as possible
|
||||
|
||||
@@ -54,8 +54,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
|
||||
protected static Actor FindDefenselessTarget(Squad owner)
|
||||
{
|
||||
Actor target = null;
|
||||
FindSafePlace(owner, out target, true);
|
||||
FindSafePlace(owner, out var target, true);
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly AircraftInfo aircraftInfo;
|
||||
readonly Aircraft aircraft;
|
||||
readonly BodyOrientation body;
|
||||
readonly IMove move;
|
||||
readonly IFacing facing;
|
||||
readonly Actor self;
|
||||
|
||||
@@ -125,7 +124,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
aircraftInfo = self.Info.TraitInfoOrDefault<AircraftInfo>();
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
body = self.Trait<BodyOrientation>();
|
||||
move = self.Trait<IMove>();
|
||||
facing = self.Trait<IFacing>();
|
||||
this.self = self;
|
||||
|
||||
@@ -347,7 +345,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!aircraftInfo.MoveIntoShroud && !self.Owner.Shroud.IsExplored(cell))
|
||||
return;
|
||||
|
||||
var targetLocation = move.NearestMoveableCell(cell);
|
||||
self.QueueActivity(order.Queued, new DeliverUnit(self, order.Target, Info.DropRange, Info.TargetLineColor));
|
||||
self.ShowTargetLines();
|
||||
}
|
||||
@@ -435,9 +432,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!info.AllowDropOff || !modifiers.HasModifier(TargetModifiers.ForceMove))
|
||||
return false;
|
||||
|
||||
cursor = info.DropOffCursor;
|
||||
var type = target.Type;
|
||||
|
||||
if ((type == TargetType.Actor && target.Actor.Info.HasTraitInfo<BuildingInfo>())
|
||||
|| (target.Type == TargetType.FrozenActor && target.FrozenActor.Info.HasTraitInfo<BuildingInfo>()))
|
||||
{
|
||||
|
||||
@@ -38,8 +38,6 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
var modId = modData.Manifest.Id;
|
||||
|
||||
foreach (var bo in actorNode.ChildrenMatching("BodyOrientation"))
|
||||
{
|
||||
var usesClassicFacings = false;
|
||||
|
||||
@@ -23,8 +23,6 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
var modId = modData.Manifest.Id;
|
||||
|
||||
foreach (var sh in actorNode.ChildrenMatching("SelfHealing"))
|
||||
{
|
||||
sh.RenameChildrenMatching("HealIfBelow", "StartIfBelow");
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
var palette = new ImmutablePalette(args[1], new[] { 0 }, Array.Empty<int>());
|
||||
|
||||
SequenceProvider sequences = null;
|
||||
SequenceProvider sequences;
|
||||
var mapPackage = new Folder(Platform.EngineDir).OpenPackage(args[2], modData.ModFiles);
|
||||
if (mapPackage != null)
|
||||
sequences = new Map(modData, mapPackage).Rules.Sequences;
|
||||
|
||||
@@ -118,8 +118,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
{
|
||||
var iniFormat = basicSection.GetValue("NewINIFormat", "0");
|
||||
|
||||
var iniFormatVersion = 0;
|
||||
Exts.TryParseIntegerInvariant(iniFormat, out iniFormatVersion);
|
||||
Exts.TryParseIntegerInvariant(iniFormat, out var iniFormatVersion);
|
||||
|
||||
return iniFormatVersion;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ using OpenRA.Mods.Common.UpdateRules;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands
|
||||
{
|
||||
using YamlFileSet = List<(IReadWritePackage, string, List<MiniYamlNode>)>;
|
||||
|
||||
class UpdateMapCommand : IUtilityCommand
|
||||
{
|
||||
string IUtilityCommand.Name => "--update-map";
|
||||
@@ -102,15 +100,23 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var externalFilenames = new HashSet<string>();
|
||||
foreach (var rule in rules)
|
||||
{
|
||||
Console.WriteLine("{0}: {1}", rule.GetType().Name, rule.Name);
|
||||
var mapFiles = new YamlFileSet();
|
||||
var manualSteps = new List<string>();
|
||||
|
||||
Console.WriteLine($"{rule.GetType().Name}: {rule.Name}");
|
||||
Console.Write(" Updating map... ");
|
||||
|
||||
try
|
||||
{
|
||||
manualSteps = UpdateUtils.UpdateMap(modData, mapPackage, rule, out mapFiles, externalFilenames);
|
||||
var manualSteps = UpdateUtils.UpdateMap(modData, mapPackage, rule, out var mapFiles, externalFilenames);
|
||||
|
||||
// Files are saved after each successful automated rule update
|
||||
mapFiles.Save();
|
||||
Console.WriteLine("COMPLETE");
|
||||
|
||||
if (manualSteps.Count > 0)
|
||||
{
|
||||
Console.WriteLine(" Manual changes are required to complete this update:");
|
||||
foreach (var manualStep in manualSteps)
|
||||
Console.WriteLine(" * " + manualStep.Replace("\n", "\n "));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -119,24 +125,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" The automated changes for this rule were not applied because of an error.");
|
||||
Console.WriteLine(" After the issue reported below is resolved you should run the updater");
|
||||
Console.WriteLine(" with SOURCE set to {0} to retry these changes", rule.GetType().Name);
|
||||
Console.WriteLine($" with SOURCE set to {rule.GetType().Name} to retry these changes");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" The exception reported was:");
|
||||
Console.WriteLine(" " + ex.ToString().Replace("\n", "\n "));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Files are saved after each successful automated rule update
|
||||
mapFiles.Save();
|
||||
Console.WriteLine("COMPLETE");
|
||||
|
||||
if (manualSteps.Count > 0)
|
||||
{
|
||||
Console.WriteLine(" Manual changes are required to complete this update:");
|
||||
foreach (var manualStep in manualSteps)
|
||||
Console.WriteLine(" * " + manualStep.Replace("\n", "\n "));
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -167,9 +167,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
foreach (var rule in rules)
|
||||
{
|
||||
var manualSteps = new List<string>();
|
||||
var allFiles = new YamlFileSet();
|
||||
YamlFileSet allFiles;
|
||||
|
||||
LogLine(logWriter, "{0}: {1}", rule.GetType().Name, rule.Name);
|
||||
LogLine(logWriter, $"{rule.GetType().Name}: {rule.Name}");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -221,10 +221,7 @@ namespace OpenRA.Platforms.Default
|
||||
}
|
||||
|
||||
if (pendingMotion != null)
|
||||
{
|
||||
inputHandler.OnMouseInput(pendingMotion.Value);
|
||||
pendingMotion = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user