Fix a collection of minor style violations.

This enables several new StyleCopAnalyzer rules to
be enabled immediately during migration.
This commit is contained in:
Paul Chote
2019-05-02 21:35:47 +00:00
committed by reaperrr
parent 76a8ae9f98
commit 353db73381
28 changed files with 58 additions and 49 deletions

View File

@@ -248,7 +248,7 @@ namespace OpenRA.Mods.Common.FileFormats
{
*op++ = *ip++;
if (t > 2)
*op++ = *ip++;
(*op++) = *ip++;
}
t = *ip++;

View File

@@ -63,7 +63,8 @@ namespace OpenRA.Mods.Common.LoadScreens
var widgetArgs = new WidgetArgs
{
{ "continueLoading", () =>
Game.RunAfterTick(() => Game.InitializeMod(modId, new Arguments())) },
Game.RunAfterTick(() => Game.InitializeMod(modId, new Arguments()))
},
{ "mod", selectedMod },
{ "content", content },
};
@@ -77,7 +78,8 @@ namespace OpenRA.Mods.Common.LoadScreens
{ "mod", selectedMod },
{ "content", content },
{ "onCancel", () =>
Game.RunAfterTick(() => Game.InitializeMod(modId, new Arguments())) }
Game.RunAfterTick(() => Game.InitializeMod(modId, new Arguments()))
}
};
Ui.OpenWindow("CONTENT_PANEL", widgetArgs);

View File

@@ -441,7 +441,7 @@ namespace OpenRA.Mods.Common.Projectiles
}
// NOTE: It might be desirable to make lookahead more intelligent by outputting more information
// than just the highest point in the lookahead distance
// than just the highest point in the lookahead distance
void InclineLookahead(World world, int distCheck, out int predClfHgt, out int predClfDist, out int lastHtChg, out int lastHt)
{
predClfHgt = 0; // Highest probed terrain height

View File

@@ -217,7 +217,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
bw.Write((ushort)0);
bw.Write((ushort)size.Width);
bw.Write((ushort)size.Height);
bw.Write((uint)0);
bw.Write(0U);
foreach (var f in compressedFrames)
{

View File

@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
// Checks the number of anti air enemies around units
protected virtual bool ShouldFlee(Squad owner)
{
return base.ShouldFlee(owner, enemies => CountAntiAirUnits(enemies) * MissileUnitMultiplier > owner.Units.Count);
return ShouldFlee(owner, enemies => CountAntiAirUnits(enemies) * MissileUnitMultiplier > owner.Units.Count);
}
}

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
{
protected virtual bool ShouldFlee(Squad owner)
{
return base.ShouldFlee(owner, enemies => !AttackOrFleeFuzzy.Default.CanAttack(owner.Units, enemies));
return ShouldFlee(owner, enemies => !AttackOrFleeFuzzy.Default.CanAttack(owner.Units, enemies));
}
protected Actor FindClosestEnemy(Squad owner)

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
{
protected virtual bool ShouldFlee(Squad owner)
{
return base.ShouldFlee(owner, enemies => !AttackOrFleeFuzzy.Default.CanAttack(owner.Units, enemies));
return ShouldFlee(owner, enemies => !AttackOrFleeFuzzy.Default.CanAttack(owner.Units, enemies));
}
protected Actor FindClosestEnemy(Squad owner)

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string Owner = "Creeps";
[Desc("Type of ActorSpawner with which it connects.")]
public readonly HashSet<string> Types = new HashSet<string>() { };
public readonly HashSet<string> Types = new HashSet<string>() { };
public override object Create(ActorInitializer init) { return new ActorSpawnManager(init.Self, this); }
}

View File

@@ -132,7 +132,7 @@ namespace OpenRA.Mods.Common.Traits
var n = taken.Count == 0 || !separateTeamSpawns
? world.SharedRandom.Next(available.Count)
: available // pick the most distant spawnpoint from everyone else
: available // pick the most distant spawnpoint from everyone else
.Select((k, i) => Pair.New(k, i))
.MaxBy(a => taken.Sum(t => (t - a.First).LengthSquared)).Second;

View File

@@ -37,4 +37,4 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
yield break;
}
}
}
}

