From 8ee6957e6a79d03d9bdefd6de800318aa193f451 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Tue, 28 Feb 2023 19:27:42 +0000 Subject: [PATCH] Fix IDE0048 --- .editorconfig | 9 +++++++++ OpenRA.Game/Map/Map.cs | 4 ++-- OpenRA.Game/Primitives/PriorityQueue.cs | 2 +- OpenRA.Game/Traits/Player/Shroud.cs | 2 +- OpenRA.Mods.Cnc/FileFormats/BlowfishKeyProvider.cs | 8 ++++---- OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs | 2 +- OpenRA.Mods.Cnc/FileSystem/MixFile.cs | 2 +- OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs | 4 ++-- OpenRA.Mods.Common/FileFormats/WavReader.cs | 4 ++-- OpenRA.Mods.Common/Graphics/DefaultSpriteSequence.cs | 6 +++--- OpenRA.Mods.Common/Pathfinder/HierarchicalPathFinder.cs | 4 ++-- .../BotModules/BotModuleLogic/BaseBuilderQueueManager.cs | 4 ++-- .../Traits/BotModules/SupportPowerBotModule.cs | 4 ++-- OpenRA.Mods.Common/Traits/Crates/GiveCashCrateAction.cs | 2 +- OpenRA.Mods.Common/Widgets/LineGraphWidget.cs | 2 +- .../Widgets/Logic/Editor/LayerSelectorLogic.cs | 4 ++-- .../Widgets/Logic/Ingame/ClassicProductionLogic.cs | 6 +++--- .../Widgets/Logic/Ingame/ProductionTooltipLogic.cs | 2 +- OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs | 2 +- OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs | 2 +- OpenRA.Mods.Common/Widgets/SliderWidget.cs | 2 +- OpenRA.Mods.Common/Widgets/TextFieldWidget.cs | 2 +- OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs | 4 ++-- 23 files changed, 46 insertions(+), 37 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9852c0c1b0..b672861277 100644 --- a/.editorconfig +++ b/.editorconfig @@ -127,6 +127,12 @@ csharp_style_expression_bodied_local_functions = when_on_single_line # Remove unused parameters on non public methods, ignore unused parameters on public methods. dotnet_code_quality_unused_parameters = non_public +# Parentheses preferences. +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary + ## Others: # Show an IDE warning when default access modifiers are explicitly specified. @@ -201,6 +207,9 @@ dotnet_diagnostic.IDE0044.severity = warning # Remove unnecessary parentheses. dotnet_diagnostic.IDE0047.severity = warning +# Add parentheses for clarity. +dotnet_diagnostic.IDE0048.severity = warning + # Remove unused private member. dotnet_diagnostic.IDE0051.severity = warning diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 9cb2ba64de..3ea70abbeb 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -1248,8 +1248,8 @@ namespace OpenRA if (allProjected.Length > 0) { var puv = allProjected.First(); - var horizontalBound = ((puv.U - Bounds.Left) < Bounds.Width / 2) ? Bounds.Left : Bounds.Right; - var verticalBound = ((puv.V - Bounds.Top) < Bounds.Height / 2) ? Bounds.Top : Bounds.Bottom; + var horizontalBound = (puv.U - Bounds.Left < Bounds.Width / 2) ? Bounds.Left : Bounds.Right; + var verticalBound = (puv.V - Bounds.Top < Bounds.Height / 2) ? Bounds.Top : Bounds.Bottom; var du = Math.Abs(horizontalBound - puv.U); var dv = Math.Abs(verticalBound - puv.V); diff --git a/OpenRA.Game/Primitives/PriorityQueue.cs b/OpenRA.Game/Primitives/PriorityQueue.cs index 9b8b5d3b9c..25b72af22f 100644 --- a/OpenRA.Game/Primitives/PriorityQueue.cs +++ b/OpenRA.Game/Primitives/PriorityQueue.cs @@ -51,7 +51,7 @@ namespace OpenRA.Primitives items[addLevel][addIndex] = item; - if (++index >= (1 << level)) + if (++index >= 1 << level) { index = 0; if (items.Count <= ++level) diff --git a/OpenRA.Game/Traits/Player/Shroud.cs b/OpenRA.Game/Traits/Player/Shroud.cs index 1229ed093e..e4fed9614f 100644 --- a/OpenRA.Game/Traits/Player/Shroud.cs +++ b/OpenRA.Game/Traits/Player/Shroud.cs @@ -382,7 +382,7 @@ namespace OpenRA.Traits { var index = touched.Index(puv); touched[index] = true; - explored[index] = (visibleCount[index] + passiveVisibleCount[index]) > 0; + explored[index] = visibleCount[index] + passiveVisibleCount[index] > 0; } anyCellTouched = true; diff --git a/OpenRA.Mods.Cnc/FileFormats/BlowfishKeyProvider.cs b/OpenRA.Mods.Cnc/FileFormats/BlowfishKeyProvider.cs index e966665558..6fabcc9449 100644 --- a/OpenRA.Mods.Cnc/FileFormats/BlowfishKeyProvider.cs +++ b/OpenRA.Mods.Cnc/FileFormats/BlowfishKeyProvider.cs @@ -228,7 +228,7 @@ namespace OpenRA.Mods.Cnc.FileFormats InitBigNum(n1, 0, len); nTwoBitLen = (int)BitLenBigNum(n2, len); bit = 1U << (nTwoBitLen % 32); - var j = ((nTwoBitLen + 32) / 32) - 1; + var j = (nTwoBitLen + 32) / 32 - 1; nTwoByteLen = (uint)((nTwoBitLen - 1) / 32) * 4; nTmp[nTwoByteLen / 4] |= 1U << ((nTwoBitLen - 1) & 0x1f); @@ -293,7 +293,7 @@ namespace OpenRA.Mods.Cnc.FileFormats tmp = 0; for (i = 0; i < len; i++) { - tmp = mul * (*pn2) + (*pn1) + tmp; + tmp = mul * *pn2 + *pn1 + tmp; *pn1 = (ushort)tmp; pn1++; pn2++; @@ -371,8 +371,8 @@ namespace OpenRA.Mods.Cnc.FileFormats IncrementBigNum(globTwo, len * 2 + 1); NegBigNum(globTwo, len * 2 + 1); lenDiff = globTwoXtwo + 1 - globOneLenXTwo; - var esi = ((ushort*)g2) + (1 + globTwoXtwo - globOneLenXTwo); - var edi = ((ushort*)g2) + (globTwoXtwo + 1); + var esi = (ushort*)g2 + (1 + globTwoXtwo - globOneLenXTwo); + var edi = (ushort*)g2 + (globTwoXtwo + 1); for (; lenDiff != 0; lenDiff--) { edi--; diff --git a/OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs b/OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs index 9672e7654d..569388c67e 100644 --- a/OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs +++ b/OpenRA.Mods.Cnc/FileFormats/LZOCompression.cs @@ -218,7 +218,7 @@ namespace OpenRA.Mods.Cnc.FileFormats goto match_done; } - if (t >= 2 * 4 - (3 - 1) && (op - mPos) >= 4) + if (t >= 2 * 4 - (3 - 1) && op - mPos >= 4) { *(uint*)op = *(uint*)mPos; op += 4; mPos += 4; t -= 4 - (3 - 1); diff --git a/OpenRA.Mods.Cnc/FileSystem/MixFile.cs b/OpenRA.Mods.Cnc/FileSystem/MixFile.cs index 7227bf7737..77e157b0be 100644 --- a/OpenRA.Mods.Cnc/FileSystem/MixFile.cs +++ b/OpenRA.Mods.Cnc/FileSystem/MixFile.cs @@ -164,7 +164,7 @@ namespace OpenRA.Mods.Cnc.FileSystem if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), "Non-negative number required."); - if (offset + (count * 2) > s.Length) + if (offset + count * 2 > s.Length) throw new ArgumentException($"Bytes to read {count * 2} and offset {offset} greater than stream length {s.Length}."); s.Seek(offset, SeekOrigin.Begin); diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs index 66398906f0..721bc6bbae 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs @@ -304,8 +304,8 @@ namespace OpenRA.Mods.Common.Widgets for (var x = previousCell.X; x <= nextCell.X; x += terrainTemplate.Size.X) { PaintSingleCell(new CPos(x, queuedCell.Y)); - var upperCell = new CPos(x, queuedCell.Y - (1 * terrainTemplate.Size.Y)); - var lowerCell = new CPos(x, queuedCell.Y + (1 * terrainTemplate.Size.Y)); + var upperCell = new CPos(x, queuedCell.Y - 1 * terrainTemplate.Size.Y); + var lowerCell = new CPos(x, queuedCell.Y + 1 * terrainTemplate.Size.Y); if (ShouldPaint(upperCell)) MaybeEnqueue(upperCell); diff --git a/OpenRA.Mods.Common/FileFormats/WavReader.cs b/OpenRA.Mods.Common/FileFormats/WavReader.cs index c176250901..70469e9cfd 100644 --- a/OpenRA.Mods.Common/FileFormats/WavReader.cs +++ b/OpenRA.Mods.Common/FileFormats/WavReader.cs @@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.FileFormats { this.channels = channels; numBlocks = dataSize / blockAlign; - blockDataSize = blockAlign - (channels * 4); + blockDataSize = blockAlign - channels * 4; outputSize = uncompressedSize * channels * 2; predictor = new int[channels]; index = new int[channels]; @@ -268,7 +268,7 @@ namespace OpenRA.Mods.Common.FileFormats // This code contains elements from libsndfile short DecodeNibble(short nibble, byte bpred, ref short idelta, ref short s1, ref short s2) { - var predict = ((s1 * AdaptCoeff1[bpred]) + (s2 * AdaptCoeff2[bpred])) >> 8; + var predict = (s1 * AdaptCoeff1[bpred] + s2 * AdaptCoeff2[bpred]) >> 8; var twosCompliment = (nibble & 0x8) > 0 ? nibble - 0x10 diff --git a/OpenRA.Mods.Common/Graphics/DefaultSpriteSequence.cs b/OpenRA.Mods.Common/Graphics/DefaultSpriteSequence.cs index 177e51fc26..5fb633c4fe 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 : - (facing * stride) + (frame % length); + 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 : - (facing * stride) + (frame % length); + facing * stride + frame % length; var s = frames != null ? sprites[frames[i]] : sprites[start + i]; if (!s.Bounds.IsEmpty) yield return new Rectangle( @@ -574,7 +574,7 @@ namespace OpenRA.Mods.Common.Graphics f = (facings - f) % facings; var i = transpose ? frame % length * facings + f : - (f * stride) + (frame % length); + f * stride + frame % length; var j = frames != null ? frames[i] : start + i; if (sprites[j] == null) diff --git a/OpenRA.Mods.Common/Pathfinder/HierarchicalPathFinder.cs b/OpenRA.Mods.Common/Pathfinder/HierarchicalPathFinder.cs index 5f3e909d1d..0502e856b6 100644 --- a/OpenRA.Mods.Common/Pathfinder/HierarchicalPathFinder.cs +++ b/OpenRA.Mods.Common/Pathfinder/HierarchicalPathFinder.cs @@ -699,8 +699,8 @@ namespace OpenRA.Mods.Common.Pathfinder static CPos GetGridTopLeft(CPos cellInGrid, Grid mapBounds) { return new CPos( - ((cellInGrid.X - mapBounds.TopLeft.X) / GridSize * GridSize) + mapBounds.TopLeft.X, - ((cellInGrid.Y - mapBounds.TopLeft.Y) / GridSize * GridSize) + mapBounds.TopLeft.Y, + (cellInGrid.X - mapBounds.TopLeft.X) / GridSize * GridSize + mapBounds.TopLeft.X, + (cellInGrid.Y - mapBounds.TopLeft.Y) / GridSize * GridSize + mapBounds.TopLeft.Y, cellInGrid.Layer); } diff --git a/OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/BaseBuilderQueueManager.cs b/OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/BaseBuilderQueueManager.cs index 83d58e78c8..ca0f3a2a76 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/BaseBuilderQueueManager.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/BaseBuilderQueueManager.cs @@ -223,8 +223,8 @@ namespace OpenRA.Mods.Common.Traits bool HasSufficientPowerForActor(ActorInfo actorInfo) { - return playerPower == null || (actorInfo.TraitInfos().Where(i => i.EnabledByDefault) - .Sum(p => p.Amount) + playerPower.ExcessPower) >= baseBuilder.Info.MinimumExcessPower; + return playerPower == null || actorInfo.TraitInfos().Where(i => i.EnabledByDefault) + .Sum(p => p.Amount) + playerPower.ExcessPower >= baseBuilder.Info.MinimumExcessPower; } ActorInfo ChooseBuildingToBuild(ProductionQueue queue) diff --git a/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs index 9687f89f1a..1851e7869a 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs @@ -186,11 +186,11 @@ namespace OpenRA.Mods.Common.Traits var checkRadius = powerDecision.CoarseScanRadius; var fineCheck = powerDecision.FineScanRadius; - for (var i = 0 - extendedRange; i <= (checkRadius + extendedRange); i += fineCheck) + for (var i = 0 - extendedRange; i <= checkRadius + extendedRange; i += fineCheck) { var x = checkPos.X + i; - for (var j = 0 - extendedRange; j <= (checkRadius + extendedRange); j += fineCheck) + for (var j = 0 - extendedRange; j <= checkRadius + extendedRange; j += fineCheck) { var y = checkPos.Y + j; var pos = world.Map.CenterOfCell(new CPos(x, y)); diff --git a/OpenRA.Mods.Common/Traits/Crates/GiveCashCrateAction.cs b/OpenRA.Mods.Common/Traits/Crates/GiveCashCrateAction.cs index df072d5aa9..67e6de8c1d 100644 --- a/OpenRA.Mods.Common/Traits/Crates/GiveCashCrateAction.cs +++ b/OpenRA.Mods.Common/Traits/Crates/GiveCashCrateAction.cs @@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits public override int GetSelectionShares(Actor collector) { var pr = collector.Owner.PlayerActor.Trait(); - if (info.Amount < 0 && (pr.Cash + pr.Resources) == 0) + if (info.Amount < 0 && pr.Cash + pr.Resources == 0) return 0; return base.GetSelectionShares(collector); diff --git a/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs b/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs index 62b145adf4..8e32d69085 100644 --- a/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs +++ b/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs @@ -185,7 +185,7 @@ namespace OpenRA.Mods.Common.Widgets var xAxisText = GetXAxisValueFormat().F(n / XAxisTicksPerLabel); var xAxisTickTextWidth = labelFont.Measure(xAxisText).X; - var xLocation = x - (xAxisTickTextWidth / 2); + var xLocation = x - xAxisTickTextWidth / 2; labelFont.DrawTextWithShadow(xAxisText, graphOrigin + new float2(xLocation, 2), Color.White, BackgroundColorDark, BackgroundColorLight, 1); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/LayerSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/LayerSelectorLogic.cs index 928844d2f9..3d04c3a6f5 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/LayerSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/LayerSelectorLogic.cs @@ -58,8 +58,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic layerPreview.ResourceType = resourceType; layerPreview.Bounds.Width = size.Width; layerPreview.Bounds.Height = size.Height; - newResourcePreviewTemplate.Bounds.Width = size.Width + (layerPreview.Bounds.X * 2); - newResourcePreviewTemplate.Bounds.Height = size.Height + (layerPreview.Bounds.Y * 2); + newResourcePreviewTemplate.Bounds.Width = size.Width + layerPreview.Bounds.X * 2; + newResourcePreviewTemplate.Bounds.Height = size.Height + layerPreview.Bounds.Y * 2; newResourcePreviewTemplate.IsVisible = () => true; newResourcePreviewTemplate.GetTooltipText = () => resourceType; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs index 06b3156bbc..246ad0ce3e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs @@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (scrollDown != null) { scrollDown.OnClick = palette.ScrollDown; - scrollDown.IsVisible = () => palette.TotalIconCount > (palette.MaxIconRowOffset * palette.Columns); + scrollDown.IsVisible = () => palette.TotalIconCount > palette.MaxIconRowOffset * palette.Columns; scrollDown.IsDisabled = () => !palette.CanScrollDown; } @@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (scrollUp != null) { scrollUp.OnClick = palette.ScrollUp; - scrollUp.IsVisible = () => palette.TotalIconCount > (palette.MaxIconRowOffset * palette.Columns); + scrollUp.IsVisible = () => palette.TotalIconCount > palette.MaxIconRowOffset * palette.Columns; scrollUp.IsDisabled = () => !palette.CanScrollUp; } @@ -179,7 +179,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic // Check if icon heights exceed y resolution var maxItemsHeight = screenHeight - sidebarProductionHeight; - var maxIconRowOffest = (maxItemsHeight / productionPalette.IconSize.Y) - 1; + var maxIconRowOffest = maxItemsHeight / productionPalette.IconSize.Y - 1; productionPalette.MaxIconRowOffset = Math.Min(maxIconRowOffest, productionPalette.MaximumRows); } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs index 88752253da..a8d312fbf5 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs @@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var power = actor.TraitInfos().Where(i => i.EnabledByDefault).Sum(i => i.Amount); powerLabel.Text = power.ToString(); - powerLabel.GetColor = () => ((pm.PowerProvided - pm.PowerDrained) >= -power || power > 0) + powerLabel.GetColor = () => (pm.PowerProvided - pm.PowerDrained >= -power || power > 0) ? Color.White : Color.Red; powerLabel.Visible = power != 0; powerIcon.Visible = power != 0; diff --git a/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs index ad810f494e..c7a7f3a428 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs @@ -843,7 +843,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (game.State == (int)ServerState.WaitingPlayers && !filters.HasFlag(MPGameFilters.Waiting) && game.Players != 0) return true; - if ((game.Players + game.Spectators) == 0 && !filters.HasFlag(MPGameFilters.Empty)) + if (game.Players + game.Spectators == 0 && !filters.HasFlag(MPGameFilters.Empty)) return true; if (!game.IsCompatible && !filters.HasFlag(MPGameFilters.Incompatible)) diff --git a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs index d9929ab34e..a16dc3d707 100644 --- a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs @@ -372,7 +372,7 @@ namespace OpenRA.Mods.Common.Widgets var thumbHeight = ContentHeight == 0 ? 0 : Math.Max(MinimumThumbSize, (int)(scrollbarHeight * Math.Min(rb.Height * 1f / ContentHeight, 1f))); var oldOffset = currentListOffset; - var newOffset = currentListOffset + ((int)((lastMouseLocation.Y - mi.Location.Y) * (ContentHeight - rb.Height) * 1f / (scrollbarHeight - thumbHeight))); + var newOffset = currentListOffset + (int)((lastMouseLocation.Y - mi.Location.Y) * (ContentHeight - rb.Height) * 1f / (scrollbarHeight - thumbHeight)); newOffset = Math.Min(0, Math.Max(rb.Height - ContentHeight, newOffset)); SetListOffset(newOffset, false); diff --git a/OpenRA.Mods.Common/Widgets/SliderWidget.cs b/OpenRA.Mods.Common/Widgets/SliderWidget.cs index 44a24f07fb..2cbfcd248b 100644 --- a/OpenRA.Mods.Common/Widgets/SliderWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SliderWidget.cs @@ -128,7 +128,7 @@ namespace OpenRA.Mods.Common.Widgets for (var i = 0; i < Ticks; i++) { var tickPos = new float2( - trackOrigin + (i * (trackRect.Width - (int)tick.Size.X) / (Ticks - 1)) - tick.Size.X / 2, + trackOrigin + i * (trackRect.Width - (int)tick.Size.X) / (Ticks - 1) - tick.Size.X / 2, trackRect.Bottom); WidgetUtils.DrawSprite(tick, tickPos); diff --git a/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs b/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs index 48fc525977..033d62207f 100644 --- a/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs +++ b/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs @@ -584,7 +584,7 @@ namespace OpenRA.Mods.Common.Widgets var highlightEndX = font.Measure(apparentText.Substring(0, visualSelectionEndIndex)).X; WidgetUtils.FillRectWithColor( - new Rectangle(textPos.X + highlightStartX, textPos.Y, highlightEndX - highlightStartX, Bounds.Height - (verticalMargin * 2)), TextColorHighlight); + new Rectangle(textPos.X + highlightStartX, textPos.Y, highlightEndX - highlightStartX, Bounds.Height - verticalMargin * 2), TextColorHighlight); } var color = diff --git a/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs b/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs index c4495fd395..7dec3d979c 100644 --- a/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs +++ b/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs @@ -409,8 +409,8 @@ namespace OpenRA.Mods.D2k.UtilityCommands { var tileIndex = (int)stream.Position / 4 - 2; - var x = (tileIndex % mapSize.Width) + MapCordonWidth; - var y = (tileIndex / mapSize.Width) + MapCordonWidth; + var x = tileIndex % mapSize.Width + MapCordonWidth; + var y = tileIndex / mapSize.Width + MapCordonWidth; return new CPos(x, y); }