From 1515ac54f6e7c6c0b387efbf43b2aee5236fcca1 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Wed, 11 Mar 2015 23:57:41 +0000 Subject: [PATCH] Enforce a line length limit. --- OpenRA.Editor/Form1.cs | 9 +++++---- OpenRA.Editor/Surface.cs | 3 ++- OpenRA.Game/Exts.cs | 11 ++++++++--- OpenRA.Game/FileFormats/VqaReader.cs | 8 ++++++-- OpenRA.Game/Map/MapPreview.cs | 12 +++++++++--- OpenRA.Game/Map/TileSet.cs | 3 ++- OpenRA.Game/Network/UPnP.cs | 3 ++- OpenRA.Game/Sound/Sound.cs | 3 ++- OpenRA.Game/Widgets/SliderWidget.cs | 11 +++++++++-- OpenRA.Game/Widgets/VqaPlayerWidget.cs | 4 +++- .../WorldInteractionControllerWidget.cs | 3 ++- OpenRA.Mods.Common/AI/BaseBuilder.cs | 6 ++++-- OpenRA.Mods.Common/Activities/Enter.cs | 3 ++- OpenRA.Mods.Common/Activities/Move/Move.cs | 8 ++++++-- .../Graphics/VoxelActorPreview.cs | 3 ++- .../Scripting/Global/MediaGlobal.cs | 3 ++- OpenRA.Mods.Common/Scripting/ScriptTriggers.cs | 3 ++- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 7 ++++++- OpenRA.Mods.Common/Traits/Air/Plane.cs | 12 ++++++++++-- OpenRA.Mods.Common/Traits/Mobile.cs | 3 ++- OpenRA.Mods.Common/Traits/Player/TechTree.cs | 3 ++- .../Traits/Render/RenderSprites.cs | 9 +++++++-- OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs | 3 ++- .../UtilityCommands/ExtractLuaDocsCommand.cs | 3 ++- .../UtilityCommands/UpgradeRules.cs | 13 +++++++++---- .../Widgets/Logic/AssetBrowserLogic.cs | 3 ++- .../Logic/Ingame/IngamePowerCounterLogic.cs | 3 ++- .../Widgets/Logic/Lobby/ClientTooltipLogic.cs | 6 +++++- .../Widgets/Logic/Lobby/LobbyLogic.cs | 18 ++++++++++++------ .../Logic/Lobby/LobbyMapPreviewLogic.cs | 4 +++- .../Widgets/Logic/MapChooserLogic.cs | 7 +++++-- .../Widgets/Logic/ReplayBrowserLogic.cs | 4 +++- OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs | 10 ++++++++-- Settings.StyleCop | 9 ++++++++- 34 files changed, 156 insertions(+), 57 deletions(-) diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index c52f39e8e1..b2359c1fdb 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -577,10 +577,11 @@ namespace OpenRA.Editor void AboutToolStripMenuItemClick(object sender, EventArgs e) { - MessageBox.Show("OpenRA and OpenRA Editor are Free/Libre Open Source Software released under the GNU General Public License version 3. See AUTHORS and COPYING for details.", - "About", - MessageBoxButtons.OK, - MessageBoxIcon.Asterisk); + MessageBox.Show( + "OpenRA and OpenRA Editor are Free/Libre Open Source Software released under the GNU General Public License version 3. See AUTHORS and COPYING for details.", + "About", + MessageBoxButtons.OK, + MessageBoxIcon.Asterisk); } void HelpToolStripButton_Click(object sender, EventArgs e) diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index ae520adbe0..2cbf2cbbfe 100644 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -283,7 +283,8 @@ namespace OpenRA.Editor var rawImage = tile[index]; for (var x = 0; x < TileSetRenderer.TileSize; x++) for (var y = 0; y < TileSetRenderer.TileSize; y++) - p[(j * TileSetRenderer.TileSize + y) * stride + i * TileSetRenderer.TileSize + x] = Palette.GetColor(rawImage[x + TileSetRenderer.TileSize * y]).ToArgb(); + p[(j * TileSetRenderer.TileSize + y) * stride + i * TileSetRenderer.TileSize + x] = + Palette.GetColor(rawImage[x + TileSetRenderer.TileSize * y]).ToArgb(); if (Map.MapResources.Value[uv].Type != 0) { diff --git a/OpenRA.Game/Exts.cs b/OpenRA.Game/Exts.cs index 8bcfa82638..64fad44cc3 100644 --- a/OpenRA.Game/Exts.cs +++ b/OpenRA.Game/Exts.cs @@ -309,12 +309,16 @@ namespace OpenRA return new HashSet(source); } - public static Dictionary ToDictionaryWithConflictLog(this IEnumerable source, Func keySelector, string debugName, Func logKey, Func logValue) + public static Dictionary ToDictionaryWithConflictLog( + this IEnumerable source, Func keySelector, + string debugName, Func logKey, Func logValue) { return ToDictionaryWithConflictLog(source, keySelector, x => x, debugName, logKey, logValue); } - public static Dictionary ToDictionaryWithConflictLog(this IEnumerable source, Func keySelector, Func elementSelector, string debugName, Func logKey, Func logValue) + public static Dictionary ToDictionaryWithConflictLog( + this IEnumerable source, Func keySelector, Func elementSelector, + string debugName, Func logKey, Func logValue) { // Fall back on ToString() if null functions are provided: logKey = logKey ?? (s => s.ToString()); @@ -385,7 +389,8 @@ namespace OpenRA { for (var j = 0; j < height; j++) { - // Workaround for broken ternary operators in certain versions of mono (3.10 and certain versions of the 3.8 series): https://bugzilla.xamarin.com/show_bug.cgi?id=23319 + // Workaround for broken ternary operators in certain versions of mono + // (3.10 and certain versions of the 3.8 series): https://bugzilla.xamarin.com/show_bug.cgi?id=23319 if (i <= ts.GetUpperBound(0) && j <= ts.GetUpperBound(1)) result[i, j] = ts[i, j]; else diff --git a/OpenRA.Game/FileFormats/VqaReader.cs b/OpenRA.Game/FileFormats/VqaReader.cs index ab7f9cb218..b801392205 100644 --- a/OpenRA.Game/FileFormats/VqaReader.cs +++ b/OpenRA.Game/FileFormats/VqaReader.cs @@ -38,8 +38,12 @@ namespace OpenRA.FileFormats byte[] cbf; byte[] cbp; byte[] cbfBuffer; - byte[] fileBuffer = new byte[256000]; // Buffer for loading file subchunks, the maximum chunk size of a file is not defined - int maxCbfzSize = 256000; // and the header definition for the size of the biggest chunks (color data) isn't accurate. But 256k is large enough for all TS videos(< 200k). + + // Buffer for loading file subchunks, the maximum chunk size of a file is not defined + // and the header definition for the size of the biggest chunks (color data) isn't accurate. + // But 256k is large enough for all TS videos(< 200k). + byte[] fileBuffer = new byte[256000]; + int maxCbfzSize = 256000; int vtprSize = 0; int currentChunkBuffer = 0; int chunkBufferOffset = 0; diff --git a/OpenRA.Game/Map/MapPreview.cs b/OpenRA.Game/Map/MapPreview.cs index 482729eaf2..fb843d1eaa 100644 --- a/OpenRA.Game/Map/MapPreview.cs +++ b/OpenRA.Game/Map/MapPreview.cs @@ -29,9 +29,15 @@ namespace OpenRA // Used for verifying map availability in the lobby public enum MapRuleStatus { Unknown, Cached, Invalid } - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Fields names must match the with the remote API.")] - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1304:NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter", Justification = "Fields names must match the with the remote API.")] - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Fields names must match the with the remote API.")] + [SuppressMessage("StyleCop.CSharp.NamingRules", + "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", + Justification = "Fields names must match the with the remote API.")] + [SuppressMessage("StyleCop.CSharp.NamingRules", + "SA1304:NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter", + Justification = "Fields names must match the with the remote API.")] + [SuppressMessage("StyleCop.CSharp.NamingRules", + "SA1310:FieldNamesMustNotContainUnderscore", + Justification = "Fields names must match the with the remote API.")] public class RemoteMapData { public readonly string title; diff --git a/OpenRA.Game/Map/TileSet.cs b/OpenRA.Game/Map/TileSet.cs index cc293ceb54..1c26b33c27 100644 --- a/OpenRA.Game/Map/TileSet.cs +++ b/OpenRA.Game/Map/TileSet.cs @@ -148,7 +148,8 @@ namespace OpenRA public class TileSet { - static readonly string[] Fields = { "Name", "Id", "SheetSize", "Palette", "PlayerPalette", "Extensions", "WaterPaletteRotationBase", "EditorTemplateOrder", "IgnoreTileSpriteOffsets", "MaximumHeight" }; + static readonly string[] Fields = { "Name", "Id", "SheetSize", "Palette", "PlayerPalette", "Extensions", "WaterPaletteRotationBase", + "EditorTemplateOrder", "IgnoreTileSpriteOffsets", "MaximumHeight" }; public readonly string Name; public readonly string Id; diff --git a/OpenRA.Game/Network/UPnP.cs b/OpenRA.Game/Network/UPnP.cs index 8fc9db8db8..e65679967b 100644 --- a/OpenRA.Game/Network/UPnP.cs +++ b/OpenRA.Game/Network/UPnP.cs @@ -44,7 +44,8 @@ namespace OpenRA.Network if (NatDevice == null || NatDevice.GetType() != typeof(Mono.Nat.Upnp.UpnpNatDevice)) { - Log.Write("server", "No NAT devices with UPnP enabled found within {0} ms deadline. Disabling automatic port forwarding.".F(Game.Settings.Server.NatDiscoveryTimeout)); + Log.Write("server", + "No NAT devices with UPnP enabled found within {0} ms deadline. Disabling automatic port forwarding.".F(Game.Settings.Server.NatDiscoveryTimeout)); Game.Settings.Server.NatDeviceAvailable = false; Game.Settings.Server.AllowPortForward = false; } diff --git a/OpenRA.Game/Sound/Sound.cs b/OpenRA.Game/Sound/Sound.cs index 12aed81df7..7ac399c040 100644 --- a/OpenRA.Game/Sound/Sound.cs +++ b/OpenRA.Game/Sound/Sound.cs @@ -298,7 +298,8 @@ namespace OpenRA } // Returns true if played successfully - public static bool PlayPredefined(Ruleset ruleset, Player p, Actor voicedUnit, string type, string definition, string variant, bool relative, WPos pos, float volumeModifier, bool attenuateVolume) + public static bool PlayPredefined(Ruleset ruleset, Player p, Actor voicedUnit, string type, string definition, string variant, + bool relative, WPos pos, float volumeModifier, bool attenuateVolume) { if (ruleset == null) throw new ArgumentNullException("ruleset"); diff --git a/OpenRA.Game/Widgets/SliderWidget.cs b/OpenRA.Game/Widgets/SliderWidget.cs index 0173eddd31..db3e949e8b 100644 --- a/OpenRA.Game/Widgets/SliderWidget.cs +++ b/OpenRA.Game/Widgets/SliderWidget.cs @@ -82,8 +82,15 @@ namespace OpenRA.Widgets return ThumbRect.Contains(mi.Location); } - float ValueFromPx(int x) { return MinimumValue + (MaximumValue - MinimumValue) * (x - 0.5f * RenderBounds.Height) / (RenderBounds.Width - RenderBounds.Height); } - protected int PxFromValue(float x) { return (int)(0.5f * RenderBounds.Height + (RenderBounds.Width - RenderBounds.Height) * (x - MinimumValue) / (MaximumValue - MinimumValue)); } + float ValueFromPx(int x) + { + return MinimumValue + (MaximumValue - MinimumValue) * (x - 0.5f * RenderBounds.Height) / (RenderBounds.Width - RenderBounds.Height); + } + + protected int PxFromValue(float x) + { + return (int)(0.5f * RenderBounds.Height + (RenderBounds.Width - RenderBounds.Height) * (x - MinimumValue) / (MaximumValue - MinimumValue)); + } public override Widget Clone() { return new SliderWidget(this); } diff --git a/OpenRA.Game/Widgets/VqaPlayerWidget.cs b/OpenRA.Game/Widgets/VqaPlayerWidget.cs index adfe956aec..5581166e18 100644 --- a/OpenRA.Game/Widgets/VqaPlayerWidget.cs +++ b/OpenRA.Game/Widgets/VqaPlayerWidget.cs @@ -82,7 +82,9 @@ namespace OpenRA.Widgets TextureChannel.Alpha); var scale = Math.Min((float)RenderBounds.Width / video.Width, (float)RenderBounds.Height / video.Height * AspectRatio); - videoOrigin = new float2(RenderBounds.X + (RenderBounds.Width - scale * video.Width) / 2, RenderBounds.Y + (RenderBounds.Height - scale * video.Height * AspectRatio) / 2); + videoOrigin = new float2( + RenderBounds.X + (RenderBounds.Width - scale * video.Width) / 2, + RenderBounds.Y + (RenderBounds.Height - scale * video.Height * AspectRatio) / 2); // Round size to integer pixels. Round up to be consistent with the scale calcuation. videoSize = new float2((int)Math.Ceiling(video.Width * scale), (int)Math.Ceiling(video.Height * AspectRatio * scale)); diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index c6ec62f6fc..c16d57a615 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -184,7 +184,8 @@ namespace OpenRA.Widgets } else if (o.TargetLocation != CPos.Zero) { - world.AddFrameEndTask(w => w.Add(new SpriteEffect(worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(mi.Location)), world, "moveflsh", "moveflash"))); + world.AddFrameEndTask(w => w.Add( + new SpriteEffect(worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(mi.Location)), world, "moveflsh", "moveflash"))); flashed = true; } } diff --git a/OpenRA.Mods.Common/AI/BaseBuilder.cs b/OpenRA.Mods.Common/AI/BaseBuilder.cs index 96e6c6dd9f..8807abd56d 100644 --- a/OpenRA.Mods.Common/AI/BaseBuilder.cs +++ b/OpenRA.Mods.Common/AI/BaseBuilder.cs @@ -205,7 +205,8 @@ namespace OpenRA.Mods.Common.AI if (playerPower.ExcessPower < 0 || playerPower.ExcessPower < pis.Sum(pi => pi.Amount)) { // Try building a power plant instead - var power = GetProducibleBuilding("Power", buildableThings, a => a.Traits.WithInterface().Where(i => i.UpgradeMinEnabledLevel < 1).Sum(pi => pi.Amount)); + var power = GetProducibleBuilding("Power", + buildableThings, a => a.Traits.WithInterface().Where(i => i.UpgradeMinEnabledLevel < 1).Sum(pi => pi.Amount)); if (power != null && power.Traits.WithInterface().Where(i => i.UpgradeMinEnabledLevel < 1).Sum(pi => pi.Amount) > 0) { // TODO: Handle the case when of when we actually do need a power plant because we don't have enough but are also suffering from a power outage @@ -220,7 +221,8 @@ namespace OpenRA.Mods.Common.AI } // Lets build this - HackyAI.BotDebug("{0} decided to build {1}: Desired is {2} ({3} / {4}); current is {5} / {4}", queue.Actor.Owner, name, frac.Value, frac.Value * playerBuildings.Length, playerBuildings.Length, count); + HackyAI.BotDebug("{0} decided to build {1}: Desired is {2} ({3} / {4}); current is {5} / {4}", + queue.Actor.Owner, name, frac.Value, frac.Value * playerBuildings.Length, playerBuildings.Length, count); return actor; } diff --git a/OpenRA.Mods.Common/Activities/Enter.cs b/OpenRA.Mods.Common/Activities/Enter.cs index 83473fbae3..46215d2e25 100644 --- a/OpenRA.Mods.Common/Activities/Enter.cs +++ b/OpenRA.Mods.Common/Activities/Enter.cs @@ -51,7 +51,8 @@ namespace OpenRA.Mods.Common.Activities protected virtual void Unreserve(Actor self, bool abort) { } protected virtual void OnInside(Actor self) { } - protected bool TryGetAlternateTargetInCircle(Actor self, WRange radius, Action update, Func primaryFilter, Func[] preferenceFilters = null) + protected bool TryGetAlternateTargetInCircle( + Actor self, WRange radius, Action update, Func primaryFilter, Func[] preferenceFilters = null) { var radiusSquared = radius.Range * radius.Range; var diff = new WVec(radius, radius, WRange.Zero); diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index 5ff3ee01e8..53fbaa5998 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -181,10 +181,14 @@ namespace OpenRA.Mods.Common.Activities else { mobile.SetLocation(mobile.FromCell, mobile.FromSubCell, nextCell.Value.First, nextCell.Value.Second); + var from = self.World.Map.CenterOfSubCell(mobile.FromCell, mobile.FromSubCell); + var to = Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + + (self.World.Map.OffsetOfSubCell(mobile.FromSubCell) + + self.World.Map.OffsetOfSubCell(mobile.ToSubCell)) / 2; var move = new MoveFirstHalf( this, - self.World.Map.CenterOfSubCell(mobile.FromCell, mobile.FromSubCell), - Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (self.World.Map.OffsetOfSubCell(mobile.FromSubCell) + self.World.Map.OffsetOfSubCell(mobile.ToSubCell)) / 2, + from, + to, mobile.Facing, mobile.Facing, 0); diff --git a/OpenRA.Mods.Common/Graphics/VoxelActorPreview.cs b/OpenRA.Mods.Common/Graphics/VoxelActorPreview.cs index dbdf852f25..60f369cd94 100644 --- a/OpenRA.Mods.Common/Graphics/VoxelActorPreview.cs +++ b/OpenRA.Mods.Common/Graphics/VoxelActorPreview.cs @@ -28,7 +28,8 @@ namespace OpenRA.Mods.Common.Graphics readonly WVec offset; readonly int zOffset; - public VoxelPreview(VoxelAnimation[] components, WVec offset, int zOffset, float scale, WAngle lightPitch, WAngle lightYaw, float[] lightAmbientColor, float[] lightDiffuseColor, WAngle cameraPitch, + public VoxelPreview(VoxelAnimation[] components, WVec offset, int zOffset, float scale, WAngle lightPitch, WAngle lightYaw, + float[] lightAmbientColor, float[] lightDiffuseColor, WAngle cameraPitch, PaletteReference colorPalette, PaletteReference normalsPalette, PaletteReference shadowPalette) { this.components = components; diff --git a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs index 8da6a551db..bf181b30eb 100644 --- a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs @@ -120,7 +120,8 @@ namespace OpenRA.Mods.Common.Scripting Action onLoadComplete; Action onCompleteRadar; - [Desc("Play a VQA video in the radar window. File name has to include the file extension. Returns true on success, if the movie wasn't found the function returns false and the callback is executed.")] + [Desc("Play a VQA video in the radar window. File name has to include the file extension. " + + "Returns true on success, if the movie wasn't found the function returns false and the callback is executed.")] public bool PlayMovieInRadar(string movie, LuaFunction playComplete = null) { if (playComplete != null) diff --git a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs index bdedb24fcf..3c887b6028 100644 --- a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs +++ b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs @@ -30,7 +30,8 @@ namespace OpenRA.Mods.Common.Scripting public object Create(ActorInitializer init) { return new ScriptTriggers(init.World); } } - public sealed class ScriptTriggers : INotifyIdle, INotifyDamage, INotifyKilled, INotifyProduction, INotifyOtherProduction, INotifyObjectivesUpdated, INotifyCapture, INotifyInfiltrated, INotifyAddedToWorld, INotifyRemovedFromWorld, IDisposable + public sealed class ScriptTriggers : INotifyIdle, INotifyDamage, INotifyKilled, INotifyProduction, INotifyOtherProduction, + INotifyObjectivesUpdated, INotifyCapture, INotifyInfiltrated, INotifyAddedToWorld, INotifyRemovedFromWorld, IDisposable { readonly World world; diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index bf679bed0e..b5c920d19d 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -203,7 +203,12 @@ namespace OpenRA.Mods.Common.Traits public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return false; } // TODO: Handle landing public SubCell GetValidSubCell(SubCell preferred) { return SubCell.Invalid; } - public SubCell GetAvailableSubCell(CPos a, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true) { return SubCell.Invalid; } // Does not use any subcell + public SubCell GetAvailableSubCell(CPos a, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true) + { + // Does not use any subcell + return SubCell.Invalid; + } + public bool CanEnterCell(CPos cell, Actor ignoreActor = null, bool checkTransientActors = true) { return true; } public bool CanEnterTargetNow(Actor self, Target target) diff --git a/OpenRA.Mods.Common/Traits/Air/Plane.cs b/OpenRA.Mods.Common/Traits/Air/Plane.cs index c24361c5c4..2ff0f34e6c 100644 --- a/OpenRA.Mods.Common/Traits/Air/Plane.cs +++ b/OpenRA.Mods.Common/Traits/Air/Plane.cs @@ -129,12 +129,20 @@ namespace OpenRA.Mods.Common.Traits public Activity MoveTo(CPos cell, int nearEnough) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle()); } public Activity MoveTo(CPos cell, Actor ignoredActor) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle()); } public Activity MoveWithinRange(Target target, WRange range) { return Util.SequenceActivities(new Fly(self, target, WRange.Zero, range), new FlyCircle()); } - public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), new FlyCircle()); } + public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) + { + return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), new FlyCircle()); + } + public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new FlyFollow(self, target, minRange, maxRange); } public CPos NearestMoveableCell(CPos cell) { return cell; } public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) { return new Fly(self, Target.FromCell(self.World, cell)); } - public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos))); } + public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) + { + return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos))); + } + public Activity MoveToTarget(Actor self, Target target) { return new Fly(self, target, WRange.FromCells(3), WRange.FromCells(5)); } public Activity MoveIntoTarget(Actor self, Target target) { return new Land(target); } } diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 98fc0f42c7..18800a3472 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -258,7 +258,8 @@ namespace OpenRA.Mods.Common.Traits return true; } - public SubCell GetAvailableSubCell(World world, Actor self, CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, CellConditions check = CellConditions.All) + public SubCell GetAvailableSubCell( + World world, Actor self, CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, CellConditions check = CellConditions.All) { if (MovementCostForCell(world, cell) == int.MaxValue) return SubCell.Invalid; diff --git a/OpenRA.Mods.Common/Traits/Player/TechTree.cs b/OpenRA.Mods.Common/Traits/Player/TechTree.cs index 4809e51f53..00fb3c624c 100644 --- a/OpenRA.Mods.Common/Traits/Player/TechTree.cs +++ b/OpenRA.Mods.Common/Traits/Player/TechTree.cs @@ -134,7 +134,8 @@ namespace OpenRA.Mods.Common.Traits bool IsHidden(Cache> ownedPrerequisites) { - return prerequisites.Any(prereq => prereq.StartsWith("~") && (prereq.Replace("~", "").StartsWith("!") ^ !ownedPrerequisites.ContainsKey(prereq.Replace("~", "").Replace("!", "")))); + return prerequisites.Any(prereq => prereq.StartsWith("~") && + (prereq.Replace("~", "").StartsWith("!") ^ !ownedPrerequisites.ContainsKey(prereq.Replace("~", "").Replace("!", "")))); } public void Update(Cache> ownedPrerequisites) diff --git a/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs b/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs index f6ea77600b..90ffee6429 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs @@ -18,7 +18,10 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public interface IRenderActorPreviewSpritesInfo { IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p); } + public interface IRenderActorPreviewSpritesInfo + { + IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p); + } public class RenderSpritesInfo : IRenderActorPreviewInfo, ITraitInfo { @@ -60,7 +63,9 @@ namespace OpenRA.Mods.Common.Traits var facings = 0; var body = init.Actor.Traits.GetOrDefault(); if (body != null) - facings = body.QuantizedFacings == -1 ? init.Actor.Traits.Get().QuantizedBodyFacings(init.Actor, sequenceProvider, init.Owner.Country.Race) : body.QuantizedFacings; + facings = body.QuantizedFacings == -1 ? + init.Actor.Traits.Get().QuantizedBodyFacings(init.Actor, sequenceProvider, init.Owner.Country.Race) : + body.QuantizedFacings; foreach (var spi in init.Actor.Traits.WithInterface()) foreach (var preview in spi.RenderPreviewSprites(init, this, image, facings, palette)) diff --git a/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs b/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs index 0320e12f01..0e51472955 100644 --- a/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs +++ b/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs @@ -42,7 +42,8 @@ namespace OpenRA.Mods.Common.Traits var cp = self.CenterPosition; - if (info.DeathTypes.Contains(e.Warhead.DeathType) || (!info.DeathTypes.Any() && !self.Info.Traits.WithInterface().Any(dsi => dsi.DeathTypes.Contains(e.Warhead.DeathType)))) + if (info.DeathTypes.Contains(e.Warhead.DeathType) || + (!info.DeathTypes.Any() && !self.Info.Traits.WithInterface().Any(dsi => dsi.DeathTypes.Contains(e.Warhead.DeathType)))) Sound.PlayVoiceLocal(info.DeathSound, self, self.Owner.Country.Race, cp, info.VolumeMultiplier); } } diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs index 6016db671c..bbb3e70195 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs @@ -33,7 +33,8 @@ namespace OpenRA.Mods.Common.UtilityCommands "These scripts run in a sandbox that prevents access to unsafe functions (e.g. OS or file access), " + "and limits the memory and CPU usage of the scripts."); Console.WriteLine(); - Console.WriteLine("You can access this interface by adding the [LuaScript](Traits#luascript) trait to the world actor in your map rules (note, you must replace the spaces in the snippet below with a single tab for each level of indentation):"); + Console.WriteLine("You can access this interface by adding the [LuaScript](Traits#luascript) trait to the world actor in your map rules " + + "(note, you must replace the spaces in the snippet below with a single tab for each level of indentation):"); Console.WriteLine("```\nRules:\n\tWorld:\n\t\tLuaScript:\n\t\t\tScripts: myscript.lua\n```"); Console.WriteLine(); Console.WriteLine("Map scripts can interact with the game engine in three ways:\n" + diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 8118e370d0..21e048016d 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -793,8 +793,11 @@ namespace OpenRA.Mods.Common.UtilityCommands // Split out the warheads to individual warhead types. if (depth == 0) { - var validTargets = node.Value.Nodes.FirstOrDefault(n => n.Key == "ValidTargets"); // Weapon's ValidTargets need to be copied to the warheads, so find it - var invalidTargets = node.Value.Nodes.FirstOrDefault(n => n.Key == "InvalidTargets"); // Weapon's InvalidTargets need to be copied to the warheads, so find it + // Weapon's ValidTargets need to be copied to the warheads, so find it + var validTargets = node.Value.Nodes.FirstOrDefault(n => n.Key == "ValidTargets"); + + // Weapon's InvalidTargets need to be copied to the warheads, so find it + var invalidTargets = node.Value.Nodes.FirstOrDefault(n => n.Key == "InvalidTargets"); var warheadCounter = 0; foreach (var curNode in node.Value.Nodes.ToArray()) @@ -970,7 +973,8 @@ namespace OpenRA.Mods.Common.UtilityCommands var newYaml = new List(); - var keywords = new List { "Explosion", "ImpactSound", "Delay", "ValidTargets", "InvalidTargets", "ValidImpactTypes", "InvalidImpactTypes" }; + var keywords = new List { "Explosion", "ImpactSound", "Delay", + "ValidTargets", "InvalidTargets", "ValidImpactTypes", "InvalidImpactTypes" }; foreach (var keyword in keywords) { @@ -991,7 +995,8 @@ namespace OpenRA.Mods.Common.UtilityCommands var newYaml = new List(); - var keywords = new List { "WaterExplosion", "WaterImpactSound", "Delay", "ValidTargets", "InvalidTargets", "ValidImpactTypes", "InvalidImpactTypes" }; + var keywords = new List { "WaterExplosion", "WaterImpactSound", "Delay", + "ValidTargets", "InvalidTargets", "ValidImpactTypes", "InvalidImpactTypes" }; foreach (var keyword in keywords) { diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index 5960ef1530..9c41b22b7c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -114,7 +114,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic var frameContainer = panel.GetOrNull("FRAME_SELECTOR"); if (frameContainer != null) - frameContainer.IsVisible = () => (currentSprites != null && currentSprites.Length > 1) || (isVideoLoaded && player != null && player.Video != null && player.Video.Frames > 1); + frameContainer.IsVisible = () => (currentSprites != null && currentSprites.Length > 1) || + (isVideoLoaded && player != null && player.Video != null && player.Video.Frames > 1); frameSlider = panel.Get("FRAME_SLIDER"); if (frameSlider != null) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs index c4c9a5b48d..cf5bfe6e20 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs @@ -26,7 +26,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic powerIcon.GetImageName = () => powerManager.ExcessPower < 0 ? "power-critical" : "power-normal"; power.GetColor = () => powerManager.ExcessPower < 0 ? Color.Red : Color.White; power.GetText = () => powerManager.PowerProvided == 1000000 ? "inf" : powerManager.ExcessPower.ToString(); - power.GetTooltipText = () => "Power Usage: " + powerManager.PowerDrained.ToString() + (powerManager.PowerProvided != 1000000 ? "/" + powerManager.PowerProvided.ToString() : ""); + power.GetTooltipText = () => "Power Usage: " + powerManager.PowerDrained.ToString() + + (powerManager.PowerProvided != 1000000 ? "/" + powerManager.PowerProvided.ToString() : ""); } } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/ClientTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/ClientTooltipLogic.cs index 18badf3370..f028d99dc1 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/ClientTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/ClientTooltipLogic.cs @@ -46,7 +46,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic tooltipContainer.BeforeRender = () => { var latencyPrefixSize = latencyPrefix.Bounds.X + latencyPrefixFont.Measure(latencyPrefix.GetText() + " ").X; - var width = Math.Max(locationFont.Measure(location.GetText()).X, Math.Max(adminFont.Measure(admin.GetText()).X, Math.Max(addressFont.Measure(ip.GetText()).X, latencyPrefixSize + latencyFont.Measure(latency.GetText()).X))); + var locationWidth = locationFont.Measure(location.GetText()).X; + var adminWidth = adminFont.Measure(admin.GetText()).X; + var addressWidth = addressFont.Measure(ip.GetText()).X; + var latencyWidth = latencyPrefixSize + latencyFont.Measure(latency.GetText()).X; + var width = Math.Max(locationWidth, Math.Max(adminWidth, Math.Max(addressWidth, latencyWidth))); widget.Bounds.Width = width + 2 * margin; latency.Bounds.Width = widget.Bounds.Width; ip.Bounds.Width = widget.Bounds.Width; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index d96accdeef..8259af78c0 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -408,8 +408,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic return selectedClass != null ? selectedClass : c; }; - startingUnits.IsDisabled = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits || configurationDisabled(); - startingUnits.GetText = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass); + startingUnits.IsDisabled = () => Map.Status != MapStatus.Available || + !Map.Map.Options.ConfigurableStartingUnits || configurationDisabled(); + startingUnits.GetText = () => Map.Status != MapStatus.Available || + !Map.Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass); startingUnits.OnMouseDown = _ => { var options = classes.Select(c => new DropDownOption @@ -435,8 +437,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var startingCash = optionsBin.GetOrNull("STARTINGCASH_DROPDOWNBUTTON"); if (startingCash != null) { - startingCash.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue || configurationDisabled(); - startingCash.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash); + startingCash.IsDisabled = () => Map.Status != MapStatus.Available || + Map.Map.Options.StartingCash.HasValue || configurationDisabled(); + startingCash.GetText = () => Map.Status != MapStatus.Available || + Map.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash); startingCash.OnMouseDown = _ => { var options = modRules.Actors["player"].Traits.Get().SelectableCash.Select(c => new DropDownOption @@ -463,8 +467,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var techTraits = modRules.Actors["player"].Traits.WithInterface().ToList(); techLevel.IsVisible = () => techTraits.Count > 0; optionsBin.GetOrNull("TECHLEVEL_DESC").IsVisible = () => techTraits.Count > 0; - techLevel.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.TechLevel != null || configurationDisabled() || techTraits.Count <= 1; - techLevel.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.TechLevel != null ? "Not Available" : "{0}".F(orderManager.LobbyInfo.GlobalSettings.TechLevel); + techLevel.IsDisabled = () => Map.Status != MapStatus.Available || + Map.Map.Options.TechLevel != null || configurationDisabled() || techTraits.Count <= 1; + techLevel.GetText = () => Map.Status != MapStatus.Available || + Map.Map.Options.TechLevel != null ? "Not Available" : "{0}".F(orderManager.LobbyInfo.GlobalSettings.TechLevel); techLevel.OnMouseDown = _ => { var options = techTraits.Select(c => new DropDownOption diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyMapPreviewLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyMapPreviewLogic.cs index 16a4c587be..1fa4bf28de 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyMapPreviewLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyMapPreviewLogic.cs @@ -90,7 +90,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var progress = widget.GetOrNull("MAP_PROGRESS"); if (progress != null) { - progress.IsVisible = () => (lobby.Map.Status != MapStatus.Available || lobby.Map.RuleStatus == MapRuleStatus.Unknown) && lobby.Map.Status != MapStatus.DownloadAvailable; + progress.IsVisible = () => + (lobby.Map.Status != MapStatus.Available || lobby.Map.RuleStatus == MapRuleStatus.Unknown) && + lobby.Map.Status != MapStatus.DownloadAvailable; var preview = progress.Get("MAP_PREVIEW"); preview.Preview = () => lobby.Map; diff --git a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs index 770fe328dc..9832270b50 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs @@ -114,7 +114,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var maps = Game.ModData.MapCache .Where(m => m.Status == MapStatus.Available && (m.Map.Visibility & filter) != 0) .Where(m => gameMode == null || m.Type == gameMode) - .Where(m => mapFilter == null || m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0 || m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0) + .Where(m => mapFilter == null || + m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0 || + m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0) .OrderBy(m => m.PlayerCount) .ThenBy(m => m.Title); @@ -126,7 +128,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic // Access the minimap to trigger async generation of the minimap. preview.GetMinimap(); - var item = ScrollItemWidget.Setup(preview.Uid, itemTemplate, () => selectedUid == preview.Uid, () => selectedUid = preview.Uid, () => { Ui.CloseWindow(); onSelect(preview.Uid); }); + var item = ScrollItemWidget.Setup(preview.Uid, itemTemplate, () => selectedUid == preview.Uid, + () => selectedUid = preview.Uid, () => { Ui.CloseWindow(); onSelect(preview.Uid); }); item.IsVisible = () => item.RenderBounds.IntersectsWith(scrollpanel.RenderBounds); var titleLabel = item.Get("TITLE"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs index d02cf5d211..adbcb007cb 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs @@ -299,7 +299,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic { ddb.IsDisabled = () => string.IsNullOrEmpty(filter.PlayerName); - var options = replays.SelectMany(r => r.GameInfo.Players.Select(p => p.FactionName).Where(n => !string.IsNullOrEmpty(n))).Distinct(StringComparer.OrdinalIgnoreCase).ToList(); + var options = replays + .SelectMany(r => r.GameInfo.Players.Select(p => p.FactionName).Where(n => !string.IsNullOrEmpty(n))) + .Distinct(StringComparer.OrdinalIgnoreCase).ToList(); options.Sort(StringComparer.OrdinalIgnoreCase); options.Insert(0, null); // no filter diff --git a/OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs b/OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs index e3dccf5c21..d6491c1550 100644 --- a/OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs +++ b/OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs @@ -17,7 +17,11 @@ using OpenRA.Traits; namespace OpenRA.Mods.TS.Traits { - public interface IRenderActorPreviewVoxelsInfo { IEnumerable RenderPreviewVoxels(ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p); } + public interface IRenderActorPreviewVoxelsInfo + { + IEnumerable RenderPreviewVoxels( + ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p); + } public class RenderVoxelsInfo : ITraitInfo, IRenderActorPreviewInfo, Requires { @@ -46,7 +50,9 @@ namespace OpenRA.Mods.TS.Traits var body = init.Actor.Traits.Get(); var sequenceProvider = init.World.Map.SequenceProvider; var image = Image ?? init.Actor.Name; - var facings = body.QuantizedFacings == -1 ? init.Actor.Traits.Get().QuantizedBodyFacings(init.Actor, sequenceProvider, init.Owner.Country.Race) : body.QuantizedFacings; + var facings = body.QuantizedFacings == -1 ? + init.Actor.Traits.Get().QuantizedBodyFacings(init.Actor, sequenceProvider, init.Owner.Country.Race) : + body.QuantizedFacings; var palette = init.WorldRenderer.Palette(Palette ?? PlayerPalette + init.Owner.InternalName); var ifacing = init.Actor.Traits.GetOrDefault(); diff --git a/Settings.StyleCop b/Settings.StyleCop index 0652af92b3..dce8c7e2f0 100644 --- a/Settings.StyleCop +++ b/Settings.StyleCop @@ -394,8 +394,15 @@ False + + + True + + - + + 180:4 + \ No newline at end of file