From eb287d9b8d96648da1bbcf516fe9a0067e163810 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 18 Mar 2023 12:50:55 +0000 Subject: [PATCH] Fix RCS1089 --- .editorconfig | 3 +++ OpenRA.Game/Exts.cs | 8 ++++---- OpenRA.Game/Map/CellRegion.cs | 4 ++-- OpenRA.Game/Map/Map.cs | 2 +- OpenRA.Game/Map/MapCoordsRegion.cs | 2 +- OpenRA.Game/Map/ProjectedCellRegion.cs | 4 ++-- OpenRA.Game/Primitives/Color.cs | 2 +- OpenRA.Mods.Cnc/SpriteLoaders/ShpD2Loader.cs | 2 +- OpenRA.Mods.Cnc/Traits/World/ModelRenderer.cs | 4 ++-- OpenRA.Mods.Common/Projectiles/Railgun.cs | 2 +- OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs | 4 ++-- OpenRA.Mods.Common/SpriteLoaders/TgaLoader.cs | 2 +- OpenRA.Mods.Common/Traits/CaptureManager.cs | 2 +- OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs | 2 +- OpenRA.Mods.Common/Traits/World/Selection.cs | 2 +- OpenRA.Mods.Common/Widgets/MapPreviewWidget.cs | 2 +- OpenRA.Mods.Common/Widgets/RadarWidget.cs | 2 +- 17 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.editorconfig b/.editorconfig index 28a46eb589..d946348231 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1004,6 +1004,9 @@ dotnet_diagnostic.RCS1080.severity = warning # Use coalesce expression instead of conditional expression. dotnet_diagnostic.RCS1084.severity = warning +# Use --/++ operator instead of assignment. +dotnet_diagnostic.RCS1089.severity = warning + # Remove empty region. dotnet_diagnostic.RCS1091.severity = warning diff --git a/OpenRA.Game/Exts.cs b/OpenRA.Game/Exts.cs index 3c613bec29..5a2e5591c8 100644 --- a/OpenRA.Game/Exts.cs +++ b/OpenRA.Game/Exts.cs @@ -302,9 +302,9 @@ namespace OpenRA // Adjust for other rounding modes if (round == ISqrtRoundMode.Nearest && remainder > root) - root += 1; + root++; else if (round == ISqrtRoundMode.Ceiling && root * root < number) - root += 1; + root++; return root; } @@ -343,9 +343,9 @@ namespace OpenRA // Adjust for other rounding modes if (round == ISqrtRoundMode.Nearest && remainder > root) - root += 1; + root++; else if (round == ISqrtRoundMode.Ceiling && root * root < number) - root += 1; + root++; return root; } diff --git a/OpenRA.Game/Map/CellRegion.cs b/OpenRA.Game/Map/CellRegion.cs index b6edac0906..8f204cf27a 100644 --- a/OpenRA.Game/Map/CellRegion.cs +++ b/OpenRA.Game/Map/CellRegion.cs @@ -135,12 +135,12 @@ namespace OpenRA public bool MoveNext() { - u += 1; + u++; // Check for column overflow if (u > r.mapBottomRight.U) { - v += 1; + v++; u = r.mapTopLeft.U; // Check for row overflow diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index f6c0ba46c8..8839b5ff7e 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -611,7 +611,7 @@ namespace OpenRA // Odd-height ramps get bumped up a level to the next even height layer if ((height & 1) == 1 && Ramp[uv] != 0) - height += 1; + height++; var candidates = new List(); diff --git a/OpenRA.Game/Map/MapCoordsRegion.cs b/OpenRA.Game/Map/MapCoordsRegion.cs index e77acd11c2..5c27c23ce3 100644 --- a/OpenRA.Game/Map/MapCoordsRegion.cs +++ b/OpenRA.Game/Map/MapCoordsRegion.cs @@ -35,7 +35,7 @@ namespace OpenRA // Check for column overflow if (u > r.BottomRight.U) { - v += 1; + v++; u = r.TopLeft.U; // Check for row overflow diff --git a/OpenRA.Game/Map/ProjectedCellRegion.cs b/OpenRA.Game/Map/ProjectedCellRegion.cs index 8f4c1d8b55..6fe41e546a 100644 --- a/OpenRA.Game/Map/ProjectedCellRegion.cs +++ b/OpenRA.Game/Map/ProjectedCellRegion.cs @@ -93,12 +93,12 @@ namespace OpenRA public bool MoveNext() { - u += 1; + u++; // Check for column overflow if (u > r.BottomRight.U) { - v += 1; + v++; u = r.TopLeft.U; // Check for row overflow diff --git a/OpenRA.Game/Primitives/Color.cs b/OpenRA.Game/Primitives/Color.cs index 5660386301..520b7d028b 100644 --- a/OpenRA.Game/Primitives/Color.cs +++ b/OpenRA.Game/Primitives/Color.cs @@ -154,7 +154,7 @@ namespace OpenRA.Primitives // Wrap negative values into [0-1) if (h < 0) - h += 1; + h++; var s = delta / rgbMax; return (h, s, v); diff --git a/OpenRA.Mods.Cnc/SpriteLoaders/ShpD2Loader.cs b/OpenRA.Mods.Cnc/SpriteLoaders/ShpD2Loader.cs index 5f7b96ec1d..ea35a111ec 100644 --- a/OpenRA.Mods.Cnc/SpriteLoaders/ShpD2Loader.cs +++ b/OpenRA.Mods.Cnc/SpriteLoaders/ShpD2Loader.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders public ShpD2Frame(Stream s) { var flags = (FormatFlags)s.ReadUInt16(); - s.Position += 1; + s.Position++; var width = s.ReadUInt16(); var height = s.ReadUInt8(); Size = new Size(width, height); diff --git a/OpenRA.Mods.Cnc/Traits/World/ModelRenderer.cs b/OpenRA.Mods.Cnc/Traits/World/ModelRenderer.cs index 57d6a66c4e..cce2dbac61 100644 --- a/OpenRA.Mods.Cnc/Traits/World/ModelRenderer.cs +++ b/OpenRA.Mods.Cnc/Traits/World/ModelRenderer.cs @@ -250,9 +250,9 @@ namespace OpenRA.Mods.Cnc.Traits // Width and height must be even to avoid rendering glitches if ((width & 1) == 1) - width += 1; + width++; if ((height & 1) == 1) - height += 1; + height++; size = new Size(width, height); } diff --git a/OpenRA.Mods.Common/Projectiles/Railgun.cs b/OpenRA.Mods.Common/Projectiles/Railgun.cs index b172b58205..9080fdcd66 100644 --- a/OpenRA.Mods.Common/Projectiles/Railgun.cs +++ b/OpenRA.Mods.Common/Projectiles/Railgun.cs @@ -179,7 +179,7 @@ namespace OpenRA.Mods.Common.Projectiles CycleCount = SourceToTarget.Length / info.HelixPitch.Length; if (SourceToTarget.Length % info.HelixPitch.Length != 0) - CycleCount += 1; // math.ceil, int version. + CycleCount++; // math.ceil, int version. // Using ForwardStep * CycleCount, the helix and the main beam gets "out of sync" // if drawn from source to target. Instead, the main beam is drawn from source to end point of helix. diff --git a/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs b/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs index 8c7f11d660..8d8a021aea 100644 --- a/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs +++ b/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs @@ -41,10 +41,10 @@ namespace OpenRA.Mods.Common.SpriteLoaders var dataWidth = width; var dataHeight = height; if (dataWidth % 2 == 1) - dataWidth += 1; + dataWidth++; if (dataHeight % 2 == 1) - dataHeight += 1; + dataHeight++; Offset = new int2(x + (dataWidth - frameSize.Width) / 2, y + (dataHeight - frameSize.Height) / 2); Size = new Size(dataWidth, dataHeight); diff --git a/OpenRA.Mods.Common/SpriteLoaders/TgaLoader.cs b/OpenRA.Mods.Common/SpriteLoaders/TgaLoader.cs index e27418b8dc..aab73e424d 100644 --- a/OpenRA.Mods.Common/SpriteLoaders/TgaLoader.cs +++ b/OpenRA.Mods.Common/SpriteLoaders/TgaLoader.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders try { // Require true-color images - s.Position += 1; + s.Position++; var colorMapType = s.ReadUInt8(); if (colorMapType != 0) return false; diff --git a/OpenRA.Mods.Common/Traits/CaptureManager.cs b/OpenRA.Mods.Common/Traits/CaptureManager.cs index c66f1bffe3..b9a40f8aa5 100644 --- a/OpenRA.Mods.Common/Traits/CaptureManager.cs +++ b/OpenRA.Mods.Common/Traits/CaptureManager.cs @@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.Traits currentTargetDelay = 0; } else - currentTargetDelay += 1; + currentTargetDelay++; if (capturingToken == Actor.InvalidConditionToken) capturingToken = self.GrantCondition(info.CapturingCondition); diff --git a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs index fa328a0316..4466b31e6e 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs @@ -714,7 +714,7 @@ namespace OpenRA.Mods.Common.Traits return; RemainingCost -= costThisFrame; - RemainingTime -= 1; + RemainingTime--; if (RemainingTime > 0) return; diff --git a/OpenRA.Mods.Common/Traits/World/Selection.cs b/OpenRA.Mods.Common/Traits/World/Selection.cs index 22c51cf905..0dc0089829 100644 --- a/OpenRA.Mods.Common/Traits/World/Selection.cs +++ b/OpenRA.Mods.Common/Traits/World/Selection.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits // Not a real hash, but things checking this only care about checking when the selection has changed // For this purpose, having a false positive (forcing a refresh when nothing changed) is much better // than a false negative (selection state mismatch) - Hash += 1; + Hash++; } public virtual void Add(Actor a) diff --git a/OpenRA.Mods.Common/Widgets/MapPreviewWidget.cs b/OpenRA.Mods.Common/Widgets/MapPreviewWidget.cs index 7e7f4473e9..57bf3fe222 100644 --- a/OpenRA.Mods.Common/Widgets/MapPreviewWidget.cs +++ b/OpenRA.Mods.Common/Widgets/MapPreviewWidget.cs @@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Widgets // Odd rows are shifted right by 1px if ((point.V & 1) == 1) - dx += 1; + dx++; return new int2(mapRect.X + dx, mapRect.Y + dy); } diff --git a/OpenRA.Mods.Common/Widgets/RadarWidget.cs b/OpenRA.Mods.Common/Widgets/RadarWidget.cs index 0655a58c4b..9ab1306d5d 100644 --- a/OpenRA.Mods.Common/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.Common/Widgets/RadarWidget.cs @@ -474,7 +474,7 @@ namespace OpenRA.Mods.Common.Widgets // Odd rows are shifted right by 1px if (isRectangularIsometric && (uv.V & 1) == 1) - dx += 1; + dx++; return new int2(mapRect.X + dx, mapRect.Y + dy); }