From a6cda967c25ee9a4876b038248a3da61a166a679 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sun, 4 Jan 2015 22:09:32 +0000 Subject: [PATCH] Formatted all files. Automatically formatted all files via VS. This generally corrects indentation, removes trailing whitespace and corrects misplaced tabs or spaces. Manually tweaked a few files where required. --- OpenRA.Editor/Surface.cs | 5 +- OpenRA.Game/Exts.cs | 2 +- OpenRA.Game/FieldLoader.cs | 4 +- .../FileFormats/BlowfishKeyProvider.cs | 3 +- OpenRA.Game/FileFormats/HvaReader.cs | 20 +-- OpenRA.Game/FileFormats/IniFile.cs | 6 +- OpenRA.Game/FileFormats/VqaReader.cs | 54 +++--- OpenRA.Game/FileFormats/WavLoader.cs | 4 +- OpenRA.Game/FileSystem/Folder.cs | 4 +- OpenRA.Game/FileSystem/MixFile.cs | 2 +- OpenRA.Game/FileSystem/PackageEntry.cs | 62 +++---- OpenRA.Game/Game.cs | 2 +- OpenRA.Game/GameRules/ActorInfo.cs | 3 +- OpenRA.Game/GameRules/Warhead.cs | 4 +- OpenRA.Game/Graphics/IGraphicsDevice.cs | 2 +- .../Graphics/SelectionBarsRenderable.cs | 2 +- OpenRA.Game/Graphics/Util.cs | 14 +- OpenRA.Game/Graphics/VoxelRenderer.cs | 23 +-- OpenRA.Game/MiniYaml.cs | 3 +- OpenRA.Game/Network/Handshake.cs | 4 +- OpenRA.Game/Network/UnitOrders.cs | 2 +- OpenRA.Game/ObjectCreator.cs | 2 +- OpenRA.Game/Platform.cs | 54 +++--- OpenRA.Game/Server/Server.cs | 74 ++++---- OpenRA.Game/Sound/Sound.cs | 10 +- OpenRA.Game/Support/Log.cs | 4 +- OpenRA.Game/Traits/Health.cs | 6 +- OpenRA.Game/Traits/Target.cs | 44 ++--- OpenRA.Game/Traits/TraitsInterfaces.cs | 4 +- OpenRA.Game/WRange.cs | 18 +- OpenRA.Game/WRot.cs | 6 +- OpenRA.Game/Widgets/ButtonWidget.cs | 14 +- OpenRA.Game/Widgets/DropDownButtonWidget.cs | 6 +- OpenRA.Game/Widgets/SliderWidget.cs | 28 +-- OpenRA.Game/Widgets/TextFieldWidget.cs | 7 +- OpenRA.Game/Widgets/VqaPlayerWidget.cs | 8 +- OpenRA.Game/Widgets/Widget.cs | 2 +- OpenRA.Game/Widgets/WidgetLoader.cs | 2 +- OpenRA.Game/Widgets/WidgetUtils.cs | 2 +- .../WorldInteractionControllerWidget.cs | 4 +- OpenRA.Game/World.cs | 2 +- OpenRA.GameMonitor/GameMonitor.cs | 8 +- .../Activities/HarvesterDockSequence.cs | 3 +- .../Activities/Air/ReturnToBase.cs | 2 +- OpenRA.Mods.Common/Activities/Attack.cs | 2 +- OpenRA.Mods.Common/Activities/Enter.cs | 4 +- .../Activities/EnterTransport.cs | 2 +- OpenRA.Mods.Common/Activities/Hunt.cs | 2 +- OpenRA.Mods.Common/Commands/HelpCommand.cs | 2 +- OpenRA.Mods.Common/Commands/PlayerCommands.cs | 4 +- OpenRA.Mods.Common/Effects/Beacon.cs | 2 +- OpenRA.Mods.Common/Effects/Missile.cs | 2 +- .../Graphics/VoxelRenderable.cs | 35 ++-- .../Scripting/Global/MapGlobal.cs | 3 +- .../Scripting/Global/MediaGlobal.cs | 3 +- .../Scripting/Global/TriggerGlobal.cs | 2 +- .../Scripting/ScriptTriggers.cs | 7 +- .../ServerTraits/MasterServerPinger.cs | 4 +- .../SpriteLoaders/ShpTDLoader.cs | 32 ++-- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 12 +- OpenRA.Mods.Common/Traits/Air/Plane.cs | 2 +- .../Traits/Air/TargetableAircraft.cs | 7 +- OpenRA.Mods.Common/Traits/Armament.cs | 2 +- .../Traits/Attack/AttackBase.cs | 26 +-- .../Traits/Attack/AttackCharge.cs | 12 +- OpenRA.Mods.Common/Traits/Buildable.cs | 2 +- .../Traits/Buildings/DeadBuildingState.cs | 4 +- .../Traits/Buildings/Reservable.cs | 11 +- OpenRA.Mods.Common/Traits/Cloak.cs | 2 +- OpenRA.Mods.Common/Traits/GivesBounty.cs | 2 +- OpenRA.Mods.Common/Traits/GlobalUpgradable.cs | 2 +- OpenRA.Mods.Common/Traits/Huntable.cs | 6 +- OpenRA.Mods.Common/Traits/IgnoresDisguise.cs | 6 +- OpenRA.Mods.Common/Traits/Mobile.cs | 6 +- .../Traits/Player/MissionObjectives.cs | 12 +- .../Traits/Player/PlayerStatistics.cs | 2 +- .../Player/ProvidesCustomPrerequisite.cs | 2 +- OpenRA.Mods.Common/Traits/Power/Power.cs | 2 +- .../Traits/Render/RenderBuildingTurreted.cs | 2 +- .../Traits/Render/WithBuildingExplosion.cs | 2 +- .../Render/WithBuildingPlacedAnimation.cs | 2 +- .../Traits/Render/WithMakeAnimation.cs | 2 +- .../Traits/Render/WithResources.cs | 7 +- OpenRA.Mods.Common/Traits/SelfHealing.cs | 2 +- .../Traits/Sound/AnnounceOnKill.cs | 2 +- .../Traits/Sound/DeathSounds.cs | 2 +- OpenRA.Mods.Common/Traits/World/PathFinder.cs | 4 +- .../Traits/World/ShroudRenderer.cs | 2 +- .../Traits/World/TerrainGeometryOverlay.cs | 4 +- .../UtilityCommands/LegacyMapImporter.cs | 2 +- .../UtilityCommands/UpgradeRules.cs | 18 +- .../Widgets/ColorMixerWidget.cs | 30 ++-- .../Widgets/Logic/AssetBrowserLogic.cs | 30 ++-- .../Widgets/Logic/DisconnectWatcherLogic.cs | 2 +- .../Widgets/Logic/SettingsLogic.cs | 6 +- OpenRA.Mods.Common/Widgets/RadarWidget.cs | 2 +- .../Widgets/ResourceBarWidget.cs | 5 +- OpenRA.Mods.D2k/Activities/CarryUnit.cs | 4 +- OpenRA.Mods.D2k/Traits/World/PaletteFromR8.cs | 2 +- OpenRA.Mods.D2k/Traits/World/WormManager.cs | 2 +- OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs | 4 +- OpenRA.Mods.RA/AI/AttackOrFleeFuzzy.cs | 4 +- OpenRA.Mods.RA/AI/HackyAI.cs | 29 ++- OpenRA.Mods.RA/Activities/LayMines.cs | 2 +- .../Activities/RAHarvesterDockSequence.cs | 3 +- OpenRA.Mods.RA/Cloneable.cs | 6 +- OpenRA.Mods.RA/Effects/RepairIndicator.cs | 6 +- OpenRA.Mods.RA/EjectOnDeath.cs | 2 +- OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs | 6 +- OpenRA.Mods.RA/Lint/CheckMapCordon.cs | 6 +- OpenRA.Mods.RA/Player/AllyRepair.cs | 1 - OpenRA.Mods.RA/Player/PlaceBuilding.cs | 2 +- OpenRA.Mods.RA/Player/ProductionQueue.cs | 112 ++++++------ .../ProductionQueueFromSelection.cs | 2 +- OpenRA.Mods.RA/Repairable.cs | 7 +- .../Scripting/Global/ReinforcementsGlobal.cs | 2 +- .../Scripting/Properties/PlayerProperties.cs | 2 +- .../SupportPowers/GrantUpgradePower.cs | 2 +- OpenRA.Mods.RA/SupportPowers/NukePower.cs | 2 +- OpenRA.Mods.RA/Traits/Buildings/Bridge.cs | 2 +- .../Traits/Buildings/ClonesProducedUnits.cs | 6 +- OpenRA.Mods.RA/Traits/Buildings/Fake.cs | 2 +- .../Traits/Buildings/RepairableBuilding.cs | 4 +- OpenRA.Mods.RA/Traits/Crates/Crate.cs | 3 +- OpenRA.Mods.RA/Traits/Crates/CrateAction.cs | 2 +- .../Traits/Crates/GrantUpgradeCrateAction.cs | 2 +- OpenRA.Mods.RA/Traits/Harvester.cs | 2 +- .../Traits/Infiltration/InfiltrateForCash.cs | 4 +- .../Traits/SupportPowers/ChronoshiftPower.cs | 20 +-- .../Traits/SupportPowers/GpsPower.cs | 5 +- OpenRA.Mods.RA/Traits/TargetableSubmarine.cs | 6 +- .../Widgets/Logic/ConnectionLogic.cs | 2 +- OpenRA.Mods.RA/Widgets/Logic/CreditsLogic.cs | 2 +- .../Widgets/Logic/DownloadPackagesLogic.cs | 2 +- .../Widgets/Logic/GameTimerLogic.cs | 2 +- .../Widgets/Logic/IngameMenuLogic.cs | 2 +- OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs | 8 +- .../Widgets/Logic/LobbyMapPreviewLogic.cs | 8 +- OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs | 2 +- .../Widgets/Logic/MapChooserLogic.cs | 4 +- .../Widgets/Logic/ServerBrowserLogic.cs | 8 +- .../Widgets/Logic/WorldTooltipLogic.cs | 28 +-- .../Widgets/ProductionPaletteWidget.cs | 2 +- OpenRA.Mods.RA/Widgets/SupportPowersWidget.cs | 2 +- OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs | 2 +- OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs | 11 +- .../Traits/Render/WithVoxelBarrel.cs | 4 +- OpenRA.Mods.TS/Traits/Render/WithVoxelBody.cs | 4 +- .../Traits/Render/WithVoxelTurret.cs | 4 +- .../Traits/Render/WithVoxelWalkerBody.cs | 4 +- OpenRA.Renderer.Sdl2/ErrorHandler.cs | 8 +- OpenRA.Renderer.Sdl2/Sdl2Input.cs | 170 +++++++++--------- OpenRA.Test/OpenRA.Game/OrderTest.cs | 6 +- 153 files changed, 740 insertions(+), 698 deletions(-) diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 21ac38ba4f..ac09861284 100644 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -334,8 +334,9 @@ namespace OpenRA.Editor { var vX = (int)Math.Floor((mousePos.X - Offset.X) / Zoom); var vY = (int)Math.Floor((mousePos.Y - Offset.Y) / Zoom); - return new CPos((vX + TileSetRenderer.TileSize - 1) / TileSetRenderer.TileSize, - (vY + TileSetRenderer.TileSize - 1) / TileSetRenderer.TileSize); + return new CPos( + (vX + TileSetRenderer.TileSize - 1) / TileSetRenderer.TileSize, + (vY + TileSetRenderer.TileSize - 1) / TileSetRenderer.TileSize); } public void DrawActor(SGraphics g, CPos p, ActorTemplate t, ColorPalette cp) diff --git a/OpenRA.Game/Exts.cs b/OpenRA.Game/Exts.cs index 9d09320a1b..d385fad662 100644 --- a/OpenRA.Game/Exts.cs +++ b/OpenRA.Game/Exts.cs @@ -91,7 +91,7 @@ namespace OpenRA { return (k & mod) == mod; } - + public static V GetOrAdd(this Dictionary d, K k) where V : new() { diff --git a/OpenRA.Game/FieldLoader.cs b/OpenRA.Game/FieldLoader.cs index 66eef0972b..aadd24e491 100644 --- a/OpenRA.Game/FieldLoader.cs +++ b/OpenRA.Game/FieldLoader.cs @@ -156,7 +156,7 @@ namespace OpenRA else if (fieldType == typeof(decimal)) { decimal res; - if (decimal.TryParse(value.Replace("%", ""), NumberStyles.Float, NumberFormatInfo.InvariantInfo, out res)) + if (decimal.TryParse(value.Replace("%", ""), NumberStyles.Float, NumberFormatInfo.InvariantInfo, out res)) return res * (value.Contains('%') ? 0.01m : 1m); return InvalidValueAction(value, fieldType, fieldName); } @@ -291,7 +291,7 @@ namespace OpenRA if (Exts.TryParseIntegerInvariant(value, out rr) && Exts.TryParseIntegerInvariant(value, out rp) && Exts.TryParseIntegerInvariant(value, out ry)) - return new WRot(new WAngle(rr), new WAngle(rp), new WAngle(ry)); + return new WRot(new WAngle(rr), new WAngle(rp), new WAngle(ry)); } return InvalidValueAction(value, fieldType, fieldName); diff --git a/OpenRA.Game/FileFormats/BlowfishKeyProvider.cs b/OpenRA.Game/FileFormats/BlowfishKeyProvider.cs index e5c6fb16cf..50aaa1c4e4 100644 --- a/OpenRA.Game/FileFormats/BlowfishKeyProvider.cs +++ b/OpenRA.Game/FileFormats/BlowfishKeyProvider.cs @@ -390,7 +390,8 @@ namespace OpenRA.FileFormats MulBignumWord(esi, globOne, tmp, 2 * len); if ((*edi & 0x8000) == 0) { - if (0 != SubBigNum((uint*)esi, (uint*)esi, g1, 0, (int)len))(*edi)--; + if (0 != SubBigNum((uint*)esi, (uint*)esi, g1, 0, (int)len)) + (*edi)--; } } } diff --git a/OpenRA.Game/FileFormats/HvaReader.cs b/OpenRA.Game/FileFormats/HvaReader.cs index 4779bd8e99..938d6d96f2 100644 --- a/OpenRA.Game/FileFormats/HvaReader.cs +++ b/OpenRA.Game/FileFormats/HvaReader.cs @@ -33,17 +33,17 @@ namespace OpenRA.FileFormats Transforms = new float[16 * FrameCount * LimbCount]; for (var j = 0; j < FrameCount; j++) for (var i = 0; i < LimbCount; i++) - { - // Convert to column-major matrices and add the final matrix row - var c = 16 * (LimbCount * j + i); - Transforms[c + 3] = 0; - Transforms[c + 7] = 0; - Transforms[c + 11] = 0; - Transforms[c + 15] = 1; + { + // Convert to column-major matrices and add the final matrix row + var c = 16 * (LimbCount * j + i); + Transforms[c + 3] = 0; + Transforms[c + 7] = 0; + Transforms[c + 11] = 0; + Transforms[c + 15] = 1; - for (var k = 0; k < 12; k++) - Transforms[c + ids[k]] = s.ReadFloat(); - } + for (var k = 0; k < 12; k++) + Transforms[c + ids[k]] = s.ReadFloat(); + } } public static HvaReader Load(string filename) diff --git a/OpenRA.Game/FileFormats/IniFile.cs b/OpenRA.Game/FileFormats/IniFile.cs index 91b11cff63..f71eef1821 100644 --- a/OpenRA.Game/FileFormats/IniFile.cs +++ b/OpenRA.Game/FileFormats/IniFile.cs @@ -44,9 +44,9 @@ namespace OpenRA.FileFormats switch (line[0]) { - case ';': break; - case '[': currentSection = ProcessSection(line); break; - default: ProcessEntry(line, currentSection); break; + case ';': break; + case '[': currentSection = ProcessSection(line); break; + default: ProcessEntry(line, currentSection); break; } } } diff --git a/OpenRA.Game/FileFormats/VqaReader.cs b/OpenRA.Game/FileFormats/VqaReader.cs index f8ca8a77ff..94dae126d8 100644 --- a/OpenRA.Game/FileFormats/VqaReader.cs +++ b/OpenRA.Game/FileFormats/VqaReader.cs @@ -175,8 +175,8 @@ namespace OpenRA.FileFormats var jmp = int2.Swap(stream.ReadUInt32()); stream.Seek(jmp, SeekOrigin.Current); type = stream.ReadASCII(4); - } - + } + var length = int2.Swap(stream.ReadUInt32()); switch (type) @@ -197,10 +197,10 @@ namespace OpenRA.FileFormats } compressed = type == "SND2"; - break; + break; default: stream.ReadBytes((int)length); - break; + break; } // Chunks are aligned on even bytes; advance by a byte if the next one is null @@ -230,7 +230,7 @@ namespace OpenRA.FileFormats audioData = new byte[rightData.Length + leftData.Length]; var rightIndex = 0; - var leftIndex = 0; + var leftIndex = 0; for (var i = 0; i < audioData.Length;) { audioData[i++] = leftData[leftIndex++]; @@ -273,28 +273,28 @@ namespace OpenRA.FileFormats stream.Seek(length, SeekOrigin.Current); type = stream.ReadASCII(4); } - else + else throw new NotSupportedException(); - } - + } + length = int2.Swap(stream.ReadUInt32()); - + switch (type) { case "VQFR": DecodeVQFR(stream); - break; + break; case "\0VQF": stream.ReadByte(); DecodeVQFR(stream); - break; - case "VQFL": + break; + case "VQFL": DecodeVQFR(stream, "VQFL"); - break; + break; default: // Don't parse sound here. stream.ReadBytes((int)length); - break; + break; } // Chunks are aligned on even bytes; advance by a byte if the next one is null @@ -343,10 +343,10 @@ namespace OpenRA.FileFormats if (parentType == "VQFL") return; - break; + break; case "CBF0": cbf = s.ReadBytes(subchunkLength); - break; + break; // frame-modifier chunk case "CBP0": @@ -366,7 +366,7 @@ namespace OpenRA.FileFormats bytes.CopyTo(cbp, chunkBufferOffset); chunkBufferOffset += subchunkLength; currentChunkBuffer++; - break; + break; // Palette case "CPL0": @@ -378,7 +378,7 @@ namespace OpenRA.FileFormats palette[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b); } - break; + break; // Frame data case "VPTZ": @@ -390,9 +390,9 @@ namespace OpenRA.FileFormats Array.Clear(origData, 0, origData.Length); s.Read(fileBuffer, 0, subchunkLength); if (fileBuffer[0] != 0) - vtprSize = Format80.DecodeInto(fileBuffer, origData); + vtprSize = Format80.DecodeInto(fileBuffer, origData); else - Format80.DecodeInto(fileBuffer, origData, 1, true); + Format80.DecodeInto(fileBuffer, origData, 1, true); return; case "VPTR": Array.Clear(origData, 0, origData.Length); @@ -434,21 +434,21 @@ namespace OpenRA.FileFormats { case 0: x += para_A; - break; + break; case 1: WriteBlock(para_B1, para_B2, ref x, ref y); - break; + break; case 2: WriteBlock(para_B1, 1, ref x, ref y); - for (var i = 0; i < para_B2; i++) - WriteBlock(origData[p++], 1, ref x, ref y); - break; + for (var i = 0; i < para_B2; i++) + WriteBlock(origData[p++], 1, ref x, ref y); + break; case 3: WriteBlock(para_A, 1, ref x, ref y); - break; + break; case 5: WriteBlock(para_A, origData[p++], ref x, ref y); - break; + break; default: throw new NotSupportedException(); } diff --git a/OpenRA.Game/FileFormats/WavLoader.cs b/OpenRA.Game/FileFormats/WavLoader.cs index 36cfeb373a..3f17809a4a 100644 --- a/OpenRA.Game/FileFormats/WavLoader.cs +++ b/OpenRA.Game/FileFormats/WavLoader.cs @@ -32,7 +32,7 @@ namespace OpenRA.FileFormats public enum WaveType { Pcm = 0x1, ImaAdpcm = 0x11 } public static WaveType Type { get; private set; } - + public WavLoader(Stream s) { while (s.Position < s.Length) @@ -92,7 +92,7 @@ namespace OpenRA.FileFormats BitsPerSample = 16; } } - + public static float WaveLength(Stream s) { s.Position = 12; diff --git a/OpenRA.Game/FileSystem/Folder.cs b/OpenRA.Game/FileSystem/Folder.cs index d6f5337fe1..92a9c1cf84 100644 --- a/OpenRA.Game/FileSystem/Folder.cs +++ b/OpenRA.Game/FileSystem/Folder.cs @@ -75,8 +75,8 @@ namespace OpenRA.FileSystem foreach (var file in contents) using (var dataStream = File.Create(Path.Combine(path, file.Key))) - using (var writer = new BinaryWriter(dataStream)) - writer.Write(file.Value); + using (var writer = new BinaryWriter(dataStream)) + writer.Write(file.Value); } } } diff --git a/OpenRA.Game/FileSystem/MixFile.cs b/OpenRA.Game/FileSystem/MixFile.cs index 1872ee3297..cf6dd8805d 100644 --- a/OpenRA.Game/FileSystem/MixFile.cs +++ b/OpenRA.Game/FileSystem/MixFile.cs @@ -218,7 +218,7 @@ namespace OpenRA.FileSystem public int Priority { get { return 1000 + priority; } } public string Name { get { return filename; } } - + public void Write(Dictionary contents) { // Cannot modify existing mixfile - rename existing file and diff --git a/OpenRA.Game/FileSystem/PackageEntry.cs b/OpenRA.Game/FileSystem/PackageEntry.cs index 6667f26e69..a731be5f02 100644 --- a/OpenRA.Game/FileSystem/PackageEntry.cs +++ b/OpenRA.Game/FileSystem/PackageEntry.cs @@ -59,41 +59,41 @@ namespace OpenRA.FileSystem { switch (type) { - case PackageHashType.Classic: - { - name = name.ToUpperInvariant(); - if (name.Length % 4 != 0) - name = name.PadRight(name.Length + (4 - name.Length % 4), '\0'); - - var ms = new MemoryStream(Encoding.ASCII.GetBytes(name)); - var reader = new BinaryReader(ms); - - var len = name.Length >> 2; - uint result = 0; - - while (len-- != 0) - result = ((result << 1) | (result >> 31)) + reader.ReadUInt32(); - - return result; - } - - case PackageHashType.CRC32: - { - name = name.ToUpperInvariant(); - var l = name.Length; - var a = l >> 2; - if ((l & 3) != 0) + case PackageHashType.Classic: { - name += (char)(l - (a << 2)); - var i = 3 - (l & 3); - while (i-- != 0) - name += name[a << 2]; + name = name.ToUpperInvariant(); + if (name.Length % 4 != 0) + name = name.PadRight(name.Length + (4 - name.Length % 4), '\0'); + + var ms = new MemoryStream(Encoding.ASCII.GetBytes(name)); + var reader = new BinaryReader(ms); + + var len = name.Length >> 2; + uint result = 0; + + while (len-- != 0) + result = ((result << 1) | (result >> 31)) + reader.ReadUInt32(); + + return result; } - return CRC32.Calculate(Encoding.ASCII.GetBytes(name)); - } + case PackageHashType.CRC32: + { + name = name.ToUpperInvariant(); + var l = name.Length; + var a = l >> 2; + if ((l & 3) != 0) + { + name += (char)(l - (a << 2)); + var i = 3 - (l & 3); + while (i-- != 0) + name += name[a << 2]; + } - default: throw new NotImplementedException("Unknown hash type `{0}`".F(type)); + return CRC32.Calculate(Encoding.ASCII.GetBytes(name)); + } + + default: throw new NotImplementedException("Unknown hash type `{0}`".F(type)); } } diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 0315daef3c..9bfe460c26 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -153,7 +153,7 @@ namespace OpenRA if (worldRenderer != null) worldRenderer.Dispose(); worldRenderer = new WorldRenderer(OrderManager.World); - + using (new PerfTimer("LoadComplete")) OrderManager.World.LoadComplete(worldRenderer); diff --git a/OpenRA.Game/GameRules/ActorInfo.cs b/OpenRA.Game/GameRules/ActorInfo.cs index 593c279031..63f4a6497a 100644 --- a/OpenRA.Game/GameRules/ActorInfo.cs +++ b/OpenRA.Game/GameRules/ActorInfo.cs @@ -92,7 +92,8 @@ namespace OpenRA if (constructOrderCache != null) return constructOrderCache; - var source = Traits.WithInterface().Select(i => new { + var source = Traits.WithInterface().Select(i => new + { Trait = i, Type = i.GetType(), Dependencies = PrerequisitesOf(i).ToList() diff --git a/OpenRA.Game/GameRules/Warhead.cs b/OpenRA.Game/GameRules/Warhead.cs index 84a0ed9c34..c01bf53f1d 100644 --- a/OpenRA.Game/GameRules/Warhead.cs +++ b/OpenRA.Game/GameRules/Warhead.cs @@ -23,10 +23,10 @@ namespace OpenRA.GameRules [Desc("What types of targets are unaffected.", "Overrules ValidTargets.")] public readonly string[] InvalidTargets = { }; - + [Desc("What diplomatic stances are affected.")] public readonly Stance ValidStances = Stance.Ally | Stance.Neutral | Stance.Enemy; - + [Desc("Can this warhead affect the actor that fired it.")] public readonly bool AffectsParent = false; diff --git a/OpenRA.Game/Graphics/IGraphicsDevice.cs b/OpenRA.Game/Graphics/IGraphicsDevice.cs index 41ef525c1d..bbf2425384 100755 --- a/OpenRA.Game/Graphics/IGraphicsDevice.cs +++ b/OpenRA.Game/Graphics/IGraphicsDevice.cs @@ -85,7 +85,7 @@ namespace OpenRA } public enum TextureScaleFilter { Nearest, Linear } - + public interface ITexture : IDisposable { void SetData(Bitmap bitmap); diff --git a/OpenRA.Game/Graphics/SelectionBarsRenderable.cs b/OpenRA.Game/Graphics/SelectionBarsRenderable.cs index b7aab12f19..b14ae2f8fc 100644 --- a/OpenRA.Game/Graphics/SelectionBarsRenderable.cs +++ b/OpenRA.Game/Graphics/SelectionBarsRenderable.cs @@ -83,7 +83,7 @@ namespace OpenRA.Graphics var isAlly = actor.Owner.IsAlliedWith(actor.World.LocalPlayer) || (actor.EffectiveOwner != null && actor.EffectiveOwner.Disguised && actor.World.LocalPlayer.IsAlliedWith(actor.EffectiveOwner.Owner)); - return isAlly ? Color.LimeGreen : actor.Owner.NonCombatant ? Color.Tan : Color.Red; + return isAlly ? Color.LimeGreen : actor.Owner.NonCombatant ? Color.Tan : Color.Red; } else return health.DamageState == DamageState.Critical ? Color.Red : diff --git a/OpenRA.Game/Graphics/Util.cs b/OpenRA.Game/Graphics/Util.cs index 977837c4f5..b734c3fef4 100644 --- a/OpenRA.Game/Graphics/Util.cs +++ b/OpenRA.Game/Graphics/Util.cs @@ -106,12 +106,12 @@ namespace OpenRA.Graphics { var mtx = new float[16]; for (var i = 0; i < 4; i++) - for (var j = 0; j < 4; j++) - { - mtx[4 * i + j] = 0; - for (var k = 0; k < 4; k++) - mtx[4 * i + j] += lhs[4 * k + j] * rhs[4 * i + k]; - } + for (var j = 0; j < 4; j++) + { + mtx[4 * i + j] = 0; + for (var k = 0; k < 4; k++) + mtx[4 * i + j] += lhs[4 * k + j] * rhs[4 * i + k]; + } return mtx; } @@ -250,7 +250,7 @@ namespace OpenRA.Graphics return null; for (var i = 0; i < 16; i++) - mtx[i] *= 1 / det; + mtx[i] *= 1 / det; return mtx; } diff --git a/OpenRA.Game/Graphics/VoxelRenderer.cs b/OpenRA.Game/Graphics/VoxelRenderer.cs index c1585c04eb..3f7b5879b2 100644 --- a/OpenRA.Game/Graphics/VoxelRenderer.cs +++ b/OpenRA.Game/Graphics/VoxelRenderer.cs @@ -77,9 +77,10 @@ namespace OpenRA.Graphics shader.SetMatrix("View", view); } - public VoxelRenderProxy RenderAsync(WorldRenderer wr, IEnumerable voxels, WRot camera, float scale, - float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, - PaletteReference color, PaletteReference normals, PaletteReference shadowPalette) + public VoxelRenderProxy RenderAsync( + WorldRenderer wr, IEnumerable voxels, WRot camera, float scale, + float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, + PaletteReference color, PaletteReference normals, PaletteReference shadowPalette) { // Correct for inverted y-axis var scaleTransform = Util.ScaleMatrix(scale, scale, scale); @@ -202,7 +203,7 @@ namespace OpenRA.Graphics var lightDirection = ExtractRotationVector(Util.MatrixMultiply(Util.MatrixInverse(t), lightTransform)); Render(rd, Util.MatrixMultiply(transform, t), lightDirection, - lightAmbientColor, lightDiffuseColor, color.Index, normals.Index); + lightAmbientColor, lightDiffuseColor, color.Index, normals.Index); // Disable shadow normals by forcing zero diffuse and identity ambient light Render(rd, Util.MatrixMultiply(shadow, t), lightDirection, @@ -249,14 +250,16 @@ namespace OpenRA.Graphics return tVec; } - void Render(VoxelRenderData renderData, - float[] t, float[] lightDirection, - float[] ambientLight, float[] diffuseLight, - int colorPalette, int normalsPalette) + void Render( + VoxelRenderData renderData, + float[] t, float[] lightDirection, + float[] ambientLight, float[] diffuseLight, + int colorPalette, int normalsPalette) { shader.SetTexture("DiffuseTexture", renderData.Sheet.GetTexture()); - shader.SetVec("PaletteRows", (colorPalette + 0.5f) / HardwarePalette.MaxPalettes, - (normalsPalette + 0.5f) / HardwarePalette.MaxPalettes); + shader.SetVec("PaletteRows", + (colorPalette + 0.5f) / HardwarePalette.MaxPalettes, + (normalsPalette + 0.5f) / HardwarePalette.MaxPalettes); shader.SetMatrix("TransformMatrix", t); shader.SetVec("LightDirection", lightDirection, 4); shader.SetVec("AmbientLight", ambientLight, 3); diff --git a/OpenRA.Game/MiniYaml.cs b/OpenRA.Game/MiniYaml.cs index dc660fc2eb..639d963baa 100755 --- a/OpenRA.Game/MiniYaml.cs +++ b/OpenRA.Game/MiniYaml.cs @@ -270,8 +270,7 @@ namespace OpenRA } } - if (throwErrors) - if (noInherit.ContainsValue(false)) + if (throwErrors && noInherit.ContainsValue(false)) throw new YamlException("Bogus yaml removals: {0}".F( noInherit.Where(x => !x.Value).JoinWith(", "))); diff --git a/OpenRA.Game/Network/Handshake.cs b/OpenRA.Game/Network/Handshake.cs index a4f153074d..111e502eee 100644 --- a/OpenRA.Game/Network/Handshake.cs +++ b/OpenRA.Game/Network/Handshake.cs @@ -53,10 +53,10 @@ namespace OpenRA.Network { case "Handshake": FieldLoader.Load(handshake, y.Value); - break; + break; case "Client": FieldLoader.Load(handshake.Client, y.Value); - break; + break; } } diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 359e59e486..2fa68f2500 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -52,7 +52,7 @@ namespace OpenRA.Network } case "Message": // Server message - Game.AddChatLine(Color.White, "Server", order.TargetString); + Game.AddChatLine(Color.White, "Server", order.TargetString); break; case "Disconnected": /* reports that the target player disconnected */ diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index 2c3bad09a7..019cb864ab 100755 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -107,7 +107,7 @@ namespace OpenRA var it = typeof(T); return GetTypes().Where(t => t != it && it.IsAssignableFrom(t)); } - + public IEnumerable GetTypes() { return assemblies.Select(ma => ma.First).Distinct() diff --git a/OpenRA.Game/Platform.cs b/OpenRA.Game/Platform.cs index 7b8e5b16c8..06741d2e1f 100644 --- a/OpenRA.Game/Platform.cs +++ b/OpenRA.Game/Platform.cs @@ -26,24 +26,24 @@ namespace OpenRA static PlatformType GetCurrentPlatform() { - if (Environment.OSVersion.Platform == PlatformID.Win32NT) - return PlatformType.Windows; + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + return PlatformType.Windows; - try - { - var psi = new ProcessStartInfo("uname", "-s"); - psi.UseShellExecute = false; - psi.RedirectStandardOutput = true; - var p = Process.Start(psi); - var kernelName = p.StandardOutput.ReadToEnd(); - if (kernelName.Contains("Linux") || kernelName.Contains("BSD")) - return PlatformType.Linux; - if (kernelName.Contains("Darwin")) - return PlatformType.OSX; - } - catch { } + try + { + var psi = new ProcessStartInfo("uname", "-s"); + psi.UseShellExecute = false; + psi.RedirectStandardOutput = true; + var p = Process.Start(psi); + var kernelName = p.StandardOutput.ReadToEnd(); + if (kernelName.Contains("Linux") || kernelName.Contains("BSD")) + return PlatformType.Linux; + if (kernelName.Contains("Darwin")) + return PlatformType.OSX; + } + catch { } - return PlatformType.Unknown; + return PlatformType.Unknown; } public static string RuntimeVersion @@ -58,7 +58,7 @@ namespace OpenRA if (version == null) return "Mono (unknown version) CLR {0}".F(Environment.Version); - return "Mono {0} CLR {1}".F(version.Invoke(null, null), Environment.Version); + return "Mono {0} CLR {1}".F(version.Invoke(null, null), Environment.Version); } } @@ -75,16 +75,16 @@ namespace OpenRA switch (CurrentPlatform) { - case PlatformType.Windows: - dir += Path.DirectorySeparatorChar + "OpenRA"; - break; - case PlatformType.OSX: - dir += "/Library/Application Support/OpenRA"; - break; - case PlatformType.Linux: - default: - dir += "/.openra"; - break; + case PlatformType.Windows: + dir += Path.DirectorySeparatorChar + "OpenRA"; + break; + case PlatformType.OSX: + dir += "/Library/Application Support/OpenRA"; + break; + case PlatformType.Linux: + default: + dir += "/.openra"; + break; } if (!Directory.Exists(dir)) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 4d64b40dbb..a57259f803 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -347,7 +347,7 @@ namespace OpenRA.Server LobbyInfo.ClientPings.Add(clientPing); Log.Write("server", "Client {0}: Accepted connection from {1}.", - newConn.PlayerIndex, newConn.Socket.RemoteEndPoint); + newConn.PlayerIndex, newConn.Socket.RemoteEndPoint); foreach (var t in serverTraits.WithInterface()) t.ClientJoined(this, newConn); @@ -451,20 +451,20 @@ namespace OpenRA.Server switch (so.Name) { case "Command": - { - var handled = false; - foreach (var t in serverTraits.WithInterface()) - if (handled = t.InterpretCommand(this, conn, GetClient(conn), so.Data)) - break; - - if (!handled) { - Log.Write("server", "Unknown server command: {0}", so.Data); - SendOrderTo(conn, "Message", "Unknown server command: {0}".F(so.Data)); - } + var handled = false; + foreach (var t in serverTraits.WithInterface()) + if (handled = t.InterpretCommand(this, conn, GetClient(conn), so.Data)) + break; - break; - } + if (!handled) + { + Log.Write("server", "Unknown server command: {0}", so.Data); + SendOrderTo(conn, "Message", "Unknown server command: {0}".F(so.Data)); + } + + break; + } case "HandshakeResponse": ValidateClient(conn, so.Data); @@ -475,33 +475,33 @@ namespace OpenRA.Server DispatchOrdersToClients(conn, 0, so.Serialize()); break; case "Pong": - { - int pingSent; - if (!OpenRA.Exts.TryParseIntegerInvariant(so.Data, out pingSent)) { - Log.Write("server", "Invalid order pong payload: {0}", so.Data); + int pingSent; + if (!OpenRA.Exts.TryParseIntegerInvariant(so.Data, out pingSent)) + { + Log.Write("server", "Invalid order pong payload: {0}", so.Data); + break; + } + + var pingFromClient = LobbyInfo.PingFromClient(GetClient(conn)); + if (pingFromClient == null) + return; + + var history = pingFromClient.LatencyHistory.ToList(); + history.Add(Game.RunTime - pingSent); + + // Cap ping history at 5 values (25 seconds) + if (history.Count > 5) + history.RemoveRange(0, history.Count - 5); + + pingFromClient.Latency = history.Sum() / history.Count; + pingFromClient.LatencyJitter = (history.Max() - history.Min()) / 2; + pingFromClient.LatencyHistory = history.ToArray(); + + SyncClientPing(); + break; } - - var pingFromClient = LobbyInfo.PingFromClient(GetClient(conn)); - if (pingFromClient == null) - return; - - var history = pingFromClient.LatencyHistory.ToList(); - history.Add(Game.RunTime - pingSent); - - // Cap ping history at 5 values (25 seconds) - if (history.Count > 5) - history.RemoveRange(0, history.Count - 5); - - pingFromClient.Latency = history.Sum() / history.Count; - pingFromClient.LatencyJitter = (history.Max() - history.Min()) / 2; - pingFromClient.LatencyHistory = history.ToArray(); - - SyncClientPing(); - - break; - } } } diff --git a/OpenRA.Game/Sound/Sound.cs b/OpenRA.Game/Sound/Sound.cs index 2cdc423ea0..a128fd5183 100644 --- a/OpenRA.Game/Sound/Sound.cs +++ b/OpenRA.Game/Sound/Sound.cs @@ -61,11 +61,11 @@ namespace OpenRA engine = Game.Settings.Server.Dedicated ? "Null" : engine; switch (engine) { - case "AL": return new OpenAlSoundEngine(); - case "Null": return new NullSoundEngine(); + case "AL": return new OpenAlSoundEngine(); + case "Null": return new NullSoundEngine(); - default: - throw new InvalidOperationException("Unsupported sound engine: {0}".F(engine)); + default: + throw new InvalidOperationException("Unsupported sound engine: {0}".F(engine)); } } @@ -373,7 +373,7 @@ namespace OpenRA var type = mi.Voice.ToLowerInvariant(); return PlayPredefined(voicedUnit.World.Map.Rules, null, voicedUnit, type, phrase, variant, true, WPos.Zero, 1f, true); } - + public static bool PlayVoiceLocal(string phrase, Actor voicedUnit, string variant, WPos pos, float volume) { if (voicedUnit == null || phrase == null) diff --git a/OpenRA.Game/Support/Log.cs b/OpenRA.Game/Support/Log.cs index 8a84dba0d1..1ea2334ffc 100755 --- a/OpenRA.Game/Support/Log.cs +++ b/OpenRA.Game/Support/Log.cs @@ -28,9 +28,9 @@ namespace OpenRA { var path = Platform.SupportDir + "Logs"; Directory.CreateDirectory(path); - + for (var i = 0;; i++) - yield return Path.Combine(path, i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename); + yield return Path.Combine(path, i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename); } public static void AddChannel(string channelName, string baseFilename) diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index ecb3ab5f93..d368c97334 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -92,7 +92,7 @@ namespace OpenRA.Traits }; foreach (var nd in self.TraitsImplementing() - .Concat(self.Owner.PlayerActor.TraitsImplementing())) + .Concat(self.Owner.PlayerActor.TraitsImplementing())) nd.Damaged(self, ai); foreach (var nd in self.TraitsImplementing()) @@ -100,7 +100,7 @@ namespace OpenRA.Traits if (Info.NotifyAppliedDamage && repairer != null && repairer.IsInWorld && !repairer.IsDead) foreach (var nd in repairer.TraitsImplementing() - .Concat(repairer.Owner.PlayerActor.TraitsImplementing())) + .Concat(repairer.Owner.PlayerActor.TraitsImplementing())) nd.AppliedDamage(repairer, self, ai); } @@ -144,7 +144,7 @@ namespace OpenRA.Traits if (Info.NotifyAppliedDamage && attacker != null && attacker.IsInWorld && !attacker.IsDead) foreach (var nd in attacker.TraitsImplementing() .Concat(attacker.Owner.PlayerActor.TraitsImplementing())) - nd.AppliedDamage(attacker, self, ai); + nd.AppliedDamage(attacker, self, ai); if (hp == 0) { diff --git a/OpenRA.Game/Traits/Target.cs b/OpenRA.Game/Traits/Target.cs index 821b1cadcb..11093e23cf 100644 --- a/OpenRA.Game/Traits/Target.cs +++ b/OpenRA.Game/Traits/Target.cs @@ -101,15 +101,15 @@ namespace OpenRA.Traits { switch (Type) { - case TargetType.Actor: - return actor.CenterPosition; - case TargetType.FrozenActor: - return frozen.CenterPosition; - case TargetType.Terrain: - return pos; - default: - case TargetType.Invalid: - throw new InvalidOperationException("Attempting to query the position of an invalid Target"); + case TargetType.Actor: + return actor.CenterPosition; + case TargetType.FrozenActor: + return frozen.CenterPosition; + case TargetType.Terrain: + return pos; + default: + case TargetType.Invalid: + throw new InvalidOperationException("Attempting to query the position of an invalid Target"); } } } @@ -122,20 +122,20 @@ namespace OpenRA.Traits { switch (Type) { - case TargetType.Actor: - var targetable = actor.TraitOrDefault(); - if (targetable == null) - return new[] { actor.CenterPosition }; + case TargetType.Actor: + var targetable = actor.TraitOrDefault(); + if (targetable == null) + return new[] { actor.CenterPosition }; - var positions = targetable.TargetablePositions(actor); - return positions.Any() ? positions : new[] { actor.CenterPosition }; - case TargetType.FrozenActor: - return new[] { frozen.CenterPosition }; - case TargetType.Terrain: - return new[] { pos }; - default: - case TargetType.Invalid: - return NoPositions; + var positions = targetable.TargetablePositions(actor); + return positions.Any() ? positions : new[] { actor.CenterPosition }; + case TargetType.FrozenActor: + return new[] { frozen.CenterPosition }; + case TargetType.Terrain: + return new[] { pos }; + default: + case TargetType.Invalid: + return NoPositions; } } } diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 7fbf5e11b0..fdfbcc0f9d 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -24,7 +24,7 @@ namespace OpenRA.Traits // depends on the order of pips in WorldRenderer.cs! public enum PipType { Transparent, Green, Yellow, Red, Gray, Blue, Ammo, AmmoEmpty } public enum TagType { None, Fake, Primary } - + [Flags] public enum Stance { @@ -259,7 +259,7 @@ namespace OpenRA.Traits } public interface IRenderOverlay { void Render(WorldRenderer wr); } - public interface INotifyBecomingIdle { void OnBecomingIdle(Actor self); } + public interface INotifyBecomingIdle { void OnBecomingIdle(Actor self); } public interface INotifyIdle { void TickIdle(Actor self); } public interface IBlocksBullets { } diff --git a/OpenRA.Game/WRange.cs b/OpenRA.Game/WRange.cs index 8259b7e43c..cb7fce4f98 100644 --- a/OpenRA.Game/WRange.cs +++ b/OpenRA.Game/WRange.cs @@ -63,16 +63,16 @@ namespace OpenRA switch (components.Length) { - case 2: - if (!Exts.TryParseIntegerInvariant(components[0], out cell) || - !Exts.TryParseIntegerInvariant(components[1], out subcell)) + case 2: + if (!Exts.TryParseIntegerInvariant(components[0], out cell) || + !Exts.TryParseIntegerInvariant(components[1], out subcell)) return false; - break; - case 1: - if (!Exts.TryParseIntegerInvariant(components[0], out subcell)) - return false; - break; - default: return false; + break; + case 1: + if (!Exts.TryParseIntegerInvariant(components[0], out subcell)) + return false; + break; + default: return false; } // Propagate sign to fractional part diff --git a/OpenRA.Game/WRot.cs b/OpenRA.Game/WRot.cs index b9d5fee88a..891df556c0 100644 --- a/OpenRA.Game/WRot.cs +++ b/OpenRA.Game/WRot.cs @@ -28,8 +28,10 @@ namespace OpenRA public static WRot operator -(WRot a, WRot b) { return new WRot(a.Roll - b.Roll, a.Pitch - b.Pitch, a.Yaw - b.Yaw); } public static WRot operator -(WRot a) { return new WRot(-a.Roll, -a.Pitch, -a.Yaw); } - public static bool operator ==(WRot me, WRot other) { return me.Roll == other.Roll && - me.Pitch == other.Pitch && me.Yaw == other.Yaw; } + public static bool operator ==(WRot me, WRot other) + { + return me.Roll == other.Roll && me.Pitch == other.Pitch && me.Yaw == other.Yaw; + } public static bool operator !=(WRot me, WRot other) { return !(me == other); } diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index c84ad9a90a..f6ac257e39 100644 --- a/OpenRA.Game/Widgets/ButtonWidget.cs +++ b/OpenRA.Game/Widgets/ButtonWidget.cs @@ -52,7 +52,7 @@ namespace OpenRA.Widgets // Equivalent to OnMouseUp, but without an input arg public Action OnClick = () => { }; - public Action OnDoubleClick = () => { }; + public Action OnDoubleClick = () => { }; public Action OnKeyPress = _ => { }; protected readonly Ruleset ModRules; @@ -149,7 +149,7 @@ namespace OpenRA.Widgets OnDoubleClick(); return YieldMouseFocus(mi); } - } + } else if (HasMouseFocus && mi.Event == MouseInputEvent.Up) { // Only fire the onMouseUp event if we successfully lost focus, and were pressed @@ -197,8 +197,14 @@ namespace OpenRA.Widgets tooltipContainer.Value.RemoveTooltip(); } - public override int2 ChildOrigin { get { return RenderOrigin + - (Depressed ? new int2(VisualHeight, VisualHeight) : new int2(0, 0)); } } + public override int2 ChildOrigin + { + get + { + return RenderOrigin + + (Depressed ? new int2(VisualHeight, VisualHeight) : new int2(0, 0)); + } + } public override void Draw() { diff --git a/OpenRA.Game/Widgets/DropDownButtonWidget.cs b/OpenRA.Game/Widgets/DropDownButtonWidget.cs index 7371ef9652..9b85d10464 100644 --- a/OpenRA.Game/Widgets/DropDownButtonWidget.cs +++ b/OpenRA.Game/Widgets/DropDownButtonWidget.cs @@ -101,8 +101,7 @@ namespace OpenRA.Widgets public void ShowDropDown(string panelTemplate, int maxHeight, IEnumerable options, Func setupItem) { var substitutions = new Dictionary() { { "DROPDOWN_WIDTH", Bounds.Width } }; - var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs() - { { "substitutions", substitutions } }); + var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs() { { "substitutions", substitutions } }); var itemTemplate = panel.Get("TEMPLATE"); panel.RemoveChildren(); @@ -124,8 +123,7 @@ namespace OpenRA.Widgets public void ShowDropDown(string panelTemplate, int height, Dictionary> groups, Func setupItem) { var substitutions = new Dictionary() { { "DROPDOWN_WIDTH", Bounds.Width } }; - var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs() - { { "substitutions", substitutions } }); + var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs() { { "substitutions", substitutions } }); var headerTemplate = panel.GetOrNull("HEADER"); var itemTemplate = panel.Get("TEMPLATE"); diff --git a/OpenRA.Game/Widgets/SliderWidget.cs b/OpenRA.Game/Widgets/SliderWidget.cs index 1720ea1524..6b72a3cb99 100644 --- a/OpenRA.Game/Widgets/SliderWidget.cs +++ b/OpenRA.Game/Widgets/SliderWidget.cs @@ -61,22 +61,22 @@ namespace OpenRA.Widgets switch (mi.Event) { - case MouseInputEvent.Up: - isMoving = false; - YieldMouseFocus(mi); - break; + case MouseInputEvent.Up: + isMoving = false; + YieldMouseFocus(mi); + break; - case MouseInputEvent.Down: - isMoving = true; - /* TODO: handle snapping to ticks properly again */ - /* TODO: handle nudge via clicking outside the thumb */ - UpdateValue(ValueFromPx(mi.Location.X - RenderBounds.Left)); - break; - - case MouseInputEvent.Move: - if (isMoving) + case MouseInputEvent.Down: + isMoving = true; + /* TODO: handle snapping to ticks properly again */ + /* TODO: handle nudge via clicking outside the thumb */ UpdateValue(ValueFromPx(mi.Location.X - RenderBounds.Left)); - break; + break; + + case MouseInputEvent.Move: + if (isMoving) + UpdateValue(ValueFromPx(mi.Location.X - RenderBounds.Left)); + break; } return ThumbRect.Contains(mi.Location); diff --git a/OpenRA.Game/Widgets/TextFieldWidget.cs b/OpenRA.Game/Widgets/TextFieldWidget.cs index 810454af5c..09395615b0 100644 --- a/OpenRA.Game/Widgets/TextFieldWidget.cs +++ b/OpenRA.Game/Widgets/TextFieldWidget.cs @@ -268,9 +268,10 @@ namespace OpenRA.Widgets Bounds.Width - LeftMargin - RightMargin, Bounds.Bottom)); } - var color = disabled ? TextColorDisabled - : IsValid() ? TextColor - : TextColorInvalid; + var color = + disabled ? TextColorDisabled + : IsValid() ? TextColor + : TextColorInvalid; font.DrawText(apparentText, textPos, color); if (showCursor && HasKeyboardFocus) diff --git a/OpenRA.Game/Widgets/VqaPlayerWidget.cs b/OpenRA.Game/Widgets/VqaPlayerWidget.cs index f5e1d654b4..c014164d14 100644 --- a/OpenRA.Game/Widgets/VqaPlayerWidget.cs +++ b/OpenRA.Game/Widgets/VqaPlayerWidget.cs @@ -71,7 +71,7 @@ namespace OpenRA.Widgets 0, 0, video.Width, - video.Height), + video.Height), TextureChannel.Alpha); var scale = Math.Min((float)RenderBounds.Width / video.Width, (float)RenderBounds.Height / video.Height * AspectRatio); @@ -121,15 +121,15 @@ namespace OpenRA.Widgets skippedFrames++; } - if (skippedFrames > 1) - Log.Write("perf", "VqaPlayer : {0} skipped {1} frames at position {2}", cachedVideo, skippedFrames, video.CurrentFrame); + if (skippedFrames > 1) + Log.Write("perf", "VqaPlayer : {0} skipped {1} frames at position {2}", cachedVideo, skippedFrames, video.CurrentFrame); } Game.Renderer.RgbaSpriteRenderer.DrawSprite( videoSprite, videoOrigin, videoSize); - + if (DrawOverlay) Game.Renderer.RgbaSpriteRenderer.DrawSprite(overlaySprite, videoOrigin, videoSize); } diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 75bfb606b8..6d35728c23 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -485,7 +485,7 @@ namespace OpenRA.Widgets public override string GetCursor(int2 pos) { return null; } public override Widget Clone() { return new ContainerWidget(this); } public Func OnKeyPress = _ => false; - public override bool HandleKeyPress(KeyInput e) { return OnKeyPress(e); } + public override bool HandleKeyPress(KeyInput e) { return OnKeyPress(e); } } public class WidgetArgs : Dictionary diff --git a/OpenRA.Game/Widgets/WidgetLoader.cs b/OpenRA.Game/Widgets/WidgetLoader.cs index 8254a20694..d8a2ab6472 100644 --- a/OpenRA.Game/Widgets/WidgetLoader.cs +++ b/OpenRA.Game/Widgets/WidgetLoader.cs @@ -47,7 +47,7 @@ namespace OpenRA { if (!args.ContainsKey("modRules")) args = new WidgetArgs(args) { { "modRules", modData.DefaultRules } }; - + var widget = NewWidget(node.Key, args); if (parent != null) diff --git a/OpenRA.Game/Widgets/WidgetUtils.cs b/OpenRA.Game/Widgets/WidgetUtils.cs index 6ed711cd4f..547a36b880 100644 --- a/OpenRA.Game/Widgets/WidgetUtils.cs +++ b/OpenRA.Game/Widgets/WidgetUtils.cs @@ -105,7 +105,7 @@ namespace OpenRA.Widgets // Background if (ps.HasFlags(PanelSides.Center) && ss[8] != null) FillRectWithSprite(new Rectangle(bounds.Left + marginLeft, bounds.Top + marginTop, - bounds.Width - marginWidth, bounds.Height - marginHeight), + bounds.Width - marginWidth, bounds.Height - marginHeight), ss[8]); // Left border diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index 12eace5005..cb205cfb42 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -81,7 +81,7 @@ namespace OpenRA.Widgets var unit = World.ScreenMap.ActorsAt(xy) .WithHighestSelectionPriority(); - var newSelection2 = SelectActorsInBox(World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight, + var newSelection2 = SelectActorsInBox(World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight, a => unit != null && a.Info.Name == unit.Info.Name && a.Owner == unit.Owner); World.Selection.Combine(World, newSelection2, true, false); @@ -98,7 +98,7 @@ namespace OpenRA.Widgets } // don't issue orders while selecting - if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down && !hasBox) + if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down && !hasBox) ApplyOrders(World, xy, mi); lastMousePosition = xy; diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 73f9b07f77..20f1b0c448 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -66,7 +66,7 @@ namespace OpenRA public bool ShroudObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(a); } public bool ShroudObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(p); } public bool ShroudObscures(int u, int v) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(u, v); } - + public Func FogObscuresTest(CellRegion region) { var rp = RenderPlayer; diff --git a/OpenRA.GameMonitor/GameMonitor.cs b/OpenRA.GameMonitor/GameMonitor.cs index a1f308dad4..ebe3d3809c 100644 --- a/OpenRA.GameMonitor/GameMonitor.cs +++ b/OpenRA.GameMonitor/GameMonitor.cs @@ -22,7 +22,7 @@ namespace OpenRA { static string processName = "OpenRA.Game.exe"; static Process gameProcess; - + [STAThread] static void Main(string[] args) { @@ -67,14 +67,14 @@ namespace OpenRA Text = "OpenRA has encountered a fatal error and must close.{0}Refer to the crash logs and FAQ for more information.".F(Environment.NewLine), TextAlign = ContentAlignment.TopCenter }; - + var viewLogs = new Button { Location = new Point(10, 80), Size = new Size(75, 23), Text = "View Logs" }; - + var viewFaq = new Button { Location = new Point(90, 80), @@ -89,7 +89,7 @@ namespace OpenRA Text = "Quit", DialogResult = DialogResult.Cancel }; - + form.Controls.Add(notice); form.Controls.Add(viewLogs); form.Controls.Add(viewFaq); diff --git a/OpenRA.Mods.Cnc/Activities/HarvesterDockSequence.cs b/OpenRA.Mods.Cnc/Activities/HarvesterDockSequence.cs index f9bfebc9cb..72a3dd51d4 100644 --- a/OpenRA.Mods.Cnc/Activities/HarvesterDockSequence.cs +++ b/OpenRA.Mods.Cnc/Activities/HarvesterDockSequence.cs @@ -53,7 +53,8 @@ namespace OpenRA.Mods.Cnc.Activities state = State.Dock; return Util.SequenceActivities(new Drag(self, startDock, endDock, 12), this); case State.Dock: - ru.PlayCustomAnimation(self, "dock", () => { + ru.PlayCustomAnimation(self, "dock", () => + { ru.PlayCustomAnimRepeating(self, "dock-loop"); if (proc.IsInWorld && !proc.IsDead) foreach (var nd in proc.TraitsImplementing()) diff --git a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs index edbcdab667..830bd37dba 100644 --- a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs +++ b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs @@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Activities if (dest == null) { var nearestAfld = ChooseAirfield(self, false); - + self.CancelActivity(); if (nearestAfld != null) return Util.SequenceActivities(new Fly(self, Target.FromActor(nearestAfld)), new FlyCircle()); diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index 341fd06d40..d29882cb12 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Activities var type = Target.Type; if (!Target.IsValidFor(self) || type == TargetType.FrozenActor) return NextActivity; - + if (attack.Info.AttackRequiresEnteringCell && !positionable.CanEnterCell(Target.Actor.Location, null, false)) return NextActivity; diff --git a/OpenRA.Mods.Common/Activities/Enter.cs b/OpenRA.Mods.Common/Activities/Enter.cs index 30187da88a..94e352d634 100644 --- a/OpenRA.Mods.Common/Activities/Enter.cs +++ b/OpenRA.Mods.Common/Activities/Enter.cs @@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Activities ReserveStatus TryReserveElseTryAlternateReserve(Actor self) { - for (var tries = 0;;) + for (var tries = 0;;) switch (Reserve(self)) { case ReserveStatus.None: @@ -255,7 +255,7 @@ namespace OpenRA.Mods.Common.Activities // Check target validity if not exiting or done if (nextState != State.Done && (target.Type != TargetType.Actor || !target.IsValidFor(self))) - AbortOrExit(self); + AbortOrExit(self); // If no current activity, tick next activity if (inner == null && FindAndTransitionToNextState(self) == State.Done) diff --git a/OpenRA.Mods.Common/Activities/EnterTransport.cs b/OpenRA.Mods.Common/Activities/EnterTransport.cs index 1c367017d5..3467ff1b53 100644 --- a/OpenRA.Mods.Common/Activities/EnterTransport.cs +++ b/OpenRA.Mods.Common/Activities/EnterTransport.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Activities protected override void OnInside(Actor self) { - self.World.AddFrameEndTask(w => + self.World.AddFrameEndTask(w => { if (self.IsDead || transport.IsDead || !cargo.CanLoad(transport, self)) return; diff --git a/OpenRA.Mods.Common/Activities/Hunt.cs b/OpenRA.Mods.Common/Activities/Hunt.cs index bbdb100ed4..95d96d3a75 100644 --- a/OpenRA.Mods.Common/Activities/Hunt.cs +++ b/OpenRA.Mods.Common/Activities/Hunt.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities { if (IsCanceled) return NextActivity; - + var target = targets.ClosestTo(self); if (target == null) return this; diff --git a/OpenRA.Mods.Common/Commands/HelpCommand.cs b/OpenRA.Mods.Common/Commands/HelpCommand.cs index 36a20394ba..4120d17364 100644 --- a/OpenRA.Mods.Common/Commands/HelpCommand.cs +++ b/OpenRA.Mods.Common/Commands/HelpCommand.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Commands World world; ChatCommands console; - public HelpCommand() + public HelpCommand() { helpDescriptions = new Dictionary(); } diff --git a/OpenRA.Mods.Common/Commands/PlayerCommands.cs b/OpenRA.Mods.Common/Commands/PlayerCommands.cs index 2da9ada010..6f6042534f 100644 --- a/OpenRA.Mods.Common/Commands/PlayerCommands.cs +++ b/OpenRA.Mods.Common/Commands/PlayerCommands.cs @@ -41,7 +41,9 @@ namespace OpenRA.Mods.Common.Commands { case "pause": world.IssueOrder(new Order("PauseGame", null, false) - { TargetString = world.Paused ? "UnPause" : "Pause" }); + { + TargetString = world.Paused ? "UnPause" : "Pause" + }); break; case "surrender": world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); diff --git a/OpenRA.Mods.Common/Effects/Beacon.cs b/OpenRA.Mods.Common/Effects/Beacon.cs index 36c1c31151..9a3b385e63 100644 --- a/OpenRA.Mods.Common/Effects/Beacon.cs +++ b/OpenRA.Mods.Common/Effects/Beacon.cs @@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Effects var palette = r.Palette(palettePrefix + owner.InternalName); foreach (var a in circles.Render(position, palette)) yield return a; - + foreach (var a in arrow.Render(position + new WVec(0, 0, arrowHeight), palette)) yield return a; diff --git a/OpenRA.Mods.Common/Effects/Missile.cs b/OpenRA.Mods.Common/Effects/Missile.cs index e308391057..993a39adc4 100644 --- a/OpenRA.Mods.Common/Effects/Missile.cs +++ b/OpenRA.Mods.Common/Effects/Missile.cs @@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Effects [Desc("Explodes when leaving the following terrain type, e.g., Water for torpedoes.")] public readonly string BoundToTerrainType = ""; [Desc("Explodes when inside this proximity radius to target.", - "Note: If this value is lower than the missile speed, this check might", + "Note: If this value is lower than the missile speed, this check might", "not trigger fast enough, causing the missile to fly past the target.")] public readonly WRange CloseEnough = new WRange(298); diff --git a/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs b/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs index be4ac2fb8f..5e86ed262c 100644 --- a/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs @@ -32,9 +32,10 @@ namespace OpenRA.Mods.Common.Graphics // Generated at render-time VoxelRenderProxy renderProxy; - public VoxelRenderable(IEnumerable voxels, WPos pos, int zOffset, WRot camera, float scale, - WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, - PaletteReference color, PaletteReference normals, PaletteReference shadow) + public VoxelRenderable( + IEnumerable voxels, WPos pos, int zOffset, WRot camera, float scale, + WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, + PaletteReference color, PaletteReference normals, PaletteReference shadow) { this.voxels = voxels; this.pos = pos; @@ -58,30 +59,34 @@ namespace OpenRA.Mods.Common.Graphics public IRenderable WithScale(float newScale) { - return new VoxelRenderable(voxels, pos, zOffset, camera, newScale, - lightSource, lightAmbientColor, lightDiffuseColor, - palette, normalsPalette, shadowPalette); + return new VoxelRenderable( + voxels, pos, zOffset, camera, newScale, + lightSource, lightAmbientColor, lightDiffuseColor, + palette, normalsPalette, shadowPalette); } public IRenderable WithPalette(PaletteReference newPalette) { - return new VoxelRenderable(voxels, pos, zOffset, camera, scale, - lightSource, lightAmbientColor, lightDiffuseColor, - newPalette, normalsPalette, shadowPalette); + return new VoxelRenderable( + voxels, pos, zOffset, camera, scale, + lightSource, lightAmbientColor, lightDiffuseColor, + newPalette, normalsPalette, shadowPalette); } public IRenderable WithZOffset(int newOffset) { - return new VoxelRenderable(voxels, pos, newOffset, camera, scale, - lightSource, lightAmbientColor, lightDiffuseColor, - palette, normalsPalette, shadowPalette); + return new VoxelRenderable( + voxels, pos, newOffset, camera, scale, + lightSource, lightAmbientColor, lightDiffuseColor, + palette, normalsPalette, shadowPalette); } public IRenderable OffsetBy(WVec vec) { - return new VoxelRenderable(voxels, pos + vec, zOffset, camera, scale, - lightSource, lightAmbientColor, lightDiffuseColor, - palette, normalsPalette, shadowPalette); + return new VoxelRenderable( + voxels, pos + vec, zOffset, camera, scale, + lightSource, lightAmbientColor, lightDiffuseColor, + palette, normalsPalette, shadowPalette); } public IRenderable AsDecoration() { return this; } diff --git a/OpenRA.Mods.Common/Scripting/Global/MapGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/MapGlobal.cs index 44d27e1016..bb4326932d 100644 --- a/OpenRA.Mods.Common/Scripting/Global/MapGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/MapGlobal.cs @@ -20,7 +20,8 @@ namespace OpenRA.Mods.Common.Scripting public class MapGlobal : ScriptGlobal { SpawnMapActors sma; - public MapGlobal(ScriptContext context) : base(context) + public MapGlobal(ScriptContext context) + : base(context) { sma = context.World.WorldActor.Trait(); diff --git a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs index 0f41004b98..ac25b63693 100644 --- a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs @@ -19,7 +19,8 @@ namespace OpenRA.Mods.Common.Scripting public class MediaGlobal : ScriptGlobal { World world; - public MediaGlobal(ScriptContext context) : base(context) + public MediaGlobal(ScriptContext context) + : base(context) { world = context.World; } diff --git a/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs index b80b71d19d..d858a54817 100644 --- a/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs @@ -413,7 +413,7 @@ namespace OpenRA.Mods.Common.Scripting GetScriptTriggers(a).ClearAll(); } - [Desc("Removes the specified trigger from this actor." + + [Desc("Removes the specified trigger from this actor." + "Note that the removal will only take effect at the end of a tick, " + "so you must not add new triggers at the same time that you are calling this function.")] public void Clear(Actor a, string triggerName) diff --git a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs index 9beaf343e7..9ce5465eb3 100644 --- a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs +++ b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs @@ -18,8 +18,11 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Scripting { - public enum Trigger { OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost, - OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated, OnAddedToWorld, OnRemovedFromWorld } + public enum Trigger + { + OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost, + OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated, OnAddedToWorld, OnRemovedFromWorld + } [Desc("Allows map scripts to attach triggers to this actor via the Triggers global.")] public class ScriptTriggersInfo : ITraitInfo diff --git a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs index 6b9b6ddcd8..059679afcc 100644 --- a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs +++ b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs @@ -20,8 +20,8 @@ namespace OpenRA.Mods.Common.Server { public class MasterServerPinger : ServerTrait, ITick, INotifySyncLobbyInfo, IStartGame, IEndGame { - const int MasterPingInterval = 60 * 3; // 3 minutes. server has a 5 minute TTL for games, so give ourselves a bit - // of leeway. + // 3 minutes. Server has a 5 minute TTL for games, so give ourselves a bit of leeway. + const int MasterPingInterval = 60 * 3; public int TickTimeout { get { return MasterPingInterval * 10000; } } public void Tick(S server) diff --git a/OpenRA.Mods.Common/SpriteLoaders/ShpTDLoader.cs b/OpenRA.Mods.Common/SpriteLoaders/ShpTDLoader.cs index 055375889a..4fe05dad38 100644 --- a/OpenRA.Mods.Common/SpriteLoaders/ShpTDLoader.cs +++ b/OpenRA.Mods.Common/SpriteLoaders/ShpTDLoader.cs @@ -168,26 +168,26 @@ namespace OpenRA.Mods.Common.SpriteLoaders { case Format.Format20: case Format.Format40: - { - if (h.RefImage.Data == null) { - ++recurseDepth; - Decompress(h.RefImage); - --recurseDepth; + if (h.RefImage.Data == null) + { + ++recurseDepth; + Decompress(h.RefImage); + --recurseDepth; + } + + h.Data = CopyImageData(h.RefImage.Data); + Format40.DecodeInto(shpBytes, h.Data, (int)(h.FileOffset - shpBytesFileOffset)); + break; } - h.Data = CopyImageData(h.RefImage.Data); - Format40.DecodeInto(shpBytes, h.Data, (int)(h.FileOffset - shpBytesFileOffset)); - break; - } - case Format.Format80: - { - var imageBytes = new byte[Size.Width * Size.Height]; - Format80.DecodeInto(shpBytes, imageBytes, (int)(h.FileOffset - shpBytesFileOffset)); - h.Data = imageBytes; - break; - } + { + var imageBytes = new byte[Size.Width * Size.Height]; + Format80.DecodeInto(shpBytes, imageBytes, (int)(h.FileOffset - shpBytesFileOffset)); + h.Data = imageBytes; + break; + } default: throw new InvalidDataException(); diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index de7dc915b1..630eabbf07 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -288,12 +288,12 @@ namespace OpenRA.Mods.Common.Traits { switch (order.OrderString) { - case "Move": - case "Enter": - case "ReturnToBase": - case "Stop": - return "Move"; - default: return null; + case "Move": + case "Enter": + case "ReturnToBase": + case "Stop": + return "Move"; + default: return null; } } } diff --git a/OpenRA.Mods.Common/Traits/Air/Plane.cs b/OpenRA.Mods.Common/Traits/Air/Plane.cs index 2db50c7cfc..5427971137 100644 --- a/OpenRA.Mods.Common/Traits/Air/Plane.cs +++ b/OpenRA.Mods.Common/Traits/Air/Plane.cs @@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits 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 MoveToTarget(Actor self, Target target) { return new Fly(self, target, WRange.FromCells(3), WRange.FromCells(5)); } + 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/Air/TargetableAircraft.cs b/OpenRA.Mods.Common/Traits/Air/TargetableAircraft.cs index 7c0b8437f0..1ed86f6bca 100644 --- a/OpenRA.Mods.Common/Traits/Air/TargetableAircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/TargetableAircraft.cs @@ -33,8 +33,11 @@ namespace OpenRA.Mods.Common.Traits public override string[] TargetTypes { - get { return (self.CenterPosition.Z > 0) ? info.TargetTypes - : info.GroundedTargetTypes; } + get + { + return (self.CenterPosition.Z > 0) ? info.TargetTypes + : info.GroundedTargetTypes; + } } } } diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs index bc5db50657..dfb6d3364f 100644 --- a/OpenRA.Mods.Common/Traits/Armament.cs +++ b/OpenRA.Mods.Common/Traits/Armament.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Has to be defined here and in weapons.yaml.")] public readonly string Weapon = null; public readonly string Turret = "primary"; - [Desc("Time (in frames) until the weapon can fire again.")] + [Desc("Time (in frames) until the weapon can fire again.")] public readonly int FireDelay = 0; [Desc("Muzzle position relative to turret or body. (forward, right, up) triples")] diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 6b1650c37d..b248776de1 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -113,12 +113,12 @@ namespace OpenRA.Mods.Common.Traits { switch (target.Type) { - case TargetType.Actor: - return new Order("Attack", self, queued) { TargetActor = target.Actor }; - case TargetType.FrozenActor: - return new Order("Attack", self, queued) { ExtraData = target.FrozenActor.ID }; - case TargetType.Terrain: - return new Order("Attack", self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) }; + case TargetType.Actor: + return new Order("Attack", self, queued) { TargetActor = target.Actor }; + case TargetType.FrozenActor: + return new Order("Attack", self, queued) { ExtraData = target.FrozenActor.ID }; + case TargetType.Terrain: + return new Order("Attack", self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) }; } } @@ -255,13 +255,13 @@ namespace OpenRA.Mods.Common.Traits { switch (target.Type) { - case TargetType.Actor: - case TargetType.FrozenActor: - return CanTargetActor(self, target, modifiers, ref cursor); - case TargetType.Terrain: - return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), othersAtTarget, modifiers, ref cursor); - default: - return false; + case TargetType.Actor: + case TargetType.FrozenActor: + return CanTargetActor(self, target, modifiers, ref cursor); + case TargetType.Terrain: + return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), othersAtTarget, modifiers, ref cursor); + default: + return false; } } diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackCharge.cs b/OpenRA.Mods.Common/Traits/Attack/AttackCharge.cs index 5df85e0b1e..33ac7b2097 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackCharge.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackCharge.cs @@ -84,10 +84,10 @@ namespace OpenRA.Mods.Common.Traits readonly AttackCharge attack; readonly Target target; - public ChargeAttack(AttackCharge attack, Target target) - { + public ChargeAttack(AttackCharge attack, Target target) + { this.attack = attack; - this.target = target; + this.target = target; } public override Activity Tick(Actor self) @@ -109,10 +109,10 @@ namespace OpenRA.Mods.Common.Traits readonly AttackCharge attack; readonly Target target; - public ChargeFire(AttackCharge attack, Target target) - { + public ChargeFire(AttackCharge attack, Target target) + { this.attack = attack; - this.target = target; + this.target = target; } public override Activity Tick(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Buildable.cs b/OpenRA.Mods.Common/Traits/Buildable.cs index 18218a5d49..0915cadd6e 100644 --- a/OpenRA.Mods.Common/Traits/Buildable.cs +++ b/OpenRA.Mods.Common/Traits/Buildable.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Disable production when there are more than this many of this actor on the battlefield. Set to 0 to disable.")] public readonly int BuildLimit = 0; - [Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")] + [Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")] public readonly string InitialActivity = null; // TODO: UI fluff; doesn't belong here diff --git a/OpenRA.Mods.Common/Traits/Buildings/DeadBuildingState.cs b/OpenRA.Mods.Common/Traits/Buildings/DeadBuildingState.cs index 5193dcab6d..1420dd2dab 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/DeadBuildingState.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/DeadBuildingState.cs @@ -35,12 +35,12 @@ namespace OpenRA.Mods.Common.Traits public void Killed(Actor self, AttackInfo e) { if (!rs.DefaultAnimation.HasSequence("dead")) return; - + if (rs.DefaultAnimation.GetSequence("dead").Length > 1) rs.DefaultAnimation.Play("dead"); else rs.DefaultAnimation.PlayRepeating("dead"); - + self.World.AddFrameEndTask( w => w.Add( new DelayedAction(info.LingerTime, diff --git a/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs b/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs index 09ee2b29e0..75d07e23ea 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs @@ -40,10 +40,13 @@ namespace OpenRA.Mods.Common.Traits // the one we're playing in. return new DisposableAction( () => { reservedFor = null; reservedForAircraft = null; }, - () => Game.RunAfterTick( - () => { if (Game.IsCurrentWorld(self.World)) throw new InvalidOperationException( - "Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})" - .F(forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID)); })); + () => Game.RunAfterTick(() => + { + if (Game.IsCurrentWorld(self.World)) + throw new InvalidOperationException( + "Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})".F( + forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID)); + })); } public static bool IsReserved(Actor a) diff --git a/OpenRA.Mods.Common/Traits/Cloak.cs b/OpenRA.Mods.Common/Traits/Cloak.cs index 3a3151734e..3922a6308d 100644 --- a/OpenRA.Mods.Common/Traits/Cloak.cs +++ b/OpenRA.Mods.Common/Traits/Cloak.cs @@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Traits lastPos = self.Location; } } - + public bool IsVisible(Actor self, Player viewer) { if (!Cloaked || self.Owner.IsAlliedWith(viewer)) diff --git a/OpenRA.Mods.Common/Traits/GivesBounty.cs b/OpenRA.Mods.Common/Traits/GivesBounty.cs index 88b7117eb8..5189289450 100644 --- a/OpenRA.Mods.Common/Traits/GivesBounty.cs +++ b/OpenRA.Mods.Common/Traits/GivesBounty.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits { var info = self.Info.Traits.Get(); - if (e.Attacker == null || e.Attacker.Destroyed) return; + if (e.Attacker == null || e.Attacker.Destroyed) return; if (!info.Stances.Contains(e.Attacker.Owner.Stances[self.Owner])) return; diff --git a/OpenRA.Mods.Common/Traits/GlobalUpgradable.cs b/OpenRA.Mods.Common/Traits/GlobalUpgradable.cs index 7888f45f11..7c1ca0f90c 100644 --- a/OpenRA.Mods.Common/Traits/GlobalUpgradable.cs +++ b/OpenRA.Mods.Common/Traits/GlobalUpgradable.cs @@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits { if (available == wasAvailable) return; - + if (available) foreach (var u in info.Upgrades) manager.GrantUpgrade(self, u, this); diff --git a/OpenRA.Mods.Common/Traits/Huntable.cs b/OpenRA.Mods.Common/Traits/Huntable.cs index 77a0f68b80..a59056eb6f 100644 --- a/OpenRA.Mods.Common/Traits/Huntable.cs +++ b/OpenRA.Mods.Common/Traits/Huntable.cs @@ -12,7 +12,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - [Desc("This actor can be targeted by the Hunt activity.")] - public class HuntableInfo : TraitInfo { } - public class Huntable { } + [Desc("This actor can be targeted by the Hunt activity.")] + public class HuntableInfo : TraitInfo { } + public class Huntable { } } diff --git a/OpenRA.Mods.Common/Traits/IgnoresDisguise.cs b/OpenRA.Mods.Common/Traits/IgnoresDisguise.cs index cf936a1c6c..b9f93285fd 100644 --- a/OpenRA.Mods.Common/Traits/IgnoresDisguise.cs +++ b/OpenRA.Mods.Common/Traits/IgnoresDisguise.cs @@ -12,8 +12,8 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - [Desc("Allows automatic targeting of disguised actors.")] - class IgnoresDisguiseInfo : TraitInfo { } + [Desc("Allows automatic targeting of disguised actors.")] + class IgnoresDisguiseInfo : TraitInfo { } - class IgnoresDisguise { } + class IgnoresDisguise { } } diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 9aa16f0307..a08ef7cf0c 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -184,7 +184,7 @@ namespace OpenRA.Mods.Common.Traits // Neutral/enemy units are blockers. Allied units that are moving are not blockers. if (canIgnoreMovingAllies && self.Owner.Stances[a.Owner] == Stance.Ally && IsMovingInMyDirection(self, a)) continue; - + // Non-sharable unit can enter a cell with shareable units only if it can crush all of them. if (needsCellExclusively) return false; @@ -218,7 +218,7 @@ namespace OpenRA.Mods.Common.Traits // Neutral/enemy units are blockers. Allied units that are moving are not blockers. if (canIgnoreMovingAllies && self.Owner.Stances[a.Owner] == Stance.Ally && IsMovingInMyDirection(self, a)) return false; - + // Non-sharable unit can enter a cell with shareable units only if it can crush all of them. if (needsCellExclusively) return true; @@ -252,7 +252,7 @@ namespace OpenRA.Mods.Common.Traits const int AverageTicksBeforePathing = 5; const int SpreadTicksBeforePathing = 5; internal int TicksBeforePathing = 0; - + readonly Actor self; public readonly MobileInfo Info; public bool IsMoving { get; set; } diff --git a/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs index 29a785ad3b..c9f4798e45 100644 --- a/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs +++ b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs @@ -36,13 +36,13 @@ namespace OpenRA.Mods.Common.Traits public class MissionObjectivesInfo : ITraitInfo { [Desc("Set this to true if multiple cooperative players have a distinct set of " + - "objectives that each of them has to complete to win the game. This is mainly " + - "useful for multiplayer coop missions. Do not use this for skirmish team games.")] + "objectives that each of them has to complete to win the game. This is mainly " + + "useful for multiplayer coop missions. Do not use this for skirmish team games.")] public readonly bool Cooperative = false; [Desc("If set to true, this setting causes the game to end immediately once the first " + - "player (or team of cooperative players) fails or completes his objectives. If " + - "set to false, players that fail their objectives will stick around and become observers.")] + "player (or team of cooperative players) fails or completes his objectives. If " + + "set to false, players that fail their objectives will stick around and become observers.")] public readonly bool EarlyGameOver = false; [Desc("Delay between the game over condition being met, and the game actually ending, in milliseconds.")] @@ -245,8 +245,8 @@ namespace OpenRA.Mods.Common.Traits } [Desc("Provides game mode progress information for players.", - "Goes on WorldActor - observers don't have a player it can live on.", - "Current options for PanelName are 'SKIRMISH_STATS' and 'MISSION_OBJECTIVES'.")] + "Goes on WorldActor - observers don't have a player it can live on.", + "Current options for PanelName are 'SKIRMISH_STATS' and 'MISSION_OBJECTIVES'.")] public class ObjectivesPanelInfo : ITraitInfo { public string PanelName = null; diff --git a/OpenRA.Mods.Common/Traits/Player/PlayerStatistics.cs b/OpenRA.Mods.Common/Traits/Player/PlayerStatistics.cs index f487c60a74..5400a217e2 100644 --- a/OpenRA.Mods.Common/Traits/Player/PlayerStatistics.cs +++ b/OpenRA.Mods.Common/Traits/Player/PlayerStatistics.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits public double MapControl; public int OrderCount; - public int EarnedThisMinute + public int EarnedThisMinute { get { diff --git a/OpenRA.Mods.Common/Traits/Player/ProvidesCustomPrerequisite.cs b/OpenRA.Mods.Common/Traits/Player/ProvidesCustomPrerequisite.cs index 96a589c3de..beaf9591bd 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProvidesCustomPrerequisite.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProvidesCustomPrerequisite.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits { this.info = info; - var race = init.Contains() ? init.Get() : init.Self.Owner.Country.Race; + var race = init.Contains() ? init.Get() : init.Self.Owner.Country.Race; Update(init.Self.Owner, race); } diff --git a/OpenRA.Mods.Common/Traits/Power/Power.cs b/OpenRA.Mods.Common/Traits/Power/Power.cs index fb7f427a25..ad0bd53f9d 100644 --- a/OpenRA.Mods.Common/Traits/Power/Power.cs +++ b/OpenRA.Mods.Common/Traits/Power/Power.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits PlayerPower = self.Owner.PlayerActor.Trait(); powerModifiers = Exts.Lazy(() => self.TraitsImplementing().ToArray()); } - + protected override void UpgradeEnabled(Actor self) { PlayerPower.UpdateActor(self); } protected override void UpgradeDisabled(Actor self) { PlayerPower.UpdateActor(self); } public void AddedToWorld(Actor self) { PlayerPower.UpdateActor(self); } diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs b/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs index 60f5faa5ec..ba12789953 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits { var t = init.Actor.Traits.WithInterface() .FirstOrDefault(); - + // Show the correct turret facing var anim = new Animation(init.World, image, () => t.InitialFacing); anim.PlayRepeating("idle"); diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs index 490896abfe..2928cdb458 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Custom palette name")] public readonly string Palette = "effect"; - + public object Create(ActorInitializer init) { return new WithBuildingExplosion(this); } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs index 70cdf9c34e..6f2a71ff8a 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits this.info = info; renderSimple = self.Trait(); } - + public void BuildingPlaced(Actor self) { renderSimple.PlayCustomAnim(self, info.Sequence); diff --git a/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs index 8c2bda0e18..4a931f5b40 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits var building = self.Trait(); if (!building.SkipMakeAnimation) { - renderBuilding.PlayCustomAnimThen(self, info.Sequence, () => + renderBuilding.PlayCustomAnimThen(self, info.Sequence, () => { building.NotifyBuildingComplete(self); }); diff --git a/OpenRA.Mods.Common/Traits/Render/WithResources.cs b/OpenRA.Mods.Common/Traits/Render/WithResources.cs index 41ae939b51..8f2f201d0c 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithResources.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithResources.cs @@ -38,9 +38,10 @@ namespace OpenRA.Mods.Common.Traits anim = new Animation(self.World, rs.GetImage(self)); anim.PlayFetchIndex(info.Sequence, - () => playerResources.ResourceCapacity != 0 - ? ((10 * anim.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity) - : 0); + () => + playerResources.ResourceCapacity != 0 ? + ((10 * anim.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity) : + 0); rs.Add("resources_{0}".F(info.Sequence), new AnimationWithOffset( anim, null, () => !buildComplete, 1024)); diff --git a/OpenRA.Mods.Common/Traits/SelfHealing.cs b/OpenRA.Mods.Common/Traits/SelfHealing.cs index 84a9b9a7a4..f78c295022 100644 --- a/OpenRA.Mods.Common/Traits/SelfHealing.cs +++ b/OpenRA.Mods.Common/Traits/SelfHealing.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits if (health.HP >= Info.HealIfBelow * health.MaxHP) return; - + if (damageTicks > 0) { --damageTicks; diff --git a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnKill.cs b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnKill.cs index cb17a18f60..c3fd779348 100644 --- a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnKill.cs +++ b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnKill.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits public void AppliedDamage(Actor self, Actor damaged, AttackInfo e) { // Don't notify suicides - if (e.DamageState == DamageState.Dead && damaged != e.Attacker) + if (e.DamageState == DamageState.Dead && damaged != e.Attacker) { if (self.World.WorldTick - lastAnnounce > info.Interval * 25) Sound.PlayVoice("Kill", self, self.Owner.Country.Race); diff --git a/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs b/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs index e6cf67fc7c..d8d7d3ec05 100644 --- a/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs +++ b/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits { [Desc("Death notification voice.")] public readonly string DeathSound = "Die"; - + [Desc("Multiply volume with this factor.")] public readonly float VolumeMultiplier = 1f; diff --git a/OpenRA.Mods.Common/Traits/World/PathFinder.cs b/OpenRA.Mods.Common/Traits/World/PathFinder.cs index ad6c447df6..b722c17883 100644 --- a/OpenRA.Mods.Common/Traits/World/PathFinder.cs +++ b/OpenRA.Mods.Common/Traits/World/PathFinder.cs @@ -99,8 +99,8 @@ namespace OpenRA.Mods.Common.Traits // Select only the tiles that are within range from the requested SubCell // This assumes that the SubCell does not change during the path traversal var tilesInRange = world.Map.FindTilesInCircle(targetCell, range.Range / 1024 + 1) - .Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= rangeSquared - && mi.CanEnterCell(self.World, self, t)); + .Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= rangeSquared && + mi.CanEnterCell(self.World, self, t)); // See if there is any cell within range that does not involve a cross-domain request // Really, we only need to check the circle perimeter, but it's not clear that would be a performance win diff --git a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs index 80435b7a2e..d1e9f949c7 100644 --- a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string FogPalette = "fog"; [Desc("Bitfield of shroud directions for each frame. Lower four bits are", - "corners clockwise from TL; upper four are edges clockwise from top")] + "corners clockwise from TL; upper four are edges clockwise from top")] public readonly int[] Index = new[] { 12, 9, 8, 3, 1, 6, 4, 2, 13, 11, 7, 14 }; [Desc("Use the upper four bits when calculating frame")] diff --git a/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs b/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs index 4f454bdc1a..18e480639d 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs @@ -1,12 +1,12 @@ #region Copyright & License Information - /* +/* * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, * see COPYING. */ - #endregion +#endregion using System; using System.Collections.Generic; diff --git a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs index e2e3997323..70a82ec230 100644 --- a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs +++ b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs @@ -284,7 +284,7 @@ namespace OpenRA.Mods.Common.UtilityCommands if (o != 255 && overlayResourceMapping.ContainsKey(redAlertOverlayNames[o])) res = overlayResourceMapping[redAlertOverlayNames[o]]; - + var cell = new CPos(i, j); map.MapResources.Value[cell] = new ResourceTile(res.First, res.Second); diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index bda37ed9ec..a6ea33fc67 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -351,7 +351,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var powerFields = new List { new MiniYamlNode("Amount", power.Value) }; actorTraits.Add(new MiniYamlNode("Power", new MiniYaml("", powerFields))); - + if (FieldLoader.GetValue("Power", power.Value.Value) > 0) actorTraits.Add(new MiniYamlNode("ScaleWithHealth", "")); } @@ -528,7 +528,7 @@ namespace OpenRA.Mods.Common.UtilityCommands if (engineVersion < 20140913) { var spawnsCorpseRemoval = node.Value.Nodes.FirstOrDefault(n => n.Key == "SpawnsCorpse"); - + if (depth == 0 && node.Value.Nodes.Any(n => n.Key.StartsWith("RenderInfantry")) && spawnsCorpseRemoval == null) node.Value.Nodes.Add(new MiniYamlNode("WithDeathAnimation", new MiniYaml(""))); @@ -732,13 +732,13 @@ namespace OpenRA.Mods.Common.UtilityCommands ConvertAngle(ref node.Value.Value); break; case "Speed": - { - if (parent.Value.Value == "Missile") - ConvertPxToRange(ref node.Value.Value, 1, 5); - if (parent.Value.Value == "Bullet") - ConvertPxToRange(ref node.Value.Value, 2, 5); - break; - } + { + if (parent.Value.Value == "Missile") + ConvertPxToRange(ref node.Value.Value, 1, 5); + if (parent.Value.Value == "Bullet") + ConvertPxToRange(ref node.Value.Value, 2, 5); + break; + } default: break; diff --git a/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs b/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs index f6f1db3273..7583891a72 100644 --- a/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs @@ -171,25 +171,25 @@ namespace OpenRA.Mods.Common.Widgets switch (mi.Event) { - case MouseInputEvent.Up: - isMoving = false; - YieldMouseFocus(mi); - break; + case MouseInputEvent.Up: + isMoving = false; + YieldMouseFocus(mi); + break; - case MouseInputEvent.Down: - isMoving = true; - SetValueFromPx(mi.Location - RenderOrigin); - OnChange(); - break; - - case MouseInputEvent.Move: - if (isMoving) - { + case MouseInputEvent.Down: + isMoving = true; SetValueFromPx(mi.Location - RenderOrigin); OnChange(); - } + break; - break; + case MouseInputEvent.Move: + if (isMoving) + { + SetValueFromPx(mi.Location - RenderOrigin); + OnChange(); + } + + break; } return true; diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index a6e3452cc6..2028ff2484 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var playerWidget = panel.GetOrNull("PLAYER"); - if (playerWidget != null) + if (playerWidget != null) playerWidget.IsVisible = () => isVideoLoaded; var paletteDropDown = panel.GetOrNull("PALETTE_SELECTOR"); @@ -118,22 +118,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic frameSlider = panel.Get("FRAME_SLIDER"); if (frameSlider != null) { - frameSlider.OnChange += x => + frameSlider.OnChange += x => { - if (!isVideoLoaded) - currentFrame = (int)Math.Round(x); + if (!isVideoLoaded) + currentFrame = (int)Math.Round(x); }; frameSlider.GetValue = () => isVideoLoaded ? player.Video.CurrentFrame : currentFrame; - frameSlider.IsDisabled = () => isVideoLoaded; + frameSlider.IsDisabled = () => isVideoLoaded; } var frameText = panel.GetOrNull("FRAME_COUNT"); if (frameText != null) { - frameText.GetText = () => - isVideoLoaded ? - "{0} / {1}".F(player.Video.CurrentFrame + 1, player.Video.Frames) : + frameText.GetText = () => + isVideoLoaded ? + "{0} / {1}".F(player.Video.CurrentFrame + 1, player.Video.Frames) : "{0} / {1}".F(currentFrame + 1, currentSprites.Length); } @@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { nextButton.OnClick = () => { - if (!isVideoLoaded) + if (!isVideoLoaded) nextButton.OnClick = SelectNextFrame; }; @@ -211,12 +211,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic var closeButton = panel.GetOrNull("CLOSE_BUTTON"); if (closeButton != null) - closeButton.OnClick = () => + closeButton.OnClick = () => { if (isVideoLoaded) player.Stop(); Ui.CloseWindow(); - onExit(); + onExit(); }; } @@ -290,7 +290,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic player = null; isVideoLoaded = false; } - + if (string.IsNullOrEmpty(filename)) return false; @@ -325,8 +325,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic Func setupItem = (source, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, - () => assetSource == source, - () => { assetSource = source; PopulateAssetList(); }); + () => assetSource == source, + () => { assetSource = source; PopulateAssetList(); }); item.Get("LABEL").GetText = () => source != null ? Platform.UnresolvePath(source.Name) : "All Packages"; return item; }; @@ -359,7 +359,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } } } - + bool ShowPaletteDropdown(DropDownButtonWidget dropdown, World world) { Func setupItem = (palette, itemTemplate) => diff --git a/OpenRA.Mods.Common/Widgets/Logic/DisconnectWatcherLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/DisconnectWatcherLogic.cs index 8fdaf4aa30..c249a31019 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/DisconnectWatcherLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/DisconnectWatcherLogic.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic public DisconnectWatcherLogic(Widget widget, OrderManager orderManager) { var disconnected = false; - widget.Get("DISCONNECT_WATCHER").OnTick = () => + widget.Get("DISCONNECT_WATCHER").OnTick = () => { if (disconnected || orderManager.Connection.ConnectionState != ConnectionState.NotConnected) return; diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 66e639907a..2f6c35fb4c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var textBox = key.Get("HOTKEY"); textBox.Key = (Hotkey)field.GetValue(ks); - textBox.OnLoseFocus = () => field.SetValue(ks, textBox.Key); + textBox.OnLoseFocus = () => field.SetValue(ks, textBox.Key); parent.AddChild(key); } @@ -536,8 +536,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic Func setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, - () => s.MouseScroll == options[o], - () => s.MouseScroll = options[o]); + () => s.MouseScroll == options[o], + () => s.MouseScroll = options[o]); item.Get("LABEL").GetText = () => o; return item; }; diff --git a/OpenRA.Mods.Common/Widgets/RadarWidget.cs b/OpenRA.Mods.Common/Widgets/RadarWidget.cs index 9c72bb5be9..1a5ccac3f9 100644 --- a/OpenRA.Mods.Common/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.Common/Widgets/RadarWidget.cs @@ -274,7 +274,7 @@ namespace OpenRA.Mods.Common.Widgets var stride = radarSheet.Size.Width; var dx = actorSprite.Bounds.Left - world.Map.Bounds.Left; var dy = actorSprite.Bounds.Top - world.Map.Bounds.Top; - + Array.Clear(radarData, 4 * (actorSprite.Bounds.Top * stride + actorSprite.Bounds.Left), 4 * actorSprite.Bounds.Height * stride); unsafe diff --git a/OpenRA.Mods.Common/Widgets/ResourceBarWidget.cs b/OpenRA.Mods.Common/Widgets/ResourceBarWidget.cs index bf4925702c..9d479c7a84 100644 --- a/OpenRA.Mods.Common/Widgets/ResourceBarWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ResourceBarWidget.cs @@ -96,8 +96,9 @@ namespace OpenRA.Mods.Common.Widgets } } else - Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, (int)float2.Lerp(b.Bottom, b.Top, providedFrac), - b.Width, (int)(providedFrac * b.Height)), color); + Game.Renderer.LineRenderer.FillRect(new Rectangle( + b.X, (int)float2.Lerp(b.Bottom, b.Top, providedFrac), + b.Width, (int)(providedFrac * b.Height)), color); var x = (b.Left + b.Right - indicator.Size.X) / 2; var y = float2.Lerp(b.Bottom, b.Top, usedFrac) - indicator.Size.Y / 2; diff --git a/OpenRA.Mods.D2k/Activities/CarryUnit.cs b/OpenRA.Mods.D2k/Activities/CarryUnit.cs index fa3176fe4a..1d70030e27 100644 --- a/OpenRA.Mods.D2k/Activities/CarryUnit.cs +++ b/OpenRA.Mods.D2k/Activities/CarryUnit.cs @@ -96,7 +96,7 @@ namespace OpenRA.Mods.D2k.Activities { state = State.MoveToCarryable; return this; - } + } else { // We got cancelled @@ -177,7 +177,7 @@ namespace OpenRA.Mods.D2k.Activities c.Dropped(); state = State.Done; - return Util.SequenceActivities(new Wait(10), this); + return Util.SequenceActivities(new Wait(10), this); case State.Done: diff --git a/OpenRA.Mods.D2k/Traits/World/PaletteFromR8.cs b/OpenRA.Mods.D2k/Traits/World/PaletteFromR8.cs index 7f9c0a3d26..b03c12d9d6 100644 --- a/OpenRA.Mods.D2k/Traits/World/PaletteFromR8.cs +++ b/OpenRA.Mods.D2k/Traits/World/PaletteFromR8.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.D2k.Traits public readonly long Offset = 0; public readonly bool AllowModifiers = true; public readonly bool InvertColor = false; - + public object Create(ActorInitializer init) { return new PaletteFromR8(this); } } diff --git a/OpenRA.Mods.D2k/Traits/World/WormManager.cs b/OpenRA.Mods.D2k/Traits/World/WormManager.cs index 92ec0d28c1..7b2e855d15 100644 --- a/OpenRA.Mods.D2k/Traits/World/WormManager.cs +++ b/OpenRA.Mods.D2k/Traits/World/WormManager.cs @@ -94,7 +94,7 @@ namespace OpenRA.Mods.D2k.Traits })); wormsPresent++; - + return spawnPoint.CenterPosition; } diff --git a/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs index f03c354527..f6f09b5d14 100644 --- a/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs @@ -293,10 +293,10 @@ namespace OpenRA.Mods.D2k.Widgets var size = font.Measure(tb.Second); if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0 || tb.Second != ReadyText) font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0), - Color.White, Color.Black, 1); + Color.White, Color.Black, 1); else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor) font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0), - ReadyTextAltColor, Color.Black, 1); + ReadyTextAltColor, Color.Black, 1); } // Tooltip diff --git a/OpenRA.Mods.RA/AI/AttackOrFleeFuzzy.cs b/OpenRA.Mods.RA/AI/AttackOrFleeFuzzy.cs index afccefc41a..26ed54e725 100644 --- a/OpenRA.Mods.RA/AI/AttackOrFleeFuzzy.cs +++ b/OpenRA.Mods.RA/AI/AttackOrFleeFuzzy.cs @@ -77,7 +77,7 @@ namespace OpenRA.Mods.RA.AI "and ((EnemyHealth is NearDead) or (EnemyHealth is Injured) or (EnemyHealth is Normal)) " + "and ((RelativeAttackPower is Weak) or (RelativeAttackPower is Equal) or (RelativeAttackPower is Strong)) " + "and ((RelativeSpeed is Slow) or (RelativeSpeed is Equal) or (RelativeSpeed is Fast))) " + - "then AttackOrFlee is Attack"); + "then AttackOrFlee is Attack"); } protected virtual void AddingRulesForInjuredOwnHealth() @@ -212,7 +212,7 @@ namespace OpenRA.Mods.RA.AI return RelativeValue(own, enemy, 100, Average, (Actor a) => a.Trait().Info.Speed); } - protected static float RelativeValue(IEnumerable own, IEnumerable enemy, float normalizeByValue, + protected static float RelativeValue(IEnumerable own, IEnumerable enemy, float normalizeByValue, Func, Func, float> relativeFunc, Func getValue) { if (!enemy.Any()) diff --git a/OpenRA.Mods.RA/AI/HackyAI.cs b/OpenRA.Mods.RA/AI/HackyAI.cs index 995592d3d8..4367c1e725 100644 --- a/OpenRA.Mods.RA/AI/HackyAI.cs +++ b/OpenRA.Mods.RA/AI/HackyAI.cs @@ -180,7 +180,7 @@ namespace OpenRA.Mods.RA.AI { Info = info; World = init.World; - + foreach (var decision in info.PowerDecisions) powerDecisions.Add(decision.OrderName, decision); } @@ -200,9 +200,9 @@ namespace OpenRA.Mods.RA.AI supportPowerMngr = p.PlayerActor.Trait(); playerResource = p.PlayerActor.Trait(); - foreach (var building in Info.BuildingQueues) + foreach (var building in Info.BuildingQueues) builders.Add(new BaseBuilder(this, building, p, playerPower, playerResource)); - foreach (var defense in Info.DefenseQueues) + foreach (var defense in Info.DefenseQueues) builders.Add(new BaseBuilder(this, defense, p, playerPower, playerResource)); Random = new MersenneTwister((int)p.PlayerActor.ActorID); @@ -310,7 +310,7 @@ namespace OpenRA.Mods.RA.AI // For mods like RA (number of building must match the number of aircraft) bool HasAdequateAirUnits(ActorInfo actorInfo) { - if (!actorInfo.Traits.Contains() && actorInfo.Traits.Contains() + if (!actorInfo.Traits.Contains() && actorInfo.Traits.Contains() && actorInfo.Traits.Contains()) { var countOwnAir = CountUnits(actorInfo.Name, Player); @@ -387,7 +387,7 @@ namespace OpenRA.Mods.RA.AI } // Can't find a build location - return null; + return null; } public void Tick(Actor self) @@ -402,7 +402,7 @@ namespace OpenRA.Mods.RA.AI if (ticks % FeedbackTime == 0) ProductionUnits(self); - + AssignRolesToIdleUnits(self); SetRallyPointsForNewProductionBuildings(self); TryToUseSupportPower(self); @@ -504,7 +504,7 @@ namespace OpenRA.Mods.RA.AI void AssignRolesToIdleUnits(Actor self) { CleanSquads(); - activeUnits.RemoveAll(a => a.IsDead || a.Owner != Player); + activeUnits.RemoveAll(a => a.IsDead || a.Owner != Player); unitsHangingAroundTheBase.RemoveAll(a => a.IsDead || a.Owner != Player); if (--rushTicks <= 0) @@ -555,7 +555,7 @@ namespace OpenRA.Mods.RA.AI // Tell the idle harvester to quit slacking: World.IssueOrder(new Order("Harvest", a, false)); - } + } } void FindNewUnits(Actor self) @@ -582,7 +582,7 @@ namespace OpenRA.Mods.RA.AI } activeUnits.Add(a); - } + } } void CreateAttackForce() @@ -616,7 +616,7 @@ namespace OpenRA.Mods.RA.AI { var enemies = World.FindActorsInCircle(b.CenterPosition, WRange.FromCells(Info.RushAttackScanRadius)) .Where(unit => Player.Stances[unit.Owner] == Stance.Enemy && unit.HasTrait()).ToList(); - + if (rushFuzzy.CanAttack(ownUnits, enemies)) { var target = enemies.Any() ? enemies.Random(Random) : b; @@ -626,7 +626,7 @@ namespace OpenRA.Mods.RA.AI foreach (var a3 in ownUnits) rush.Units.Add(a3); - + return; } } @@ -803,7 +803,7 @@ namespace OpenRA.Mods.RA.AI var tl = World.Map.CenterOfCell(new CPos(i, j)); var br = World.Map.CenterOfCell(new CPos(i + checkRadius, j + checkRadius)); var targets = World.ActorMap.ActorsInBox(tl, br); - + consideredAttractiveness = powerDecision.GetAttractiveness(targets, Player); if (consideredAttractiveness <= bestAttractiveness || consideredAttractiveness < powerDecision.MinimumAttractiveness) continue; @@ -881,7 +881,7 @@ namespace OpenRA.Mods.RA.AI return; var unit = buildRandom ? - ChooseRandomUnitToBuild(queue) : + ChooseRandomUnitToBuild(queue) : ChooseUnitToBuild(queue); if (unit != null && Info.UnitsToBuild.Any(u => u.Key == unit.Name)) @@ -914,8 +914,7 @@ namespace OpenRA.Mods.RA.AI { BotDebug("Bot noticed damage {0} {1}->{2}, repairing.", self, e.PreviousDamageState, e.DamageState); - World.IssueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, false) - { TargetActor = self }); + World.IssueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, false) { TargetActor = self }); } } diff --git a/OpenRA.Mods.RA/Activities/LayMines.cs b/OpenRA.Mods.RA/Activities/LayMines.cs index 39f4b0c3ca..e4f49c1820 100644 --- a/OpenRA.Mods.RA/Activities/LayMines.cs +++ b/OpenRA.Mods.RA/Activities/LayMines.cs @@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA.Activities if (ml.Minefield.Length > 0) { // dont get stuck forever here - for (var n = 0; n < 20; n++) + for (var n = 0; n < 20; n++) { var p = ml.Minefield.Random(self.World.SharedRandom); if (ShouldLayMine(self, p)) diff --git a/OpenRA.Mods.RA/Activities/RAHarvesterDockSequence.cs b/OpenRA.Mods.RA/Activities/RAHarvesterDockSequence.cs index 29a8436b3a..edc7271645 100644 --- a/OpenRA.Mods.RA/Activities/RAHarvesterDockSequence.cs +++ b/OpenRA.Mods.RA/Activities/RAHarvesterDockSequence.cs @@ -47,7 +47,8 @@ namespace OpenRA.Mods.RA state = State.Dock; return Util.SequenceActivities(new Turn(self, angle), this); case State.Dock: - ru.PlayCustomAnimation(self, "dock", () => { + ru.PlayCustomAnimation(self, "dock", () => + { ru.PlayCustomAnimRepeating(self, "dock-loop"); if (proc.IsInWorld && !proc.IsDead) foreach (var nd in proc.TraitsImplementing()) diff --git a/OpenRA.Mods.RA/Cloneable.cs b/OpenRA.Mods.RA/Cloneable.cs index ac631135c7..2e6f139b72 100644 --- a/OpenRA.Mods.RA/Cloneable.cs +++ b/OpenRA.Mods.RA/Cloneable.cs @@ -1,12 +1,12 @@ - #region Copyright & License Information - /* +#region Copyright & License Information +/* * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, * see COPYING. */ - #endregion +#endregion using System; using OpenRA.Traits; diff --git a/OpenRA.Mods.RA/Effects/RepairIndicator.cs b/OpenRA.Mods.RA/Effects/RepairIndicator.cs index 57097cefe4..b7d4faa1a9 100644 --- a/OpenRA.Mods.RA/Effects/RepairIndicator.cs +++ b/OpenRA.Mods.RA/Effects/RepairIndicator.cs @@ -38,8 +38,8 @@ namespace OpenRA.Mods.RA.Effects public void Tick(World world) { - if (!building.IsInWorld || building.IsDead || - rb == null || !rb.Repairers.Any()) + if (!building.IsInWorld || building.IsDead || + rb == null || !rb.Repairers.Any()) world.AddFrameEndTask(w => w.Remove(this)); anim.Tick(); @@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Effects return anim.Render(building.CenterPosition, palette); } - void CycleRepairer() + void CycleRepairer() { anim.PlayThen("repair", CycleRepairer); diff --git a/OpenRA.Mods.RA/EjectOnDeath.cs b/OpenRA.Mods.RA/EjectOnDeath.cs index 66217ec229..07062f7def 100644 --- a/OpenRA.Mods.RA/EjectOnDeath.cs +++ b/OpenRA.Mods.RA/EjectOnDeath.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Traits var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(), new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(self.Location) }); - + if (info.AllowUnsuitableCell || IsSuitableCell(self, pilot)) { if (cp.Z > 0) diff --git a/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs b/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs index 8e8a396e3a..169145bd0a 100644 --- a/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs +++ b/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs @@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Graphics public PaletteReference Palette { get { return null; } } public int ZOffset { get { return zOffset; } } public bool IsDecoration { get { return true; } } - + public IRenderable WithScale(float newScale) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps, palette); } public IRenderable WithPalette(PaletteReference newPalette) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps, palette); } public IRenderable WithZOffset(int newOffset) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps, palette); } @@ -81,10 +81,10 @@ namespace OpenRA.Mods.RA.Graphics { var bright = wr.World.Map.SequenceProvider.GetSequence(image, "bright"); var dim = wr.World.Map.SequenceProvider.GetSequence(image, "dim"); - + var source = wr.ScreenPosition(pos); var target = wr.ScreenPosition(pos + length); - + for (var n = 0; n < dimZaps; n++) foreach (var z in DrawZapWandering(wr, source, target, dim, palette)) yield return z; diff --git a/OpenRA.Mods.RA/Lint/CheckMapCordon.cs b/OpenRA.Mods.RA/Lint/CheckMapCordon.cs index cc6ffcf09c..acbe9b6a3d 100644 --- a/OpenRA.Mods.RA/Lint/CheckMapCordon.cs +++ b/OpenRA.Mods.RA/Lint/CheckMapCordon.cs @@ -20,9 +20,9 @@ namespace OpenRA.Mods.RA { if (map.Bounds.Left == 0 || map.Bounds.Top == 0 || map.Bounds.Right == map.MapSize.X || map.Bounds.Bottom == map.MapSize.Y) - emitError("This map does not define a valid cordon.\n" - + "A one cell (or greater) border is required on all four sides " - + "between the playable bounds and the map edges"); + emitError("This map does not define a valid cordon.\n" + + "A one cell (or greater) border is required on all four sides " + + "between the playable bounds and the map edges"); } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/Player/AllyRepair.cs b/OpenRA.Mods.RA/Player/AllyRepair.cs index 801ac91c71..145e9ebeba 100644 --- a/OpenRA.Mods.RA/Player/AllyRepair.cs +++ b/OpenRA.Mods.RA/Player/AllyRepair.cs @@ -12,7 +12,6 @@ using OpenRA.Mods.Common; using OpenRA.Traits; namespace OpenRA.Mods.RA.Traits - { [Desc("Attach this to the player actor to allow building repair by team mates.")] class AllyRepairInfo : TraitInfo { } diff --git a/OpenRA.Mods.RA/Player/PlaceBuilding.cs b/OpenRA.Mods.RA/Player/PlaceBuilding.cs index ad82c867fe..0ab2cc7f3a 100644 --- a/OpenRA.Mods.RA/Player/PlaceBuilding.cs +++ b/OpenRA.Mods.RA/Player/PlaceBuilding.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA if (queue == null) return; - + var buildingInfo = unit.Traits.Get(); if (order.OrderString == "LineBuild") diff --git a/OpenRA.Mods.RA/Player/ProductionQueue.cs b/OpenRA.Mods.RA/Player/ProductionQueue.cs index 36703f01f8..7fafe7f1fb 100644 --- a/OpenRA.Mods.RA/Player/ProductionQueue.cs +++ b/OpenRA.Mods.RA/Player/ProductionQueue.cs @@ -17,8 +17,8 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - [Desc("Attach this to an actor (usually a building) to let it produce units or construct buildings.", - "If one builds another actor of this type, he will get a separate queue to create two actors", + [Desc("Attach this to an actor (usually a building) to let it produce units or construct buildings.", + "If one builds another actor of this type, he will get a separate queue to create two actors", "at the same time. Will only work together with the Production: trait.")] public class ProductionQueueInfo : ITraitInfo { @@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA [Desc("The build time is multiplied with this value on low power.")] public readonly int LowPowerSlowdown = 3; - [Desc("Notification played when production is complete.", + [Desc("Notification played when production is complete.", "The filename of the audio is defined per faction in notifications.yaml.")] public readonly string ReadyAudio = "UnitReady"; @@ -254,70 +254,70 @@ namespace OpenRA.Mods.RA switch (order.OrderString) { - case "StartProduction": - { - var unit = self.World.Map.Rules.Actors[order.TargetString]; - var bi = unit.Traits.Get(); - if (!bi.Queue.Contains(Info.Type)) - return; /* Not built by this queue */ - - var cost = unit.Traits.Contains() ? unit.Traits.Get().Cost : 0; - var time = GetBuildTime(order.TargetString); - - if (BuildableItems().All(b => b.Name != order.TargetString)) - return; /* you can't build that!! */ - - // Check if the player is trying to build more units that they are allowed - var fromLimit = int.MaxValue; - if (bi.BuildLimit > 0) + case "StartProduction": { - var inQueue = queue.Count(pi => pi.Item == order.TargetString); - var owned = self.Owner.World.ActorsWithTrait().Count(a => a.Actor.Info.Name == order.TargetString && a.Actor.Owner == self.Owner); - fromLimit = bi.BuildLimit - (inQueue + owned); + var unit = self.World.Map.Rules.Actors[order.TargetString]; + var bi = unit.Traits.Get(); + if (!bi.Queue.Contains(Info.Type)) + return; /* Not built by this queue */ - if (fromLimit <= 0) - return; - } + var cost = unit.Traits.Contains() ? unit.Traits.Get().Cost : 0; + var time = GetBuildTime(order.TargetString); - var amountToBuild = Math.Min(fromLimit, order.ExtraData); - for (var n = 0; n < amountToBuild; n++) - { - var hasPlayedSound = false; - BeginProduction(new ProductionItem(this, order.TargetString, cost, playerPower, () => self.World.AddFrameEndTask(_ => + if (BuildableItems().All(b => b.Name != order.TargetString)) + return; /* you can't build that!! */ + + // Check if the player is trying to build more units that they are allowed + var fromLimit = int.MaxValue; + if (bi.BuildLimit > 0) { - var isBuilding = unit.Traits.Contains(); - if (isBuilding && !hasPlayedSound) + var inQueue = queue.Count(pi => pi.Item == order.TargetString); + var owned = self.Owner.World.ActorsWithTrait().Count(a => a.Actor.Info.Name == order.TargetString && a.Actor.Owner == self.Owner); + fromLimit = bi.BuildLimit - (inQueue + owned); + + if (fromLimit <= 0) + return; + } + + var amountToBuild = Math.Min(fromLimit, order.ExtraData); + for (var n = 0; n < amountToBuild; n++) + { + var hasPlayedSound = false; + BeginProduction(new ProductionItem(this, order.TargetString, cost, playerPower, () => self.World.AddFrameEndTask(_ => { - hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race); - } - else if (!isBuilding) - { - if (BuildUnit(order.TargetString)) - Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race); - else if (!hasPlayedSound && time > 0) + var isBuilding = unit.Traits.Contains(); + if (isBuilding && !hasPlayedSound) { - hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race); + hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race); } - } - }))); + else if (!isBuilding) + { + if (BuildUnit(order.TargetString)) + Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race); + else if (!hasPlayedSound && time > 0) + { + hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race); + } + } + }))); + } + + break; } - break; - } + case "PauseProduction": + { + if (queue.Count > 0 && queue[0].Item == order.TargetString) + queue[0].Pause(order.ExtraData != 0); - case "PauseProduction": - { - if (queue.Count > 0 && queue[0].Item == order.TargetString) - queue[0].Pause(order.ExtraData != 0); + break; + } - break; - } - - case "CancelProduction": - { - CancelProduction(order.TargetString, order.ExtraData); - break; - } + case "CancelProduction": + { + CancelProduction(order.TargetString, order.ExtraData); + break; + } } } diff --git a/OpenRA.Mods.RA/ProductionQueueFromSelection.cs b/OpenRA.Mods.RA/ProductionQueueFromSelection.cs index f6ab602722..7fd9594c7d 100644 --- a/OpenRA.Mods.RA/ProductionQueueFromSelection.cs +++ b/OpenRA.Mods.RA/ProductionQueueFromSelection.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA // Queue-per-actor var queue = world.Selection.Actors - .Where(a => a.IsInWorld && a.World.LocalPlayer == a.Owner) + .Where(a => a.IsInWorld && a.World.LocalPlayer == a.Owner) .SelectMany(a => a.TraitsImplementing()) .FirstOrDefault(q => q.Enabled); diff --git a/OpenRA.Mods.RA/Repairable.cs b/OpenRA.Mods.RA/Repairable.cs index bf1601829a..3e479e9064 100644 --- a/OpenRA.Mods.RA/Repairable.cs +++ b/OpenRA.Mods.RA/Repairable.cs @@ -40,8 +40,11 @@ namespace OpenRA.Mods.RA.Traits public IEnumerable Orders { - get { yield return new EnterAlliedActorTargeter("Repair", 5, - target => CanRepairAt(target), _ => CanRepair()); } + get + { + yield return new EnterAlliedActorTargeter("Repair", 5, + target => CanRepairAt(target), _ => CanRepair()); + } } public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) diff --git a/OpenRA.Mods.RA/Scripting/Global/ReinforcementsGlobal.cs b/OpenRA.Mods.RA/Scripting/Global/ReinforcementsGlobal.cs index 62376dac6f..c9a7bc7290 100644 --- a/OpenRA.Mods.RA/Scripting/Global/ReinforcementsGlobal.cs +++ b/OpenRA.Mods.RA/Scripting/Global/ReinforcementsGlobal.cs @@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA.Scripting if (af != null) { - actor.QueueActivity(new CallFunc(() => + actor.QueueActivity(new CallFunc(() => { af.Call(actor.ToLuaValue(Context)); af.Dispose(); diff --git a/OpenRA.Mods.RA/Scripting/Properties/PlayerProperties.cs b/OpenRA.Mods.RA/Scripting/Properties/PlayerProperties.cs index 316c912faa..1c2b2f654a 100644 --- a/OpenRA.Mods.RA/Scripting/Properties/PlayerProperties.cs +++ b/OpenRA.Mods.RA/Scripting/Properties/PlayerProperties.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Scripting public class PlayerProperties : ScriptPlayerProperties { public PlayerProperties(ScriptContext context, Player player) - : base(context, player) { } + : base(context, player) { } [Desc("The player's name.")] public string Name { get { return Player.PlayerName; } } diff --git a/OpenRA.Mods.RA/SupportPowers/GrantUpgradePower.cs b/OpenRA.Mods.RA/SupportPowers/GrantUpgradePower.cs index 26a3024a57..e2fccf0b27 100644 --- a/OpenRA.Mods.RA/SupportPowers/GrantUpgradePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/GrantUpgradePower.cs @@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA.Traits { if (!a.Owner.IsAlliedWith(Self.Owner)) return false; - + var um = a.TraitOrDefault(); return um != null && info.Upgrades.Any(u => um.AcceptsUpgrade(a, u)); }); diff --git a/OpenRA.Mods.RA/SupportPowers/NukePower.cs b/OpenRA.Mods.RA/SupportPowers/NukePower.cs index c15a1c1809..a98724e6af 100644 --- a/OpenRA.Mods.RA/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/NukePower.cs @@ -111,7 +111,7 @@ namespace OpenRA.Mods.RA.Traits Info.BeaconPoster, Info.BeaconPosterPalette, () => missile.FractionComplete); - + Action removeBeacon = () => self.World.AddFrameEndTask(w => { w.Remove(beacon); diff --git a/OpenRA.Mods.RA/Traits/Buildings/Bridge.cs b/OpenRA.Mods.RA/Traits/Buildings/Bridge.cs index 1c9e04f3ef..294e113a9c 100644 --- a/OpenRA.Mods.RA/Traits/Buildings/Bridge.cs +++ b/OpenRA.Mods.RA/Traits/Buildings/Bridge.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Traits public readonly string[] ShorePieces = { "br1", "br2" }; public readonly int[] NorthOffset = null; public readonly int[] SouthOffset = null; - + [Desc("The name of the weapon to use when demolishing the bridge")] public readonly string DemolishWeapon = "Demolish"; diff --git a/OpenRA.Mods.RA/Traits/Buildings/ClonesProducedUnits.cs b/OpenRA.Mods.RA/Traits/Buildings/ClonesProducedUnits.cs index ac76896942..d647b5e4f7 100644 --- a/OpenRA.Mods.RA/Traits/Buildings/ClonesProducedUnits.cs +++ b/OpenRA.Mods.RA/Traits/Buildings/ClonesProducedUnits.cs @@ -1,12 +1,12 @@ - #region Copyright & License Information - /* +#region Copyright & License Information +/* * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, * see COPYING. */ - #endregion +#endregion using System; using System.Linq; diff --git a/OpenRA.Mods.RA/Traits/Buildings/Fake.cs b/OpenRA.Mods.RA/Traits/Buildings/Fake.cs index 0df22dca21..f830dff630 100644 --- a/OpenRA.Mods.RA/Traits/Buildings/Fake.cs +++ b/OpenRA.Mods.RA/Traits/Buildings/Fake.cs @@ -18,6 +18,6 @@ namespace OpenRA.Mods.RA.Traits class Fake : ITags { - public IEnumerable GetTags() { yield return TagType.Fake; } + public IEnumerable GetTags() { yield return TagType.Fake; } } } diff --git a/OpenRA.Mods.RA/Traits/Buildings/RepairableBuilding.cs b/OpenRA.Mods.RA/Traits/Buildings/RepairableBuilding.cs index 45eab96a12..c12689a223 100644 --- a/OpenRA.Mods.RA/Traits/Buildings/RepairableBuilding.cs +++ b/OpenRA.Mods.RA/Traits/Buildings/RepairableBuilding.cs @@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA.Traits if (!IsTraitDisabled && self.AppearsFriendlyTo(player.PlayerActor)) { // If the player won't affect the repair, we won't add him - if (!Repairers.Remove(player) && Repairers.Count < Info.RepairBonuses.Length) + if (!Repairers.Remove(player) && Repairers.Count < Info.RepairBonuses.Length) { Repairers.Add(player); Sound.PlayNotification(self.World.Map.Rules, player, "Speech", "Repairing", player.Country.Race); @@ -106,7 +106,7 @@ namespace OpenRA.Mods.RA.Traits } // Bonus is applied after finding players who can pay - + // activePlayers won't cause IndexOutOfRange because we capped the max amount of players // to the length of the array self.InflictDamage(self, -(hpToRepair * Info.RepairBonuses[activePlayers - 1] / 100), null); diff --git a/OpenRA.Mods.RA/Traits/Crates/Crate.cs b/OpenRA.Mods.RA/Traits/Crates/Crate.cs index 64169db8d8..0b6f121e6d 100644 --- a/OpenRA.Mods.RA/Traits/Crates/Crate.cs +++ b/OpenRA.Mods.RA/Traits/Crates/Crate.cs @@ -74,7 +74,8 @@ namespace OpenRA.Mods.RA.Traits { s.First.Activate(crusher); return; - } else + } + else n -= s.Second; } } diff --git a/OpenRA.Mods.RA/Traits/Crates/CrateAction.cs b/OpenRA.Mods.RA/Traits/Crates/CrateAction.cs index 1cc233d171..33688aa06e 100644 --- a/OpenRA.Mods.RA/Traits/Crates/CrateAction.cs +++ b/OpenRA.Mods.RA/Traits/Crates/CrateAction.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Traits [Desc("The earliest time (in ticks) that this crate action can occur on.")] public readonly int TimeDelay = 0; - + [Desc("Only allow this crate action when the collector has these prerequisites")] public readonly string[] Prerequisites = { }; diff --git a/OpenRA.Mods.RA/Traits/Crates/GrantUpgradeCrateAction.cs b/OpenRA.Mods.RA/Traits/Crates/GrantUpgradeCrateAction.cs index 7d91bbd934..9de8b47888 100644 --- a/OpenRA.Mods.RA/Traits/Crates/GrantUpgradeCrateAction.cs +++ b/OpenRA.Mods.RA/Traits/Crates/GrantUpgradeCrateAction.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Traits readonly GrantUpgradeCrateActionInfo info; public GrantUpgradeCrateAction(Actor self, GrantUpgradeCrateActionInfo info) - : base(self, info) + : base(self, info) { this.self = self; this.info = info; diff --git a/OpenRA.Mods.RA/Traits/Harvester.cs b/OpenRA.Mods.RA/Traits/Harvester.cs index c4278f5026..be7a041830 100644 --- a/OpenRA.Mods.RA/Traits/Harvester.cs +++ b/OpenRA.Mods.RA/Traits/Harvester.cs @@ -286,7 +286,7 @@ namespace OpenRA.Mods.RA.Traits idleSmart = true; self.CancelActivity(); - + var mobile = self.Trait(); if (order.TargetLocation != CPos.Zero) { diff --git a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs index ca1aa6a792..2d22c0b542 100644 --- a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs +++ b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Traits public readonly int Percentage = 50; public readonly int Minimum = 500; public readonly string SoundToVictim = "credit1.aud"; - + public object Create(ActorInitializer init) { return new InfiltrateForCash(this); } } @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Traits var toTake = (targetResources.Cash + targetResources.Resources) * info.Percentage / 100; var toGive = Math.Max(toTake, info.Minimum); - + targetResources.TakeCash(toTake); spyResources.GiveCash(toGive); diff --git a/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs index cac8aa729b..5c842e7690 100644 --- a/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs @@ -75,17 +75,17 @@ namespace OpenRA.Mods.RA.Traits using (var se = sourceTiles.GetEnumerator()) using (var de = destTiles.GetEnumerator()) - while (se.MoveNext() && de.MoveNext()) - { - var a = se.Current; - var b = de.Current; + while (se.MoveNext() && de.MoveNext()) + { + var a = se.Current; + var b = de.Current; - if (!Self.Owner.Shroud.IsExplored(a) || !Self.Owner.Shroud.IsExplored(b)) - return false; + if (!Self.Owner.Shroud.IsExplored(a) || !Self.Owner.Shroud.IsExplored(b)) + return false; - if (Self.World.Map.GetTerrainIndex(a) != Self.World.Map.GetTerrainIndex(b)) - return false; - } + if (Self.World.Map.GetTerrainIndex(a) != Self.World.Map.GetTerrainIndex(b)) + return false; + } return true; } @@ -242,7 +242,7 @@ namespace OpenRA.Mods.RA.Traits { var targetCell = unit.Location + (xy - sourceLocation); var canEnter = manager.Self.Owner.Shroud.IsExplored(targetCell) && - unit.Trait().CanChronoshiftTo(unit, targetCell); + unit.Trait().CanChronoshiftTo(unit, targetCell); var tile = canEnter ? validTile : invalidTile; yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(targetCell), WVec.Zero, -511, pal, 1f, true); } diff --git a/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs b/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs index f3eb914de5..86886369ed 100644 --- a/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs +++ b/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs @@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA.Traits public void RefreshGps(Actor atek) { RefreshGranted(); - + foreach (var i in atek.World.ActorsWithTrait()) i.Trait.RefreshGranted(); @@ -92,7 +92,8 @@ namespace OpenRA.Mods.RA.Traits { GpsWatcher owner; - public GpsPower(Actor self, GpsPowerInfo info) : base(self, info) + public GpsPower(Actor self, GpsPowerInfo info) + : base(self, info) { owner = self.Owner.PlayerActor.Trait(); owner.GpsAdd(self); diff --git a/OpenRA.Mods.RA/Traits/TargetableSubmarine.cs b/OpenRA.Mods.RA/Traits/TargetableSubmarine.cs index 2ad7fe589d..1cd01688cc 100644 --- a/OpenRA.Mods.RA/Traits/TargetableSubmarine.cs +++ b/OpenRA.Mods.RA/Traits/TargetableSubmarine.cs @@ -32,8 +32,10 @@ namespace OpenRA.Mods.RA.Traits public override string[] TargetTypes { - get { return cloak.Cloaked ? info.CloakedTargetTypes - : info.TargetTypes; } + get + { + return cloak.Cloaked ? info.CloakedTargetTypes : info.TargetTypes; + } } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/ConnectionLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ConnectionLogic.cs index afedbc8b5e..184012be45 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ConnectionLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ConnectionLogic.cs @@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); }; retryButton.Visible = onRetry != null; - retryButton.OnClick = () => + retryButton.OnClick = () => { var password = passwordField != null && passwordField.IsVisible() ? passwordField.Text : orderManager.Password; diff --git a/OpenRA.Mods.RA/Widgets/Logic/CreditsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/CreditsLogic.cs index 238b96557c..c9b7e7cac5 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/CreditsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/CreditsLogic.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic public class CreditsLogic { [ObjectCreator.UseCtor] - public CreditsLogic(Widget widget, Action onExit) + public CreditsLogic(Widget widget, Action onExit) { var panel = widget.Get("CREDITS_PANEL"); diff --git a/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs index f690fb903e..3e77ac0fdc 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs @@ -76,7 +76,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic dataReceived = i.BytesReceived / (float)(1L << (mag * 10)); dataSuffix = SizeSuffixes[mag]; } - + progressBar.Indeterminate = false; progressBar.Percentage = i.ProgressPercentage; diff --git a/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs index ae92f18f7c..466b4edb0f 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (timer != null) { - timer.GetText = () => + timer.GetText = () => { if (status == null && shouldShowStatus()) return statusText(); diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs index f728a2dc99..841da612d2 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs @@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic ConfirmationDialogs.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, showMenu); }; - Action onSurrender = () => + Action onSurrender = () => { world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); closeMenu(); diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index 0acbd28ffa..2717d86586 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -155,7 +155,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var mapButton = lobby.GetOrNull("CHANGEMAP_BUTTON"); if (mapButton != null) { - mapButton.IsDisabled = configurationDisabled; + mapButton.IsDisabled = configurationDisabled; mapButton.OnClick = () => { var onSelect = new Action(uid => @@ -322,7 +322,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic { allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats; allowCheats.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Cheats.HasValue || configurationDisabled(); - allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command( + allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command( "allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats))); } @@ -629,7 +629,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (Map.Status == MapStatus.Available) { // Maps need to be validated and pre-loaded before they can be accessed - new Thread(_ => + new Thread(_ => { var map = Map; map.CacheRules(); @@ -820,7 +820,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic public Action OnClick; } } - + public class LobbyCountry { public string Name; diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyMapPreviewLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyMapPreviewLogic.cs index 1cfeb634a9..b29842c50f 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyMapPreviewLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyMapPreviewLogic.cs @@ -107,20 +107,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic var statusSearching = progress.GetOrNull("MAP_STATUS_SEARCHING"); if (statusSearching != null) - statusSearching.IsVisible = () => lobby.Map.Status == MapStatus.Searching; + statusSearching.IsVisible = () => lobby.Map.Status == MapStatus.Searching; var statusUnavailable = progress.GetOrNull("MAP_STATUS_UNAVAILABLE"); if (statusUnavailable != null) - statusUnavailable.IsVisible = () => lobby.Map.Status == MapStatus.Unavailable; + statusUnavailable.IsVisible = () => lobby.Map.Status == MapStatus.Unavailable; var statusError = progress.GetOrNull("MAP_STATUS_ERROR"); if (statusError != null) - statusError.IsVisible = () => lobby.Map.Status == MapStatus.DownloadError; + statusError.IsVisible = () => lobby.Map.Status == MapStatus.DownloadError; var statusDownloading = progress.GetOrNull("MAP_STATUS_DOWNLOADING"); if (statusDownloading != null) { - statusDownloading.IsVisible = () => lobby.Map.Status == MapStatus.Downloading; + statusDownloading.IsVisible = () => lobby.Map.Status == MapStatus.Downloading; statusDownloading.GetText = () => { if (lobby.Map.DownloadBytes == 0) diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs index 87f45d5863..45bea6c265 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs @@ -345,7 +345,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic checkBox.IsVisible = () => orderManager.LocalClient.IsAdmin && !skirmishMode; checkBox.IsDisabled = () => false; - Action okPressed = () => + Action okPressed = () => { orderManager.IssueOrder(Order.Command("allow_spectators {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowSpectators))); orderManager.IssueOrders( diff --git a/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs index 16a6c2ca8e..9ede2952d4 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs @@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic { mapfilterInput.TakeKeyboardFocus(); mapfilterInput.OnEscKey = () => - { + { if (mapfilterInput.Text.Length == 0) canceling(); else @@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic EnumerateMaps(onSelect, filter); } - return true; + return true; }; mapfilterInput.OnEnterKey = () => { approving(); return true; }; mapfilterInput.OnTextEdited = () => diff --git a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs index eb598f257f..d316347baf 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs @@ -217,14 +217,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (title != null) { title.GetText = () => game.Name; - title.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : title.TextColor; + title.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : title.TextColor; } var maptitle = item.GetOrNull("MAP"); if (title != null) { maptitle.GetText = () => map.Title; - maptitle.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : maptitle.TextColor; + maptitle.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : maptitle.TextColor; } var players = item.GetOrNull("PLAYERS"); @@ -232,7 +232,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic { players.GetText = () => "{0} / {1}".F(game.Players, game.MaxPlayers) + (game.Spectators > 0 ? " ({0} Spectator{1})".F(game.Spectators, game.Spectators > 1 ? "s" : "") : ""); - players.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : players.TextColor; + players.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : players.TextColor; } var state = item.GetOrNull("STATE"); @@ -254,7 +254,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var cachedServerLocation = LobbyUtils.LookupCountry(game.Address.Split(':')[0]); location.GetText = () => cachedServerLocation; - location.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : location.TextColor; + location.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : location.TextColor; } rows.Add(item); diff --git a/OpenRA.Mods.RA/Widgets/Logic/WorldTooltipLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/WorldTooltipLogic.cs index 41fbcd979f..c5e4fde8fd 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/WorldTooltipLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/WorldTooltipLogic.cs @@ -51,24 +51,24 @@ namespace OpenRA.Mods.RA.Widgets.Logic labelText = "Unexplored Terrain"; break; case WorldTooltipType.Actor: - { - o = viewport.ActorTooltip.Owner; - showOwner = !o.NonCombatant && viewport.ActorTooltip.TooltipInfo.IsOwnerRowVisible; + { + o = viewport.ActorTooltip.Owner; + showOwner = !o.NonCombatant && viewport.ActorTooltip.TooltipInfo.IsOwnerRowVisible; - var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer]; - labelText = viewport.ActorTooltip.TooltipInfo.TooltipForPlayerStance(stance); - break; - } + var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer]; + labelText = viewport.ActorTooltip.TooltipInfo.TooltipForPlayerStance(stance); + break; + } case WorldTooltipType.FrozenActor: - { - o = viewport.FrozenActorTooltip.TooltipOwner; - showOwner = !o.NonCombatant && viewport.FrozenActorTooltip.TooltipInfo.IsOwnerRowVisible; + { + o = viewport.FrozenActorTooltip.TooltipOwner; + showOwner = !o.NonCombatant && viewport.FrozenActorTooltip.TooltipInfo.IsOwnerRowVisible; - var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer]; - labelText = viewport.FrozenActorTooltip.TooltipInfo.TooltipForPlayerStance(stance); - break; - } + var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer]; + labelText = viewport.FrozenActorTooltip.TooltipInfo.TooltipForPlayerStance(stance); + break; + } } var textWidth = font.Measure(labelText).X; diff --git a/OpenRA.Mods.RA/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/ProductionPaletteWidget.cs index 34891ee614..11a5cfe863 100644 --- a/OpenRA.Mods.RA/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.RA/Widgets/ProductionPaletteWidget.cs @@ -295,7 +295,7 @@ namespace OpenRA.Mods.RA.Widgets if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0) overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, Color.White, Color.Black, 1); else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor) - overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, ReadyTextAltColor, Color.Black, 1); + overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, ReadyTextAltColor, Color.Black, 1); } else if (first.Paused) overlayFont.DrawTextWithContrast(HoldText, diff --git a/OpenRA.Mods.RA/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.RA/Widgets/SupportPowersWidget.cs index 98439accff..c7f6df34a2 100644 --- a/OpenRA.Mods.RA/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.RA/Widgets/SupportPowersWidget.cs @@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA.Widgets var oldIconCount = IconCount; IconCount = 0; - + var rb = RenderBounds; foreach (var p in powers) { diff --git a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs index f11f8da7b2..bff9d24413 100644 --- a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs @@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Widgets if (key == ks.ToSelectionKey) return ToSelection(); - + // Put all functions that aren't unit-specific before this line! if (!world.Selection.Actors.Any()) return false; diff --git a/OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs b/OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs index 2444cf0236..b8a70ff217 100644 --- a/OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs +++ b/OpenRA.Mods.TS/Traits/Render/RenderVoxels.cs @@ -55,8 +55,8 @@ namespace OpenRA.Mods.TS.Traits .SelectMany(rvpi => rvpi.RenderPreviewVoxels(init, this, image, orientation, facings, palette)) .ToArray(); - yield return new VoxelPreview(components, WVec.Zero, 0, this.Scale, this.LightPitch, - this.LightYaw, this.LightAmbientColor, this.LightDiffuseColor, body.CameraPitch, + yield return new VoxelPreview(components, WVec.Zero, 0, this.Scale, this.LightPitch, + this.LightYaw, this.LightAmbientColor, this.LightDiffuseColor, body.CameraPitch, palette, init.WorldRenderer.Palette(NormalsPalette), init.WorldRenderer.Palette("shadow")); } } @@ -94,9 +94,10 @@ namespace OpenRA.Mods.TS.Traits initializePalettes = false; } - yield return new VoxelRenderable(components, self.CenterPosition, 0, camera, info.Scale, - lightSource, info.LightAmbientColor, info.LightDiffuseColor, - colorPalette, normalsPalette, shadowPalette); + yield return new VoxelRenderable( + components, self.CenterPosition, 0, camera, info.Scale, + lightSource, info.LightAmbientColor, info.LightDiffuseColor, + colorPalette, normalsPalette, shadowPalette); } public string Image { get { return info.Image ?? self.Info.Name; } } diff --git a/OpenRA.Mods.TS/Traits/Render/WithVoxelBarrel.cs b/OpenRA.Mods.TS/Traits/Render/WithVoxelBarrel.cs index 56ad4d1ba3..8dc157b377 100644 --- a/OpenRA.Mods.TS/Traits/Render/WithVoxelBarrel.cs +++ b/OpenRA.Mods.TS/Traits/Render/WithVoxelBarrel.cs @@ -65,8 +65,8 @@ namespace OpenRA.Mods.TS.Traits var rv = self.Trait(); rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, info.Sequence), - () => BarrelOffset(), () => BarrelRotation(), - () => false, () => 0)); + () => BarrelOffset(), () => BarrelRotation(), + () => false, () => 0)); } WVec BarrelOffset() diff --git a/OpenRA.Mods.TS/Traits/Render/WithVoxelBody.cs b/OpenRA.Mods.TS/Traits/Render/WithVoxelBody.cs index 1b1b915adf..92f9bf34b5 100644 --- a/OpenRA.Mods.TS/Traits/Render/WithVoxelBody.cs +++ b/OpenRA.Mods.TS/Traits/Render/WithVoxelBody.cs @@ -48,8 +48,8 @@ namespace OpenRA.Mods.TS.Traits var voxel = VoxelProvider.GetVoxel(rv.Image, info.Sequence); rv.Add(new VoxelAnimation(voxel, () => WVec.Zero, - () => new[] { body.QuantizeOrientation(self, self.Orientation) }, - () => false, () => 0)); + () => new[] { body.QuantizeOrientation(self, self.Orientation) }, + () => false, () => 0)); // Selection size var rvi = self.Info.Traits.Get(); diff --git a/OpenRA.Mods.TS/Traits/Render/WithVoxelTurret.cs b/OpenRA.Mods.TS/Traits/Render/WithVoxelTurret.cs index a2e17b7070..77b9e0a792 100644 --- a/OpenRA.Mods.TS/Traits/Render/WithVoxelTurret.cs +++ b/OpenRA.Mods.TS/Traits/Render/WithVoxelTurret.cs @@ -57,8 +57,8 @@ namespace OpenRA.Mods.TS.Traits var rv = self.Trait(); rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, info.Sequence), - () => turreted.Position(self), () => TurretRotation(), - () => false, () => 0)); + () => turreted.Position(self), () => TurretRotation(), + () => false, () => 0)); } IEnumerable TurretRotation() diff --git a/OpenRA.Mods.TS/Traits/Render/WithVoxelWalkerBody.cs b/OpenRA.Mods.TS/Traits/Render/WithVoxelWalkerBody.cs index c12506e910..929d9784b7 100644 --- a/OpenRA.Mods.TS/Traits/Render/WithVoxelWalkerBody.cs +++ b/OpenRA.Mods.TS/Traits/Render/WithVoxelWalkerBody.cs @@ -41,8 +41,8 @@ namespace OpenRA.Mods.TS.Traits var voxel = VoxelProvider.GetVoxel(rv.Image, "idle"); frames = voxel.Frames; rv.Add(new VoxelAnimation(voxel, () => WVec.Zero, - () => new[] { body.QuantizeOrientation(self, self.Orientation) }, - () => false, () => frame)); + () => new[] { body.QuantizeOrientation(self, self.Orientation) }, + () => false, () => frame)); // Selection size var rvi = self.Info.Traits.Get(); diff --git a/OpenRA.Renderer.Sdl2/ErrorHandler.cs b/OpenRA.Renderer.Sdl2/ErrorHandler.cs index 6af34a7762..cc3ef0851f 100644 --- a/OpenRA.Renderer.Sdl2/ErrorHandler.cs +++ b/OpenRA.Renderer.Sdl2/ErrorHandler.cs @@ -53,7 +53,7 @@ namespace OpenRA.Renderer.Sdl2 Log.Write("graphics", message); Log.Write("graphics", ""); Log.Write("graphics", "OpenGL Information:"); - Log.Write("graphics", "Vendor: {0}", GL.GetString(StringName.Vendor)); + Log.Write("graphics", "Vendor: {0}", GL.GetString(StringName.Vendor)); if (GL.GetString(StringName.Vendor).Contains("Microsoft")) { var msg = ""; @@ -62,9 +62,9 @@ namespace OpenRA.Renderer.Sdl2 Log.Write("graphics", msg); } - Log.Write("graphics", "Renderer: {0}", GL.GetString(StringName.Renderer)); - Log.Write("graphics", "GL Version: {0}", GL.GetString(StringName.Version)); - Log.Write("graphics", "Shader Version: {0}", GL.GetString(StringName.ShadingLanguageVersion)); + Log.Write("graphics", "Renderer: {0}", GL.GetString(StringName.Renderer)); + Log.Write("graphics", "GL Version: {0}", GL.GetString(StringName.Version)); + Log.Write("graphics", "Shader Version: {0}", GL.GetString(StringName.ShadingLanguageVersion)); Log.Write("graphics", "Available extensions:"); Log.Write("graphics", GL.GetString(StringName.Extensions)); } diff --git a/OpenRA.Renderer.Sdl2/Sdl2Input.cs b/OpenRA.Renderer.Sdl2/Sdl2Input.cs index be609f4064..6f5db16a8a 100644 --- a/OpenRA.Renderer.Sdl2/Sdl2Input.cs +++ b/OpenRA.Renderer.Sdl2/Sdl2Input.cs @@ -55,116 +55,116 @@ namespace OpenRA.Renderer.Sdl2 break; case SDL.SDL_EventType.SDL_WINDOWEVENT: - { - switch (e.window.windowEvent) { - case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST: - Game.HasInputFocus = false; - break; + switch (e.window.windowEvent) + { + case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST: + Game.HasInputFocus = false; + break; - case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED: - Game.HasInputFocus = true; - break; + case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED: + Game.HasInputFocus = true; + break; + } + + break; } - break; - } - case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN: - { - if (pendingMotion != null) { - inputHandler.OnMouseInput(pendingMotion.Value); - pendingMotion = null; + if (pendingMotion != null) + { + inputHandler.OnMouseInput(pendingMotion.Value); + pendingMotion = null; + } + + var button = MakeButton(e.button.button); + lastButtonBits |= button; + + var pos = new int2(e.button.x, e.button.y); + + inputHandler.OnMouseInput(new MouseInput( + MouseInputEvent.Down, button, scrollDelta, pos, mods, + MultiTapDetection.DetectFromMouse(e.button.button, pos))); + + break; } - var button = MakeButton(e.button.button); - lastButtonBits |= button; - - var pos = new int2(e.button.x, e.button.y); - - inputHandler.OnMouseInput(new MouseInput( - MouseInputEvent.Down, button, scrollDelta, pos, mods, - MultiTapDetection.DetectFromMouse(e.button.button, pos))); - - break; - } - case SDL.SDL_EventType.SDL_MOUSEBUTTONUP: - { - if (pendingMotion != null) { - inputHandler.OnMouseInput(pendingMotion.Value); - pendingMotion = null; + if (pendingMotion != null) + { + inputHandler.OnMouseInput(pendingMotion.Value); + pendingMotion = null; + } + + var button = MakeButton(e.button.button); + lastButtonBits &= ~button; + + var pos = new int2(e.button.x, e.button.y); + inputHandler.OnMouseInput(new MouseInput( + MouseInputEvent.Up, button, scrollDelta, pos, mods, + MultiTapDetection.InfoFromMouse(e.button.button))); + + break; } - var button = MakeButton(e.button.button); - lastButtonBits &= ~button; - - var pos = new int2(e.button.x, e.button.y); - inputHandler.OnMouseInput(new MouseInput( - MouseInputEvent.Up, button, scrollDelta, pos, mods, - MultiTapDetection.InfoFromMouse(e.button.button))); - - break; - } - case SDL.SDL_EventType.SDL_MOUSEMOTION: - { - pendingMotion = new MouseInput( - MouseInputEvent.Move, lastButtonBits, scrollDelta, - new int2(e.motion.x, e.motion.y), mods, 0); + { + pendingMotion = new MouseInput( + MouseInputEvent.Move, lastButtonBits, scrollDelta, + new int2(e.motion.x, e.motion.y), mods, 0); - break; - } + break; + } case SDL.SDL_EventType.SDL_MOUSEWHEEL: - { - int x, y; - SDL.SDL_GetMouseState(out x, out y); - scrollDelta = e.wheel.y; - inputHandler.OnMouseInput(new MouseInput(MouseInputEvent.Scroll, MouseButton.None, scrollDelta, new int2(x, y), Modifiers.None, 0)); + { + int x, y; + SDL.SDL_GetMouseState(out x, out y); + scrollDelta = e.wheel.y; + inputHandler.OnMouseInput(new MouseInput(MouseInputEvent.Scroll, MouseButton.None, scrollDelta, new int2(x, y), Modifiers.None, 0)); - break; - } + break; + } case SDL.SDL_EventType.SDL_TEXTINPUT: - { - var rawBytes = new byte[SDL.SDL_TEXTINPUTEVENT_TEXT_SIZE]; - unsafe { Marshal.Copy((IntPtr)e.text.text, rawBytes, 0, SDL.SDL_TEXTINPUTEVENT_TEXT_SIZE); } - inputHandler.OnTextInput(Encoding.UTF8.GetString(rawBytes, 0, Array.IndexOf(rawBytes, (byte)0))); - break; - } + { + var rawBytes = new byte[SDL.SDL_TEXTINPUTEVENT_TEXT_SIZE]; + unsafe { Marshal.Copy((IntPtr)e.text.text, rawBytes, 0, SDL.SDL_TEXTINPUTEVENT_TEXT_SIZE); } + inputHandler.OnTextInput(Encoding.UTF8.GetString(rawBytes, 0, Array.IndexOf(rawBytes, (byte)0))); + break; + } case SDL.SDL_EventType.SDL_KEYDOWN: case SDL.SDL_EventType.SDL_KEYUP: - { - var keyCode = (Keycode)e.key.keysym.sym; - var type = e.type == SDL.SDL_EventType.SDL_KEYDOWN ? - KeyInputEvent.Down : KeyInputEvent.Up; - - var tapCount = e.type == SDL.SDL_EventType.SDL_KEYDOWN ? - MultiTapDetection.DetectFromKeyboard(keyCode) : - MultiTapDetection.InfoFromKeyboard(keyCode); - - var keyEvent = new KeyInput { - Event = type, - Key = keyCode, - Modifiers = mods, - UnicodeChar = (char)e.key.keysym.sym, - MultiTapCount = tapCount - }; + var keyCode = (Keycode)e.key.keysym.sym; + var type = e.type == SDL.SDL_EventType.SDL_KEYDOWN ? + KeyInputEvent.Down : KeyInputEvent.Up; - // Special case workaround for windows users - if (e.key.keysym.sym == SDL.SDL_Keycode.SDLK_F4 && mods.HasModifier(Modifiers.Alt) && - Platform.CurrentPlatform == PlatformType.Windows) - Game.Exit(); - else - inputHandler.OnKeyInput(keyEvent); + var tapCount = e.type == SDL.SDL_EventType.SDL_KEYDOWN ? + MultiTapDetection.DetectFromKeyboard(keyCode) : + MultiTapDetection.InfoFromKeyboard(keyCode); - break; - } + var keyEvent = new KeyInput + { + Event = type, + Key = keyCode, + Modifiers = mods, + UnicodeChar = (char)e.key.keysym.sym, + MultiTapCount = tapCount + }; + + // Special case workaround for windows users + if (e.key.keysym.sym == SDL.SDL_Keycode.SDLK_F4 && mods.HasModifier(Modifiers.Alt) && + Platform.CurrentPlatform == PlatformType.Windows) + Game.Exit(); + else + inputHandler.OnKeyInput(keyEvent); + + break; + } } } diff --git a/OpenRA.Test/OpenRA.Game/OrderTest.cs b/OpenRA.Test/OpenRA.Game/OrderTest.cs index 299089cc23..e30e1a7b39 100644 --- a/OpenRA.Test/OpenRA.Game/OrderTest.cs +++ b/OpenRA.Test/OpenRA.Game/OrderTest.cs @@ -22,14 +22,16 @@ namespace OpenRA.Test [SetUp] public void SetUp() { - order = new Order("TestOrder", null, false) { + order = new Order("TestOrder", null, false) + { TargetString = "TestTarget", TargetLocation = new CPos(1234, 5678), ExtraData = 1234, ExtraLocation = new CPos(555, 555) }; - immediateOrder = new Order("TestOrderImmediate", null, false) { + immediateOrder = new Order("TestOrderImmediate", null, false) + { IsImmediate = true, TargetString = "TestTarget" };