From 37c02fea793ca321992c110b892bb23712ad83f1 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 20 Jul 2013 14:02:44 +1200 Subject: [PATCH] Remove PPos overload of FindUnits. --- OpenRA.Game/Graphics/WorldRenderer.cs | 4 ++-- OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs | 2 +- OpenRA.Game/WorldUtils.cs | 9 +++------ OpenRA.Mods.RA/Activities/Rearm.cs | 2 +- OpenRA.Mods.RA/Air/Aircraft.cs | 2 +- OpenRA.Mods.RA/Combat.cs | 2 +- OpenRA.Mods.RA/Render/RenderBuildingWall.cs | 3 ++- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 5d46f60a08..74a153c484 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -74,8 +74,8 @@ namespace OpenRA.Graphics var comparer = new RenderableComparer(this); var actors = world.FindUnits( - bounds.TopLeftAsCPos().ToPPos(), - bounds.BottomRightAsCPos().ToPPos()); + bounds.TopLeftAsCPos(), + bounds.BottomRightAsCPos()); var worldRenderables = actors.SelectMany(a => a.Render(this)) .OrderBy(r => r, comparer); diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index 2c243507fe..2ca5420220 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -185,7 +185,7 @@ namespace OpenRA.Widgets static readonly Actor[] NoActors = {}; IEnumerable SelectActorsInBox(World world, PPos a, PPos b, Func cond) { - return world.FindUnits(a, b) + return world.FindUnits(a.ToWPos(0), b.ToWPos(0)) .Where(x => x.HasTrait() && x.Trait().Info.Selectable && !world.FogObscures(x) && cond(x)) .GroupBy(x => x.GetSelectionPriority()) .OrderByDescending(g => g.Key) diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index b369857a74..02a14770a2 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -23,7 +23,7 @@ namespace OpenRA { public static IEnumerable FindUnitsAtMouse(this World world, int2 mouseLocation) { - var loc = Game.viewport.ViewToWorldPx(mouseLocation); + var loc = Game.viewport.ViewToWorldPx(mouseLocation).ToWPos(0); return FindUnits(world, loc, loc).Where(a => !world.FogObscures(a)); } @@ -34,11 +34,8 @@ namespace OpenRA public static IEnumerable FindUnits(this World world, WPos tl, WPos br) { - return world.FindUnits(PPos.FromWPos(tl), PPos.FromWPos(br)); - } - - public static IEnumerable FindUnits(this World world, PPos a, PPos b) - { + var a = PPos.FromWPos(tl); + var b = PPos.FromWPos(br); var u = PPos.Min(a, b); var v = PPos.Max(a, b); return world.WorldActor.Trait().ActorsInBox(u,v); diff --git a/OpenRA.Mods.RA/Activities/Rearm.cs b/OpenRA.Mods.RA/Activities/Rearm.cs index dfca5d2d51..e2fc44356b 100644 --- a/OpenRA.Mods.RA/Activities/Rearm.cs +++ b/OpenRA.Mods.RA/Activities/Rearm.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Activities { if (!limitedAmmo.GiveAmmo()) return NextActivity; - var hostBuilding = self.World.FindUnits(self.CenterLocation, self.CenterLocation) + var hostBuilding = self.World.FindUnits(self.CenterPosition, self.CenterPosition) .FirstOrDefault(a => a.HasTrait()); if (hostBuilding != null) diff --git a/OpenRA.Mods.RA/Air/Aircraft.cs b/OpenRA.Mods.RA/Air/Aircraft.cs index 0cb4bed6db..935ea85104 100755 --- a/OpenRA.Mods.RA/Air/Aircraft.cs +++ b/OpenRA.Mods.RA/Air/Aircraft.cs @@ -80,7 +80,7 @@ namespace OpenRA.Mods.RA.Air if (self.Trait().Altitude != 0) return null; // not on the ground. - return self.World.FindUnits(self.CenterLocation, self.CenterLocation) + return self.World.FindUnits(self.CenterPosition, self.CenterPosition) .FirstOrDefault( a => a.HasTrait() ); } diff --git a/OpenRA.Mods.RA/Combat.cs b/OpenRA.Mods.RA/Combat.cs index 19adf9f5a0..aa6b4b2c11 100755 --- a/OpenRA.Mods.RA/Combat.cs +++ b/OpenRA.Mods.RA/Combat.cs @@ -118,7 +118,7 @@ namespace OpenRA.Mods.RA case DamageModel.PerCell: { foreach (var t in world.FindTilesInCircle(targetTile, warhead.Size[0])) - foreach (var unit in world.FindUnits(t.ToPPos(), (t + new CVec(1,1)).ToPPos())) + foreach (var unit in world.FindUnits(t, t)) unit.InflictDamage(args.firedBy, (int)(warhead.Damage * warhead.EffectivenessAgainst(unit)), warhead); } break; diff --git a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs index 9c1ef77965..747fe68ae9 100644 --- a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs @@ -47,7 +47,8 @@ namespace OpenRA.Mods.RA.Render if (!hasTicked) { - var adjWalls = self.World.FindUnits(self.CenterLocation - PVecInt.OneCell, self.CenterLocation + PVecInt.OneCell) + var vec = new CVec(1, 1); + var adjWalls = self.World.FindUnits(self.Location - vec, self.Location + vec) .Where(a => a.Info == self.Info && a != self); foreach (var w in adjWalls)