Fix a collection of minor style violations.
This enables several new StyleCopAnalyzer rules to be enabled immediately during migration.
This commit is contained in:
@@ -169,7 +169,7 @@ namespace OpenRA.Network
|
||||
var reader = new BinaryReader(networkStream);
|
||||
var serverProtocol = reader.ReadInt32();
|
||||
|
||||
if (ProtocolVersion.Version != serverProtocol)
|
||||
if (serverProtocol != ProtocolVersion.Version)
|
||||
throw new InvalidOperationException(
|
||||
"Protocol version mismatch. Server={0} Client={1}"
|
||||
.F(serverProtocol, ProtocolVersion.Version));
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
@@ -18,8 +19,6 @@ using OpenRA.Primitives;
|
||||
|
||||
namespace OpenRA.Network
|
||||
{
|
||||
using System.Globalization;
|
||||
|
||||
class SyncReport
|
||||
{
|
||||
const int NumSyncReports = 5;
|
||||
|
||||
@@ -123,18 +123,18 @@ namespace OpenRA.Scripting
|
||||
|
||||
public sealed class ScriptContext : IDisposable
|
||||
{
|
||||
public World World { get; private set; }
|
||||
public WorldRenderer WorldRenderer { get; private set; }
|
||||
|
||||
readonly MemoryConstrainedLuaRuntime runtime;
|
||||
readonly LuaFunction tick;
|
||||
|
||||
// Restrict user scripts (excluding system libraries) to 50 MB of memory use
|
||||
const int MaxUserScriptMemory = 50 * 1024 * 1024;
|
||||
|
||||
// Restrict the number of instructions that will be run per map function call
|
||||
const int MaxUserScriptInstructions = 1000000;
|
||||
|
||||
public World World { get; private set; }
|
||||
public WorldRenderer WorldRenderer { get; private set; }
|
||||
|
||||
readonly MemoryConstrainedLuaRuntime runtime;
|
||||
readonly LuaFunction tick;
|
||||
|
||||
readonly Type[] knownActorCommands;
|
||||
public readonly Cache<ActorInfo, Type[]> ActorCommands;
|
||||
public readonly Type[] PlayerCommands;
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA
|
||||
{
|
||||
if (isClick)
|
||||
{
|
||||
var adjNewSelection = newSelection.Take(1); /* TODO: select BEST, not FIRST */
|
||||
var adjNewSelection = newSelection.Take(1); // TODO: select BEST, not FIRST
|
||||
if (isCombine)
|
||||
actors.SymmetricExceptWith(adjNewSelection);
|
||||
else
|
||||
@@ -163,7 +163,7 @@ namespace OpenRA
|
||||
if (!mods.HasModifier(Modifiers.Shift))
|
||||
controlGroups[group].Clear();
|
||||
|
||||
for (var i = 0; i < 10; i++) /* all control groups */
|
||||
for (var i = 0; i < 10; i++) // all control groups
|
||||
controlGroups[i].RemoveAll(a => actors.Contains(a));
|
||||
|
||||
controlGroups[group].AddRange(actors.Where(a => a.Owner == world.LocalPlayer));
|
||||
|
||||
@@ -102,7 +102,9 @@ namespace OpenRA.Server
|
||||
Log.Write("server", "Dropping client {0} for excessive order length = {1}", PlayerIndex, ExpectLength);
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ReceiveState.Data:
|
||||
{
|
||||
@@ -112,7 +114,9 @@ namespace OpenRA.Server
|
||||
server.DispatchOrders(this, Frame, bytes);
|
||||
ExpectLength = 8;
|
||||
State = ReceiveState.Header;
|
||||
} break;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace OpenRA
|
||||
var lsq = x * x + y * y + z * z + w * w;
|
||||
|
||||
// Quaternion components use 10 bits, so there's no risk of overflow
|
||||
#pragma warning disable SA1115 // Allow blank lines to visually separate matrix rows
|
||||
mtx = new Int32Matrix4x4(
|
||||
lsq - 2 * (y * y + z * z),
|
||||
2 * (x * y + z * w),
|
||||
@@ -90,6 +91,7 @@ namespace OpenRA
|
||||
0,
|
||||
0,
|
||||
lsq);
|
||||
#pragma warning restore SA1115
|
||||
}
|
||||
|
||||
public Int32Matrix4x4 AsMatrix()
|
||||
|
||||
@@ -230,10 +230,10 @@ namespace OpenRA.Mods.Cnc.FileFormats
|
||||
InitBigNum(nTmp, 0, len);
|
||||
InitBigNum(n1, 0, len);
|
||||
nTwoBitLen = (int)BitLenBigNum(n2, len);
|
||||
bit = ((uint)1) << (nTwoBitLen % 32);
|
||||
bit = 1U << (nTwoBitLen % 32);
|
||||
j = ((nTwoBitLen + 32) / 32) - 1;
|
||||
nTwoByteLen = (uint)((nTwoBitLen - 1) / 32) * 4;
|
||||
nTmp[nTwoByteLen / 4] |= ((uint)1) << ((nTwoBitLen - 1) & 0x1f);
|
||||
nTmp[nTwoByteLen / 4] |= 1U << ((nTwoBitLen - 1) & 0x1f);
|
||||
|
||||
while (nTwoBitLen > 0)
|
||||
{
|
||||
@@ -431,7 +431,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
|
||||
InitTwoDw(n4, n4_len);
|
||||
n3_bitlen = (int)BitLenBigNum(n3, n4_len);
|
||||
n3_len = (uint)((n3_bitlen + 31) / 32);
|
||||
bit_mask = (((uint)1) << ((n3_bitlen - 1) % 32)) >> 1;
|
||||
bit_mask = (1U << ((n3_bitlen - 1) % 32)) >> 1;
|
||||
pn3 += n3_len - 1;
|
||||
n3_bitlen--;
|
||||
MoveBigNum(n1, n2, n4_len);
|
||||
|
||||
@@ -210,7 +210,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
{
|
||||
// "tib" - Regular Tiberium
|
||||
{ 0x01, new byte[] { 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79 } },
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79 }
|
||||
},
|
||||
|
||||
// "btib" - Blue Tiberium
|
||||
{ 0x02, new byte[] { 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||
@@ -221,7 +222,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
|
||||
// Should be "tib3"
|
||||
0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C,
|
||||
0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6 } },
|
||||
0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6 }
|
||||
},
|
||||
|
||||
// Veins
|
||||
{ 0x03, new byte[] { 0x7E } }
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
{
|
||||
*op++ = *ip++;
|
||||
if (t > 2)
|
||||
*op++ = *ip++;
|
||||
(*op++) = *ip++;
|
||||
}
|
||||
|
||||
t = *ip++;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 },
|
||||
});
|
||||
|
||||
|
||||
@@ -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 = () =>
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user