From 8d0fe52dd87f2ae4fe355117d41908059544209e Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Sun, 19 Feb 2023 17:01:36 +0200 Subject: [PATCH] Remove unnecessary parentheses --- .editorconfig | 3 +++ OpenRA.Game/Graphics/Viewport.cs | 6 +++--- OpenRA.Game/Map/Map.cs | 2 +- OpenRA.Game/ModData.cs | 4 ++-- OpenRA.Game/Network/GameServer.cs | 2 +- OpenRA.Game/Network/TickTime.cs | 2 +- OpenRA.Game/Traits/World/ScreenShaker.cs | 4 ++-- OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs | 4 ++++ OpenRA.Mods.Cnc/Graphics/TeslaZapRenderable.cs | 8 ++++---- OpenRA.Mods.Cnc/Traits/Minelayer.cs | 4 ++-- OpenRA.Mods.Cnc/UtilityCommands/LegacyTilesetImporter.cs | 3 ++- OpenRA.Mods.Common/Activities/Sell.cs | 2 +- OpenRA.Mods.Common/FileFormats/ImaAdpcmReader.cs | 2 +- OpenRA.Mods.Common/Graphics/DefaultSpriteSequence.cs | 6 +++--- OpenRA.Mods.Common/Graphics/ModelRenderable.cs | 4 ++-- OpenRA.Mods.Common/HitShapes/Capsule.cs | 4 ++-- OpenRA.Mods.Common/Lint/CheckSequences.cs | 2 +- OpenRA.Mods.Common/Projectiles/Bullet.cs | 2 +- OpenRA.Mods.Common/Projectiles/Missile.cs | 6 +++--- OpenRA.Mods.Common/Projectiles/Railgun.cs | 2 +- OpenRA.Mods.Common/SpriteLoaders/PngSheetLoader.cs | 2 +- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 2 +- .../Traits/BotModules/Squads/AttackOrFleeFuzzy.cs | 4 ++-- .../Traits/BotModules/Squads/States/AirStates.cs | 2 +- OpenRA.Mods.Common/Traits/Buildings/Bridge.cs | 4 ++-- OpenRA.Mods.Common/Traits/Buildings/Building.cs | 2 +- OpenRA.Mods.Common/Traits/Buildings/ProductionAirdrop.cs | 2 +- OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs | 2 +- .../Traits/Player/ClassicParallelProductionQueue.cs | 2 +- .../Traits/Player/ClassicProductionQueue.cs | 2 +- OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs | 2 +- .../Traits/Render/WithResourceLevelOverlay.cs | 2 +- .../Traits/Render/WithResourceLevelSpriteBody.cs | 2 +- OpenRA.Mods.Common/Traits/Render/WithShadow.cs | 2 +- OpenRA.Mods.Common/Traits/Sellable.cs | 2 +- OpenRA.Mods.Common/Traits/World/Locomotor.cs | 4 ++-- OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs | 6 +++--- OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs | 2 +- .../Rules/20221203/ExplicitSequenceFilenames.cs | 2 +- .../UtilityCommands/ConvertSpriteToPngCommand.cs | 4 +++- .../UtilityCommands/PngSheetImportMetadataCommand.cs | 2 +- OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs | 4 ++++ OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs | 2 +- .../Widgets/Logic/Ingame/ProductionTooltipLogic.cs | 2 +- OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs | 2 +- .../Widgets/Logic/Settings/AudioSettingsLogic.cs | 2 +- OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs | 2 +- OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs | 2 +- 48 files changed, 78 insertions(+), 64 deletions(-) diff --git a/.editorconfig b/.editorconfig index 004cba8b9c..9ecc063373 100644 --- a/.editorconfig +++ b/.editorconfig @@ -183,6 +183,9 @@ dotnet_diagnostic.IDE0041.severity = warning # Make field readonly. dotnet_diagnostic.IDE0044.severity = warning +# Remove unnecessary parentheses. +dotnet_diagnostic.IDE0047.severity = warning + # Remove unused private member. dotnet_diagnostic.IDE0051.severity = warning diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index 3dc5d55aa8..c06f49fa47 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -233,7 +233,7 @@ namespace OpenRA.Graphics else Zoom = Zoom.Clamp(minZoom, maxZoom); - var maxSize = (1f / (unlockMinZoom ? unlockedMinZoom : minZoom) * new float2(Game.Renderer.NativeResolution)); + var maxSize = 1f / (unlockMinZoom ? unlockedMinZoom : minZoom) * new float2(Game.Renderer.NativeResolution); Game.Renderer.SetMaximumViewportSize(new Size((int)maxSize.X, (int)maxSize.Y)); foreach (var t in worldRenderer.World.WorldActor.TraitsImplementing()) @@ -296,8 +296,8 @@ namespace OpenRA.Graphics } public int2 ViewToWorldPx(int2 view) { return (graphicSettings.UIScale / Zoom * view.ToFloat2()).ToInt2() + TopLeft; } - public int2 WorldToViewPx(int2 world) { return ((Zoom / graphicSettings.UIScale) * (world - TopLeft).ToFloat2()).ToInt2(); } - public int2 WorldToViewPx(in float3 world) { return ((Zoom / graphicSettings.UIScale) * (world - TopLeft).XY).ToInt2(); } + public int2 WorldToViewPx(int2 world) { return (Zoom / graphicSettings.UIScale * (world - TopLeft).ToFloat2()).ToInt2(); } + public int2 WorldToViewPx(in float3 world) { return (Zoom / graphicSettings.UIScale * (world - TopLeft).XY).ToInt2(); } public void Center(IEnumerable actors) { diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 2dd665d8d4..5474b45b86 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -390,7 +390,7 @@ namespace OpenRA // TODO: Remember to remove this when rewriting tile variants / PickAny if (index == byte.MaxValue) - index = (byte)(i % 4 + (j % 4) * 4); + index = (byte)(i % 4 + j % 4 * 4); Tiles[new MPos(i, j)] = new TerrainTile(tile, index); } diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index ab6a4bf0dd..d98a4b4c78 100644 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -118,13 +118,13 @@ namespace OpenRA items.Add(t.Id, t); } - return (IReadOnlyDictionary)(new ReadOnlyDictionary(items)); + return (IReadOnlyDictionary)new ReadOnlyDictionary(items); }); defaultSequences = Exts.Lazy(() => { var items = DefaultTerrainInfo.ToDictionary(t => t.Key, t => new SequenceProvider(DefaultFileSystem, this, t.Key, null)); - return (IReadOnlyDictionary)(new ReadOnlyDictionary(items)); + return (IReadOnlyDictionary)new ReadOnlyDictionary(items); }); initialThreadId = Environment.CurrentManagedThreadId; diff --git a/OpenRA.Game/Network/GameServer.cs b/OpenRA.Game/Network/GameServer.cs index 38dc66aa62..53c508721a 100644 --- a/OpenRA.Game/Network/GameServer.cs +++ b/OpenRA.Game/Network/GameServer.cs @@ -254,7 +254,7 @@ namespace OpenRA.Network var clientsNode = new MiniYaml(""); var i = 0; foreach (var c in Clients) - clientsNode.Nodes.Add(new MiniYamlNode("Client@" + (i++).ToString(), FieldSaver.Save(c))); + clientsNode.Nodes.Add(new MiniYamlNode("Client@" + i++.ToString(), FieldSaver.Save(c))); root.Add(new MiniYamlNode("Clients", clientsNode)); return new MiniYaml("", root) diff --git a/OpenRA.Game/Network/TickTime.cs b/OpenRA.Game/Network/TickTime.cs index d2d7357081..5718691da2 100644 --- a/OpenRA.Game/Network/TickTime.cs +++ b/OpenRA.Game/Network/TickTime.cs @@ -48,7 +48,7 @@ namespace OpenRA.Network var currentTimestep = timestep(); - var integralTickTimestep = (tickDelta / currentTimestep) * currentTimestep; + var integralTickTimestep = tickDelta / currentTimestep * currentTimestep; lastTickTime += integralTickTimestep >= Game.TimestepJankThreshold ? integralTickTimestep : currentTimestep; diff --git a/OpenRA.Game/Traits/World/ScreenShaker.cs b/OpenRA.Game/Traits/World/ScreenShaker.cs index f8339d7ce7..5e7d2e6f19 100644 --- a/OpenRA.Game/Traits/World/ScreenShaker.cs +++ b/OpenRA.Game/Traits/World/ScreenShaker.cs @@ -63,8 +63,8 @@ namespace OpenRA.Traits float2 GetScrollOffset() { return GetMultiplier() * GetIntensity() * new float2( - (float)Math.Sin((ticks * 2 * Math.PI) / 4), - (float)Math.Cos((ticks * 2 * Math.PI) / 5)); + (float)Math.Sin(ticks * 2 * Math.PI / 4), + (float)Math.Cos(ticks * 2 * Math.PI / 5)); } float2 GetMultiplier() diff --git a/OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs b/OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs index d74096eda4..9672e7654d 100644 --- a/OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs +++ b/OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs @@ -250,7 +250,11 @@ namespace OpenRA.Mods.Cnc.FileFormats { *op++ = *ip++; if (t > 2) + { + #pragma warning disable IDE0047 (*op++) = *ip++; + #pragma warning restore IDE0047 + } } t = *ip++; diff --git a/OpenRA.Mods.Cnc/Graphics/TeslaZapRenderable.cs b/OpenRA.Mods.Cnc/Graphics/TeslaZapRenderable.cs index cd0ee2a8e6..4cd612faa6 100644 --- a/OpenRA.Mods.Cnc/Graphics/TeslaZapRenderable.cs +++ b/OpenRA.Mods.Cnc/Graphics/TeslaZapRenderable.cs @@ -110,13 +110,13 @@ namespace OpenRA.Mods.Cnc.Graphics static IEnumerable DrawZapWandering(WorldRenderer wr, float2 from, float2 to, ISpriteSequence s, string pal) { var dist = to - from; - var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X); + var norm = 1f / dist.Length * new float2(-dist.Y, dist.X); var renderables = new List(); if (Game.CosmeticRandom.Next(2) != 0) { - var p1 = from + (1 / 3f) * dist + WDist.FromPDF(Game.CosmeticRandom, 2).Length * dist.Length / 4096 * norm; - var p2 = from + (2 / 3f) * dist + WDist.FromPDF(Game.CosmeticRandom, 2).Length * dist.Length / 4096 * norm; + var p1 = from + 1 / 3f * dist + WDist.FromPDF(Game.CosmeticRandom, 2).Length * dist.Length / 4096 * norm; + var p2 = from + 2 / 3f * 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, p2, s, out p2, pal)); @@ -124,7 +124,7 @@ namespace OpenRA.Mods.Cnc.Graphics } else { - var p1 = from + (1 / 2f) * dist + WDist.FromPDF(Game.CosmeticRandom, 2).Length * dist.Length / 4096 * norm; + 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 _, pal)); diff --git a/OpenRA.Mods.Cnc/Traits/Minelayer.cs b/OpenRA.Mods.Cnc/Traits/Minelayer.cs index 6848ba1c3f..339ef7cb56 100644 --- a/OpenRA.Mods.Cnc/Traits/Minelayer.cs +++ b/OpenRA.Mods.Cnc/Traits/Minelayer.cs @@ -149,7 +149,7 @@ namespace OpenRA.Mods.Cnc.Traits var minefield = GetMinefieldCells(minefieldStart, cell, Info.MinefieldDepth) .Where(c => IsCellAcceptable(self, c) && self.Owner.Shroud.IsExplored(c) - && movement.CanEnterCell(c, null, BlockedByActor.Immovable) && (movement is Mobile mobile && mobile.CanStayInCell(c))) + && movement.CanEnterCell(c, null, BlockedByActor.Immovable) && movement is Mobile mobile && mobile.CanStayInCell(c)) .OrderBy(c => (c - minefieldStart).LengthSquared).ToList(); self.QueueActivity(order.Queued, new LayMines(self, minefield)); @@ -180,7 +180,7 @@ namespace OpenRA.Mods.Cnc.Traits // TODO: proper endcaps, if anyone cares (which won't happen unless depth is large) var p = end - start; var q = new float2(p.Y, -p.X); - q = (start != end) ? (1 / q.Length) * q : new float2(1, 0); + q = (start != end) ? 1 / q.Length * q : new float2(1, 0); var c = -float2.Dot(q, new float2(start.X, start.Y)); // return all points such that |ax + by + c| < depth diff --git a/OpenRA.Mods.Cnc/UtilityCommands/LegacyTilesetImporter.cs b/OpenRA.Mods.Cnc/UtilityCommands/LegacyTilesetImporter.cs index 56c963382f..41035357ee 100644 --- a/OpenRA.Mods.Cnc/UtilityCommands/LegacyTilesetImporter.cs +++ b/OpenRA.Mods.Cnc/UtilityCommands/LegacyTilesetImporter.cs @@ -146,7 +146,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands data.AppendLine($"\t\t\t\tMinColor: {s.ReadUInt8():X2}{s.ReadUInt8():X2}{s.ReadUInt8():X2}"); data.AppendLine($"\t\t\t\tMaxColor: {s.ReadUInt8():X2}{s.ReadUInt8():X2}{s.ReadUInt8():X2}"); - data.AppendLine($"\t\t\t\tZOffset: {(-tileSize.Height / 2.0f)}"); + var zOffset = -tileSize.Height / 2.0f; + data.AppendLine($"\t\t\t\tZOffset: {zOffset}"); data.AppendLine("\t\t\t\tZRamp: 0"); } } diff --git a/OpenRA.Mods.Common/Activities/Sell.cs b/OpenRA.Mods.Common/Activities/Sell.cs index 55129871ea..9fc46a8391 100644 --- a/OpenRA.Mods.Common/Activities/Sell.cs +++ b/OpenRA.Mods.Common/Activities/Sell.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Activities // Cast to long to avoid overflow when multiplying by the health var hp = health != null ? (long)health.HP : 1L; var maxHP = health != null ? (long)health.MaxHP : 1L; - var refund = (int)((sellValue * sellableInfo.RefundPercent * hp) / (100 * maxHP)); + var refund = (int)(sellValue * sellableInfo.RefundPercent * hp / (100 * maxHP)); refund = playerResources.ChangeCash(refund); foreach (var ns in self.TraitsImplementing()) diff --git a/OpenRA.Mods.Common/FileFormats/ImaAdpcmReader.cs b/OpenRA.Mods.Common/FileFormats/ImaAdpcmReader.cs index d8556ca09b..018103a40d 100644 --- a/OpenRA.Mods.Common/FileFormats/ImaAdpcmReader.cs +++ b/OpenRA.Mods.Common/FileFormats/ImaAdpcmReader.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.FileFormats var sb = (b & 8) != 0; b &= 7; - var delta = (StepTable[index] * b) / 4 + StepTable[index] / 8; + var delta = StepTable[index] * b / 4 + StepTable[index] / 8; if (sb) delta = -delta; diff --git a/OpenRA.Mods.Common/Graphics/DefaultSpriteSequence.cs b/OpenRA.Mods.Common/Graphics/DefaultSpriteSequence.cs index 5473470229..ec662c7ccb 100644 --- a/OpenRA.Mods.Common/Graphics/DefaultSpriteSequence.cs +++ b/OpenRA.Mods.Common/Graphics/DefaultSpriteSequence.cs @@ -376,7 +376,7 @@ namespace OpenRA.Mods.Common.Graphics { for (var frame = 0; frame < length; frame++) { - var i = transpose ? (frame % length) * facings + facing : + var i = transpose ? frame % length * facings + facing : (facing * stride) + (frame % length); usedFrames.Add(frames != null ? frames[i] : start + i); @@ -530,7 +530,7 @@ namespace OpenRA.Mods.Common.Graphics { for (var frame = 0; frame < length; frame++) { - var i = transpose ? (frame % length) * facings + facing : + var i = transpose ? frame % length * facings + facing : (facing * stride) + (frame % length); var s = frames != null ? sprites[frames[i]] : sprites[start + i]; if (!s.Bounds.IsEmpty) @@ -574,7 +574,7 @@ namespace OpenRA.Mods.Common.Graphics if (reverseFacings) f = (facings - f) % facings; - var i = transpose ? (frame % length) * facings + f : + var i = transpose ? frame % length * facings + f : (f * stride) + (frame % length); var j = frames != null ? frames[i] : start + i; diff --git a/OpenRA.Mods.Common/Graphics/ModelRenderable.cs b/OpenRA.Mods.Common/Graphics/ModelRenderable.cs index 3f9e57638e..9861fa2f9d 100644 --- a/OpenRA.Mods.Common/Graphics/ModelRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/ModelRenderable.cs @@ -158,7 +158,7 @@ namespace OpenRA.Mods.Common.Graphics if (map.Ramp.Contains(cell) && map.Ramp[cell] == 7) pxOrigin += new float3(0, 0, 0.5f * map.Grid.TileSize.Height); - var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1)); + var shadowOrigin = pxOrigin - groundZ * new float2(renderProxy.ShadowDirection, 1); var psb = renderProxy.ProjectedShadowBounds; var sa = shadowOrigin + psb[0]; @@ -185,7 +185,7 @@ namespace OpenRA.Mods.Common.Graphics var groundPos = model.pos - new WVec(0, 0, wr.World.Map.DistanceAboveTerrain(model.pos).Length); var groundZ = wr.World.Map.Grid.TileSize.Height * (groundPos.Z - model.pos.Z) / 1024f; var pxOrigin = wr.Screen3DPosition(model.pos); - var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1)); + var shadowOrigin = pxOrigin - groundZ * new float2(renderProxy.ShadowDirection, 1); // Draw sprite rect var offset = pxOrigin + renderProxy.Sprite.Offset - 0.5f * renderProxy.Sprite.Size; diff --git a/OpenRA.Mods.Common/HitShapes/Capsule.cs b/OpenRA.Mods.Common/HitShapes/Capsule.cs index ab1078f2a5..4283896be8 100644 --- a/OpenRA.Mods.Common/HitShapes/Capsule.cs +++ b/OpenRA.Mods.Common/HitShapes/Capsule.cs @@ -74,8 +74,8 @@ namespace OpenRA.Mods.Common.HitShapes return new WDist(Math.Max(0, (PointB - p).Length - Radius.Length)); var projection = PointA + new int2( - (ab.X * t) / 1024, - (ab.Y * t) / 1024); + ab.X * t / 1024, + ab.Y * t / 1024); var distance = (projection - p).Length; diff --git a/OpenRA.Mods.Common/Lint/CheckSequences.cs b/OpenRA.Mods.Common/Lint/CheckSequences.cs index 60e2baeda5..34dc6775ef 100644 --- a/OpenRA.Mods.Common/Lint/CheckSequences.cs +++ b/OpenRA.Mods.Common/Lint/CheckSequences.cs @@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Lint continue; // All weapon sequences must specify their corresponding image - var image = ((string)fields.First(f => f.Name == sequenceReference.ImageReference).GetValue(projectileInfo)); + var image = (string)fields.First(f => f.Name == sequenceReference.ImageReference).GetValue(projectileInfo); if (string.IsNullOrEmpty(image)) { if (!sequenceReference.AllowNullImage) diff --git a/OpenRA.Mods.Common/Projectiles/Bullet.cs b/OpenRA.Mods.Common/Projectiles/Bullet.cs index b0b225975e..648a969fa5 100644 --- a/OpenRA.Mods.Common/Projectiles/Bullet.cs +++ b/OpenRA.Mods.Common/Projectiles/Bullet.cs @@ -217,7 +217,7 @@ namespace OpenRA.Mods.Common.Projectiles var at = (float)ticks / (length - 1); var attitude = angle.Tan() * (1 - 2 * at) / (4 * 1024); - var u = (facing.Angle % 512) / 512f; + var u = facing.Angle % 512 / 512f; var scale = 2048 * u * (1 - u); var effective = (int)(facing.Angle < 512 diff --git a/OpenRA.Mods.Common/Projectiles/Missile.cs b/OpenRA.Mods.Common/Projectiles/Missile.cs index b83026d002..054e68c4fb 100644 --- a/OpenRA.Mods.Common/Projectiles/Missile.cs +++ b/OpenRA.Mods.Common/Projectiles/Missile.cs @@ -301,7 +301,7 @@ namespace OpenRA.Mods.Common.Projectiles // angular speed in radians per tick = rot in facing units per tick * (pi radians / 128 facing units) // pi = 314 / 100 // ==> loopRadius = (speed * 128 * 100) / (314 * rot) - return (speed * 6400) / (157 * rot); + return speed * 6400 / (157 * rot); } void DetermineLaunchSpeedAndAngleForIncline(int predClfDist, int diffClfMslHgt, int relTarHorDist, @@ -315,9 +315,9 @@ namespace OpenRA.Mods.Common.Projectiles // Compute minimum speed necessary to both be able to face directly upwards and have enough space // to hit the target without passing it by (and thus having to do horizontal loops) - var minSpeed = ((System.Math.Min(predClfDist * 1024 / (1024 - WAngle.FromFacing(vFacing).Sin()), + var minSpeed = (System.Math.Min(predClfDist * 1024 / (1024 - WAngle.FromFacing(vFacing).Sin()), (relTarHorDist + predClfDist) * 1024 / (2 * (2048 - WAngle.FromFacing(vFacing).Sin()))) - * info.VerticalRateOfTurn.Facing * 157) / 6400).Clamp(minLaunchSpeed, maxLaunchSpeed); + * info.VerticalRateOfTurn.Facing * 157 / 6400).Clamp(minLaunchSpeed, maxLaunchSpeed); if ((sbyte)vFacing < 0) speed = minSpeed; diff --git a/OpenRA.Mods.Common/Projectiles/Railgun.cs b/OpenRA.Mods.Common/Projectiles/Railgun.cs index 40d9a908e9..ededf27718 100644 --- a/OpenRA.Mods.Common/Projectiles/Railgun.cs +++ b/OpenRA.Mods.Common/Projectiles/Railgun.cs @@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Projectiles // Forward step, pointing from src to target. // QuantizationCont * forwardStep == One cycle of beam in src2target direction. - ForwardStep = (info.HelixPitch.Length * SourceToTarget) / (info.QuantizationCount * SourceToTarget.Length); + ForwardStep = info.HelixPitch.Length * SourceToTarget / (info.QuantizationCount * SourceToTarget.Length); // An easy vector to find which is perpendicular vector to forwardStep, with 0 Z component LeftVector = new WVec(ForwardStep.Y, -ForwardStep.X, 0); diff --git a/OpenRA.Mods.Common/SpriteLoaders/PngSheetLoader.cs b/OpenRA.Mods.Common/SpriteLoaders/PngSheetLoader.cs index aa57d94bac..fb2f87d3f8 100644 --- a/OpenRA.Mods.Common/SpriteLoaders/PngSheetLoader.cs +++ b/OpenRA.Mods.Common/SpriteLoaders/PngSheetLoader.cs @@ -125,7 +125,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders if (png.EmbeddedData.ContainsKey("FrameAmount")) frameAmount = FieldLoader.GetValue("FrameAmount", png.EmbeddedData["FrameAmount"]); else - frameAmount = (png.Width / frameSize.Width) * (png.Height / frameSize.Height); + frameAmount = png.Width / frameSize.Width * (png.Height / frameSize.Height); } else if (png.EmbeddedData.ContainsKey("FrameAmount")) { diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 267397e32f..2ae17ae0ed 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -539,7 +539,7 @@ namespace OpenRA.Mods.Common.Traits return new WVec(1024, 0, 0).Rotate(rot); } - return (d * 1024 * 8) / (int)distSq; + return d * 1024 * 8 / (int)distSq; } public Actor GetActorBelow() diff --git a/OpenRA.Mods.Common/Traits/BotModules/Squads/AttackOrFleeFuzzy.cs b/OpenRA.Mods.Common/Traits/BotModules/Squads/AttackOrFleeFuzzy.cs index 0c420bc157..5ad364bfc4 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/Squads/AttackOrFleeFuzzy.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/Squads/AttackOrFleeFuzzy.cs @@ -218,7 +218,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads var totalReloadDelay = arm.Weapon.ReloadDelay + (arm.Weapon.BurstDelays[0] * (burst - 1)).Clamp(1, 200); var damageWarheads = arm.Weapon.Warheads.OfType(); foreach (var warhead in damageWarheads) - sumOfDamage += (warhead.Damage * burst / totalReloadDelay) * 100; + sumOfDamage += warhead.Damage * burst / totalReloadDelay * 100; } return sumOfDamage; @@ -239,7 +239,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads if (!own.Any()) return 0.0f; - var relative = (relativeFunc(own, getValue) / relativeFunc(enemy, getValue)) * normalizeByValue; + var relative = relativeFunc(own, getValue) / relativeFunc(enemy, getValue) * normalizeByValue; return relative.Clamp(0.0f, 999.0f); } diff --git a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs index f89e9bb191..4c6d578af5 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs @@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads var checkIndices = Exts.MakeArray(columnCount * rowCount, i => i).Shuffle(owner.World.LocalRandom); foreach (var i in checkIndices) { - var pos = new MPos((i % columnCount) * dangerRadius + dangerRadius / 2, (i / columnCount) * dangerRadius + dangerRadius / 2).ToCPos(map); + var pos = new MPos(i % columnCount * dangerRadius + dangerRadius / 2, i / columnCount * dangerRadius + dangerRadius / 2).ToCPos(map); if (NearToPosSafely(owner, map.CenterOfCell(pos), out detectedEnemyTarget)) { diff --git a/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs b/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs index b9e3731e3f..eaed6a1c44 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs @@ -215,10 +215,10 @@ namespace OpenRA.Mods.Common.Traits { var offset = buildingInfo.CenterOffset(self.World).Y + 1024; - return footprint.Select(c => (IRenderable)(new SpriteRenderable( + return footprint.Select(c => (IRenderable)new SpriteRenderable( terrainRenderer.TileSprite(new TerrainTile(template, c.Value)), wr.World.Map.CenterOfCell(c.Key), WVec.Zero, -offset, palette, 1f, 1f, - float3.Ones, TintModifiers.None, true))).ToArray(); + float3.Ones, TintModifiers.None, true)).ToArray(); } bool initialized; diff --git a/OpenRA.Mods.Common/Traits/Buildings/Building.cs b/OpenRA.Mods.Common/Traits/Buildings/Building.cs index 7bc37de0b9..84a994c13d 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Building.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Building.cs @@ -153,7 +153,7 @@ namespace OpenRA.Mods.Common.Traits public WVec CenterOffset(World w) { var off = (w.Map.CenterOfCell(new CPos(Dimensions.X, Dimensions.Y)) - w.Map.CenterOfCell(new CPos(1, 1))) / 2; - return (off - new WVec(0, 0, off.Z)) + LocalCenterOffset; + return off - new WVec(0, 0, off.Z) + LocalCenterOffset; } public BaseProvider FindBaseProvider(World world, Player p, CPos topLeft) diff --git a/OpenRA.Mods.Common/Traits/Buildings/ProductionAirdrop.cs b/OpenRA.Mods.Common/Traits/Buildings/ProductionAirdrop.cs index 4c43372136..57785e6231 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/ProductionAirdrop.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/ProductionAirdrop.cs @@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits var bounds = map.Bounds; var center = new MPos(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2).ToCPos(map); var spawnVec = owner.HomeLocation - center; - startPos = owner.HomeLocation + spawnVec * (Exts.ISqrt((bounds.Height * bounds.Height + bounds.Width * bounds.Width) / (4 * spawnVec.LengthSquared))); + startPos = owner.HomeLocation + spawnVec * Exts.ISqrt((bounds.Height * bounds.Height + bounds.Width * bounds.Width) / (4 * spawnVec.LengthSquared)); endPos = startPos; var spawnDirection = new WVec((self.Location - startPos).X, (self.Location - startPos).Y, 0); spawnFacing = spawnDirection.Yaw; diff --git a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs index 23ff131bfe..45fd838792 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs @@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Traits var hpToRepair = Math.Min(Info.RepairStep, health.MaxHP - health.HP); // Cast to long to avoid overflow when multiplying by the health - var cost = Math.Max(1, (int)(((long)hpToRepair * Info.RepairPercent * buildingValue) / (health.MaxHP * 100L))); + var cost = Math.Max(1, (int)((long)hpToRepair * Info.RepairPercent * buildingValue / (health.MaxHP * 100L))); // TakeCash will return false if the player can't pay, and will stop him from contributing this Tick var activePlayers = Repairers.Count(player => player.PlayerActor.Trait().TakeCash(cost, true)); diff --git a/OpenRA.Mods.Common/Traits/Player/ClassicParallelProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ClassicParallelProductionQueue.cs index 7948486f0c..af206115b9 100644 --- a/OpenRA.Mods.Common/Traits/Player/ClassicParallelProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ClassicParallelProductionQueue.cs @@ -208,7 +208,7 @@ namespace OpenRA.Mods.Common.Traits .Count(p => !p.Trait.IsTraitDisabled && !p.Trait.IsTraitPaused && p.Actor.Owner == self.Owner && p.Trait.Info.Produces.Contains(type)); var speedModifier = selfsameProductionsCount.Clamp(1, info.BuildingCountBuildTimeMultipliers.Length) - 1; - time = (time * info.BuildingCountBuildTimeMultipliers[speedModifier]) / 100; + time = time * info.BuildingCountBuildTimeMultipliers[speedModifier] / 100; } return time; diff --git a/OpenRA.Mods.Common/Traits/Player/ClassicProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ClassicProductionQueue.cs index a38cd77546..3540f51d37 100644 --- a/OpenRA.Mods.Common/Traits/Player/ClassicProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ClassicProductionQueue.cs @@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Traits .Count(p => !p.Trait.IsTraitDisabled && !p.Trait.IsTraitPaused && p.Actor.Owner == self.Owner && p.Trait.Info.Produces.Contains(type)); var speedModifier = selfsameProductionsCount.Clamp(1, info.BuildTimeSpeedReduction.Length) - 1; - time = (time * info.BuildTimeSpeedReduction[speedModifier]) / 100; + time = time * info.BuildTimeSpeedReduction[speedModifier] / 100; } return time; diff --git a/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs b/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs index 3828c04f63..dc04ea2a14 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs @@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits.Render if (blinkPattern != null && blinkPattern.Length > 0) { - var i = (self.World.WorldTick / Info.BlinkInterval) % blinkPattern.Length; + var i = self.World.WorldTick / Info.BlinkInterval % blinkPattern.Length; if (blinkPattern[i] != BlinkState.On) return false; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithResourceLevelOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithResourceLevelOverlay.cs index 52667bdbe9..0fccb1dffa 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithResourceLevelOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithResourceLevelOverlay.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits.Render var a = new Animation(self.World, rs.GetImage(self)); a.PlayFetchIndex(info.Sequence, () => playerResources.ResourceCapacity != 0 ? - ((10 * a.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity) : + (10 * a.CurrentSequence.Length - 1) * playerResources.Resources / (10 * playerResources.ResourceCapacity) : 0); anim = new AnimationWithOffset(a, null, () => IsTraitDisabled, 1024); diff --git a/OpenRA.Mods.Common/Traits/Render/WithResourceLevelSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithResourceLevelSpriteBody.cs index aada3c0981..83bcf6ffe2 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithResourceLevelSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithResourceLevelSpriteBody.cs @@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits.Render { DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => playerResources.ResourceCapacity != 0 - ? ((info.Stages * DefaultAnimation.CurrentSequence.Length - 1) * playerResources.Resources) / (info.Stages * playerResources.ResourceCapacity) + ? (info.Stages * DefaultAnimation.CurrentSequence.Length - 1) * playerResources.Resources / (info.Stages * playerResources.ResourceCapacity) : 0); } diff --git a/OpenRA.Mods.Common/Traits/Render/WithShadow.cs b/OpenRA.Mods.Common/Traits/Render/WithShadow.cs index 994d76577b..02d0b67bc2 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithShadow.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithShadow.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits.Render .Select(ma => ((IModifyableRenderable)ma).WithTint(shadowColor, ((IModifyableRenderable)ma).TintModifiers | TintModifiers.ReplaceColor) .WithAlpha(shadowAlpha) .OffsetBy(info.Offset - new WVec(0, 0, height)) - .WithZOffset(ma.ZOffset + (height + info.ZOffset)) + .WithZOffset(ma.ZOffset + height + info.ZOffset) .AsDecoration()); return shadowSprites.Concat(r); diff --git a/OpenRA.Mods.Common/Traits/Sellable.cs b/OpenRA.Mods.Common/Traits/Sellable.cs index 4dcd136f48..82beca31fa 100644 --- a/OpenRA.Mods.Common/Traits/Sellable.cs +++ b/OpenRA.Mods.Common/Traits/Sellable.cs @@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits // Cast to long to avoid overflow when multiplying by the health var hp = health != null ? (long)health.Value.HP : 1L; var maxHP = health != null ? (long)health.Value.MaxHP : 1L; - var refund = (int)((sellValue * info.RefundPercent * hp) / (100 * maxHP)); + var refund = (int)(sellValue * info.RefundPercent * hp / (100 * maxHP)); return "Refund: $" + refund; } diff --git a/OpenRA.Mods.Common/Traits/World/Locomotor.cs b/OpenRA.Mods.Common/Traits/World/Locomotor.cs index 77751bd9fc..1b1f209d65 100644 --- a/OpenRA.Mods.Common/Traits/World/Locomotor.cs +++ b/OpenRA.Mods.Common/Traits/World/Locomotor.cs @@ -91,9 +91,9 @@ namespace OpenRA.Mods.Common.Traits if (speed > 0) { var nodesDict = t.Value.ToDictionary(); - var cost = (nodesDict.ContainsKey("PathingCost") + var cost = nodesDict.ContainsKey("PathingCost") ? FieldLoader.GetValue("cost", nodesDict["PathingCost"].Value) - : 10000 / speed); + : 10000 / speed; ret.Add(t.Key, new TerrainInfo(speed, (short)cost)); } } diff --git a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs index bf80262c4b..8bd5751b69 100644 --- a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs @@ -214,9 +214,9 @@ namespace OpenRA.Mods.Common.Traits // All tiles are visible in the editor if (w.Type == WorldType.Editor) - cellVisibility = puv => (map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Explored); + cellVisibility = puv => map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Explored; else - cellVisibility = puv => (map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Hidden); + cellVisibility = puv => map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Hidden; var shroudBlend = shroudSprites[0].Sprite.BlendMode; if (shroudSprites.Any(s => s.Sprite.BlendMode != shroudBlend)) @@ -309,7 +309,7 @@ namespace OpenRA.Mods.Common.Traits else { // Visible under shroud: Explored. Visible under fog: Visible. - cellVisibility = puv => (map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Hidden); + cellVisibility = puv => map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Hidden; } shroud = newShroud; diff --git a/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs b/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs index 1955698416..6173688953 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs @@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits { for (var x = 0; x < template.Size.X; x++) { - var tile = new TerrainTile(template.Id, (byte)(i++)); + var tile = new TerrainTile(template.Id, (byte)i++); if (!terrainInfo.TryGetTileInfo(tile, out var tileInfo)) continue; diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20221203/ExplicitSequenceFilenames.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20221203/ExplicitSequenceFilenames.cs index e288a9b40c..2b3297ef46 100644 --- a/OpenRA.Mods.Common/UpdateRules/Rules/20221203/ExplicitSequenceFilenames.cs +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20221203/ExplicitSequenceFilenames.cs @@ -357,7 +357,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules foreach (var node in combineNode.Value.Nodes) { ProcessNode(modData, node, node, node.Key); - node.Key = (i++).ToString(); + node.Key = i++.ToString(); } return; diff --git a/OpenRA.Mods.Common/UtilityCommands/ConvertSpriteToPngCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ConvertSpriteToPngCommand.cs index 41e915bb76..9d6bb1b886 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ConvertSpriteToPngCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ConvertSpriteToPngCommand.cs @@ -79,7 +79,9 @@ namespace OpenRA.Mods.Common.UtilityCommands } var png = new Png(pngData, SpriteFrameType.Indexed8, frameSize.Width, frameSize.Height, palColors); - png.Save($"{prefix}-{(count++):D4}.png"); + #pragma warning disable SA1003 + png.Save($"{prefix}-{count++:D4}.png"); + #pragma warning restore SA1003 } Console.WriteLine("Saved {0}-[0..{1}].png", prefix, count - 1); diff --git a/OpenRA.Mods.Common/UtilityCommands/PngSheetImportMetadataCommand.cs b/OpenRA.Mods.Common/UtilityCommands/PngSheetImportMetadataCommand.cs index 9860c519f7..4f0567a27c 100644 --- a/OpenRA.Mods.Common/UtilityCommands/PngSheetImportMetadataCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/PngSheetImportMetadataCommand.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.UtilityCommands if (frameAmountField != null) { var frameAmount = FieldLoader.GetValue("FrameAmount", frameAmountField); - if (frameAmount > (png.Width / frameSize.Width) * (png.Height / frameSize.Height)) + if (frameAmount > png.Width / frameSize.Width * (png.Height / frameSize.Height)) throw new InvalidDataException(".png file is too small for given FrameSize and FrameAmount."); } } diff --git a/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs b/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs index 6e346f896f..2c292f64d2 100644 --- a/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs @@ -68,7 +68,11 @@ namespace OpenRA.Mods.Common.Widgets var c = (int*)cc; for (var s = 0; s < 256; s++) for (var h = 0; h < 256; h++) + { + #pragma warning disable IDE0047 (*(c + s * 256 + h)) = Color.FromAhsv(h / 255f, 1 - s / 255f, V).ToArgb(); + #pragma warning restore IDE0047 + } } } diff --git a/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs b/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs index 6bff589ea9..c8c4beb514 100644 --- a/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs @@ -129,7 +129,7 @@ namespace OpenRA.Mods.Common.Widgets var panelY = RenderOrigin.Y + Bounds.Height - panelRoot.RenderOrigin.Y; if (panelY + oldBounds.Height > Game.Renderer.Resolution.Height) - panelY -= (Bounds.Height + oldBounds.Height); + panelY -= Bounds.Height + oldBounds.Height; panel.Bounds = new Rectangle( panelX, diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs index c646e4a56f..88752253da 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs @@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var buildTime = tooltipIcon.ProductionQueue?.GetBuildTime(actor, buildable) ?? 0; var timeModifier = pm != null && pm.PowerState != PowerState.Normal ? tooltipIcon.ProductionQueue.Info.LowPowerModifier : 100; - timeLabel.Text = formatBuildTime.Update((buildTime * timeModifier) / 100); + timeLabel.Text = formatBuildTime.Update(buildTime * timeModifier / 100); timeLabel.TextColor = (pm != null && pm.PowerState != PowerState.Normal && tooltipIcon.ProductionQueue.Info.LowPowerModifier > 100) ? Color.Red : Color.White; var timeSize = font.Measure(timeLabel.Text); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index 16ce1d87d9..5ac376c9ee 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -283,7 +283,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var selectedSpawn = DetermineSelectedSpawnPoint(mapPreview, preview, mi); var locals = orderManager.LobbyInfo.Clients.Where(c => c.Index == orderManager.LocalClient.Index || (Game.IsHost && c.Bot != null)); - var playerToMove = locals.FirstOrDefault(c => ((selectedSpawn == 0) ^ (c.SpawnPoint == 0) && !c.IsObserver)); + var playerToMove = locals.FirstOrDefault(c => (selectedSpawn == 0) ^ (c.SpawnPoint == 0) && !c.IsObserver); SetSpawnPoint(orderManager, playerToMove, selectedSpawn); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/AudioSettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/AudioSettingsLogic.cs index 1aa6e98d55..520d4a02c6 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/AudioSettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/AudioSettingsLogic.cs @@ -154,7 +154,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic void ShowAudioDeviceDropdown(DropDownButtonWidget dropdown, SoundDevice[] devices, ScrollPanelWidget scrollPanel) { var i = 0; - var options = devices.ToDictionary(d => (i++).ToString(), d => d); + var options = devices.ToDictionary(d => i++.ToString(), d => d); Func setupItem = (o, itemTemplate) => { diff --git a/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs b/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs index bf0441025e..967adfbfa9 100644 --- a/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs @@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Widgets foreach (var queue in queues) tabs.Add(new ProductionTab() { - Name = (NextQueueName++).ToString(), + Name = NextQueueName++.ToString(), Queue = queue }); Tabs = tabs; diff --git a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs index bea1a22da6..0402f56512 100644 --- a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs @@ -207,7 +207,7 @@ namespace OpenRA.Mods.Common.Widgets var deltaScale = Math.Min(Game.RunTime - lastScrollTime, 25f); var length = Math.Max(1, scroll.Length); - scroll *= (deltaScale / (25 * length)) * Game.Settings.Game.ViewportEdgeScrollStep; + scroll *= deltaScale / (25 * length) * Game.Settings.Game.ViewportEdgeScrollStep; worldRenderer.Viewport.Scroll(scroll, false); lastScrollTime = Game.RunTime;