View File

@@ -134,7 +134,7 @@ namespace OpenRA.Mods.Common.Widgets
var c = (int*)cc;
for (var v = 0; v < 256; v++)
for (var s = 0; s < 256; s++)
*(c + (v * 256) + s) = Color.FromAhsv(hue, s / 255f, (255 - v) / 255f).ToArgb();
(*(c + (v * 256) + s)) = Color.FromAhsv(hue, s / 255f, (255 - v) / 255f).ToArgb();
}
}

View File

@@ -19,10 +19,8 @@ namespace OpenRA.Mods.Common.Widgets
public double ExpA = 1.0e-3;
public double ExpB = 6.908;
public ExponentialSliderWidget() :
base() { }
public ExponentialSliderWidget(ExponentialSliderWidget other) :
base(other) { }
public ExponentialSliderWidget(ExponentialSliderWidget other)
: base(other) { }
float ExpFromLinear(float x)
{

View File

@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (!isObserver && orderManager.LocalClient == null && world.LocalPlayer == null)
return true;
var teamNumber = (uint)0;
var teamNumber = 0U;
if (team)
teamNumber = (isObserver || world.LocalPlayer.WinState != WinState.Undefined) ? uint.MaxValue : (uint)orderManager.LocalClient.Team;

View File

@@ -128,7 +128,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ "orderManager", orderManager },
{ "getMap", (Func<MapPreview>)(() => map) },
{ "onMouseDown", (Action<MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) =>
LobbyUtils.SelectSpawnPoint(orderManager, preview, mapPreview, mi)) },
LobbyUtils.SelectSpawnPoint(orderManager, preview, mapPreview, mi))
},
{ "getSpawnOccupants", (Func<MapPreview, Dictionary<CPos, SpawnOccupant>>)(mapPreview => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, mapPreview)) },
{ "showUnoccupiedSpawnpoints", true },
});
@@ -402,7 +403,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Always scroll to bottom when we've typed something
lobbyChatPanel.ScrollToBottom();
var teamNumber = (uint)0;
var teamNumber = 0U;
if (teamChat && orderManager.LocalClient != null)
teamNumber = orderManager.LocalClient.IsObserver ? uint.MaxValue : (uint)orderManager.LocalClient.Team;

View File

@@ -82,7 +82,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ "getMap", (Func<MapPreview>)(() => map) },
{ "onMouseDown", (Action<MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) => { }) },
{ "getSpawnOccupants", (Func<MapPreview, Dictionary<CPos, SpawnOccupant>>)(mapPreview =>
LobbyUtils.GetSpawnOccupants(selectedReplay.GameInfo.Players, mapPreview)) },
LobbyUtils.GetSpawnOccupants(selectedReplay.GameInfo.Players, mapPreview))
},
{ "showUnoccupiedSpawnpoints", false },
});

View File

@@ -70,11 +70,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
current.Save();
Action closeAndExit = () => { Ui.CloseWindow(); onExit(); };
if (OriginalSoundDevice != current.Sound.Device ||
OriginalGraphicsMode != current.Graphics.Mode ||
OriginalGraphicsWindowedSize != current.Graphics.WindowedSize ||
OriginalGraphicsFullscreenSize != current.Graphics.FullscreenSize ||
OriginalServerDiscoverNatDevices != current.Server.DiscoverNatDevices)
if (current.Sound.Device != OriginalSoundDevice ||
current.Graphics.Mode != OriginalGraphicsMode ||
current.Graphics.WindowedSize != OriginalGraphicsWindowedSize ||
current.Graphics.FullscreenSize != OriginalGraphicsFullscreenSize ||
current.Server.DiscoverNatDevices != OriginalServerDiscoverNatDevices)
{
Action restart = () =>
{

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Widgets
var scaledHeight = (int)videoSize.Y;
overlay = new uint[Exts.NextPowerOf2(scaledHeight), 1];
var black = (uint)255 << 24;
var black = 255U << 24;
for (var y = 0; y < scaledHeight; y += 2)
overlay[y, 0] = black;