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.
This commit is contained in:
RoosterDragon
2015-01-04 22:09:32 +00:00
parent 6468c0b6e6
commit a6cda967c2
153 changed files with 740 additions and 698 deletions

View File

@@ -334,7 +334,8 @@ 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,
return new CPos(
(vX + TileSetRenderer.TileSize - 1) / TileSetRenderer.TileSize,
(vY + TileSetRenderer.TileSize - 1) / TileSetRenderer.TileSize);
}

View File

@@ -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)--;
}
}
}

View File

@@ -92,7 +92,8 @@ namespace OpenRA
if (constructOrderCache != null)
return constructOrderCache;
var source = Traits.WithInterface<ITraitInfo>().Select(i => new {
var source = Traits.WithInterface<ITraitInfo>().Select(i => new
{
Trait = i,
Type = i.GetType(),
Dependencies = PrerequisitesOf(i).ToList()

View File

@@ -77,7 +77,8 @@ namespace OpenRA.Graphics
shader.SetMatrix("View", view);
}
public VoxelRenderProxy RenderAsync(WorldRenderer wr, IEnumerable<VoxelAnimation> voxels, WRot camera, float scale,
public VoxelRenderProxy RenderAsync(
WorldRenderer wr, IEnumerable<VoxelAnimation> voxels, WRot camera, float scale,
float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
{
@@ -249,13 +250,15 @@ namespace OpenRA.Graphics
return tVec;
}
void Render(VoxelRenderData renderData,
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,
shader.SetVec("PaletteRows",
(colorPalette + 0.5f) / HardwarePalette.MaxPalettes,
(normalsPalette + 0.5f) / HardwarePalette.MaxPalettes);
shader.SetMatrix("TransformMatrix", t);
shader.SetVec("LightDirection", lightDirection, 4);

View File

@@ -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(", ")));

View File

@@ -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); }

View File

@@ -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()
{

View File

@@ -101,8 +101,7 @@ namespace OpenRA.Widgets
public void ShowDropDown<T>(string panelTemplate, int maxHeight, IEnumerable<T> options, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem)
{
var substitutions = new Dictionary<string, int>() { { "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<ScrollItemWidget>("TEMPLATE");
panel.RemoveChildren();
@@ -124,8 +123,7 @@ namespace OpenRA.Widgets
public void ShowDropDown<T>(string panelTemplate, int height, Dictionary<string, IEnumerable<T>> groups, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem)
{
var substitutions = new Dictionary<string, int>() { { "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<ScrollItemWidget>("HEADER");
var itemTemplate = panel.Get<ScrollItemWidget>("TEMPLATE");

View File

@@ -268,7 +268,8 @@ namespace OpenRA.Widgets
Bounds.Width - LeftMargin - RightMargin, Bounds.Bottom));
}
var color = disabled ? TextColorDisabled
var color =
disabled ? TextColorDisabled
: IsValid() ? TextColor
: TextColorInvalid;
font.DrawText(apparentText, textPos, color);

View File

@@ -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<INotifyDocking>())

View File

@@ -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));

View File

@@ -32,7 +32,8 @@ namespace OpenRA.Mods.Common.Graphics
// Generated at render-time
VoxelRenderProxy renderProxy;
public VoxelRenderable(IEnumerable<VoxelAnimation> voxels, WPos pos, int zOffset, WRot camera, float scale,
public VoxelRenderable(
IEnumerable<VoxelAnimation> voxels, WPos pos, int zOffset, WRot camera, float scale,
WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
PaletteReference color, PaletteReference normals, PaletteReference shadow)
{
@@ -58,28 +59,32 @@ namespace OpenRA.Mods.Common.Graphics
public IRenderable WithScale(float newScale)
{
return new VoxelRenderable(voxels, pos, zOffset, camera, newScale,
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,
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,
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,
return new VoxelRenderable(
voxels, pos + vec, zOffset, camera, scale,
lightSource, lightAmbientColor, lightDiffuseColor,
palette, normalsPalette, shadowPalette);
}

View File

@@ -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<SpawnMapActors>();

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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)

View File

@@ -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;
}
}
}
}

View File

@@ -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)

View File

@@ -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));

View File

@@ -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

View File

@@ -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;

View File

@@ -96,7 +96,8 @@ namespace OpenRA.Mods.Common.Widgets
}
}
else
Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, (int)float2.Lerp(b.Bottom, b.Top, providedFrac),
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;

View File

@@ -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 });
}
}

View File

@@ -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<INotifyDocking>())

View File

@@ -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;

View File

@@ -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<AllyRepair> { }

View File

@@ -40,8 +40,11 @@ namespace OpenRA.Mods.RA.Traits
public IEnumerable<IOrderTargeter> Orders
{
get { yield return new EnterAlliedActorTargeter<Building>("Repair", 5,
target => CanRepairAt(target), _ => CanRepair()); }
get
{
yield return new EnterAlliedActorTargeter<Building>("Repair", 5,
target => CanRepairAt(target), _ => CanRepair());
}
}
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)

View File

@@ -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;

View File

@@ -74,7 +74,8 @@ namespace OpenRA.Mods.RA.Traits
{
s.First.Activate(crusher);
return;
} else
}
else
n -= s.Second;
}
}

View File

@@ -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<GpsWatcher>();
owner.GpsAdd(self);

View File

@@ -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;
}
}
}
}

View File

@@ -94,7 +94,8 @@ namespace OpenRA.Mods.TS.Traits
initializePalettes = false;
}
yield return new VoxelRenderable(components, self.CenterPosition, 0, camera, info.Scale,
yield return new VoxelRenderable(
components, self.CenterPosition, 0, camera, info.Scale,
lightSource, info.LightAmbientColor, info.LightDiffuseColor,
colorPalette, normalsPalette, shadowPalette);
}

View File

@@ -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"
};