diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index c9c26ee454..64fc1f1706 100755 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -505,8 +505,8 @@ namespace OpenRA.Editor } e.Graphics.DrawRectangle(CordonPen, - Map.XOffset * TileSet.TileSize * Zoom + Offset.X, - Map.YOffset * TileSet.TileSize * Zoom + Offset.Y, + Map.TopLeft.X * TileSet.TileSize * Zoom + Offset.X, + Map.TopLeft.Y * TileSet.TileSize * Zoom + Offset.Y, Map.Width * TileSet.TileSize * Zoom, Map.Height * TileSet.TileSize * Zoom); diff --git a/OpenRA.Game/Graphics/TerrainRenderer.cs b/OpenRA.Game/Graphics/TerrainRenderer.cs index f48fcec8ab..12edd8865c 100644 --- a/OpenRA.Game/Graphics/TerrainRenderer.cs +++ b/OpenRA.Game/Graphics/TerrainRenderer.cs @@ -69,7 +69,7 @@ namespace OpenRA.Graphics int visibleRows = (int)(viewport.Height * 1f / Game.CellSize + 2); - int firstRow = (int)(viewport.Location.Y * 1f / Game.CellSize - map.YOffset); + int firstRow = (int)(viewport.Location.Y * 1f / Game.CellSize - map.TopLeft.Y); int lastRow = firstRow + visibleRows; if (lastRow < 0 || firstRow > map.Height) @@ -81,11 +81,11 @@ namespace OpenRA.Graphics if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.Bounds.HasValue) { var r = world.LocalPlayer.Shroud.Bounds.Value; - if (firstRow < r.Top - map.YOffset) - firstRow = r.Top - map.YOffset; + if (firstRow < r.Top - map.TopLeft.Y) + firstRow = r.Top - map.TopLeft.Y; - if (firstRow > r.Bottom - map.YOffset) - firstRow = r.Bottom - map.YOffset; + if (firstRow > r.Bottom - map.TopLeft.Y) + firstRow = r.Bottom - map.TopLeft.Y; } if( lastRow < firstRow ) lastRow = firstRow; diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index 02197fc354..3b0ce4a9fd 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -50,8 +50,6 @@ namespace OpenRA public string [,] CustomTerrain; // Temporary compat hacks - public int XOffset { get { return TopLeft.X; } } - public int YOffset { get { return TopLeft.Y; } } public Rectangle Bounds { get { return Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y); } } public Map() diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index fbeba21bdb..80bd95caf9 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.cs @@ -67,8 +67,8 @@ namespace OpenRA.Traits var map = w.Map; - for (int x = map.XOffset; x < map.XOffset + map.Width; x++) - for (int y = map.YOffset; y < map.YOffset + map.Height; y++) + for (int x = map.TopLeft.X; x < map.BottomRight.X; x++) + for (int y = map.TopLeft.Y; y < map.BottomRight.Y; y++) { // Todo: Valid terrain should be specified in the resource if (!AllowResourceAt(new int2(x,y))) @@ -80,8 +80,8 @@ namespace OpenRA.Traits content[x, y].image = ChooseContent(content[x, y].type); } - for (int x = map.XOffset; x < map.XOffset + map.Width; x++) - for (int y = map.YOffset; y < map.YOffset + map.Height; y++) + for (int x = map.TopLeft.X; x < map.BottomRight.X; x++) + for (int y = map.TopLeft.Y; y < map.BottomRight.Y; y++) if (content[x, y].type != null) { content[x, y].density = GetIdealDensity(x, y); diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index a66045ded6..a4d942e0c5 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -48,10 +48,10 @@ namespace OpenRA.Traits { var min = a - new int2(r, r); var max = a + new int2(r, r); - if (min.X < world.Map.XOffset - 1) min.X = world.Map.XOffset - 1; - if (min.Y < world.Map.YOffset - 1) min.Y = world.Map.YOffset - 1; - if (max.X > world.Map.XOffset + world.Map.Width) max.X = world.Map.XOffset + world.Map.Width; - if (max.Y > world.Map.YOffset + world.Map.Height) max.Y = world.Map.YOffset + world.Map.Height; + if (min.X < world.Map.TopLeft.X - 1) min.X = world.Map.TopLeft.X - 1; + if (min.Y < world.Map.TopLeft.Y - 1) min.Y = world.Map.TopLeft.Y - 1; + if (max.X > world.Map.BottomRight.X) max.X = world.Map.BottomRight.X; + if (max.Y > world.Map.BottomRight.Y) max.Y = world.Map.BottomRight.Y; for (var j = min.Y; j <= max.Y; j++) for (var i = min.X; i <= max.X; i++) diff --git a/OpenRA.Game/Traits/World/SpatialBins.cs b/OpenRA.Game/Traits/World/SpatialBins.cs index 970be709b1..5033daa160 100644 --- a/OpenRA.Game/Traits/World/SpatialBins.cs +++ b/OpenRA.Game/Traits/World/SpatialBins.cs @@ -49,10 +49,10 @@ namespace OpenRA.Traits { var bounds = a.Actor.GetBounds(true); - if (bounds.Right <= Game.CellSize * self.World.Map.XOffset) continue; - if (bounds.Bottom <= Game.CellSize * self.World.Map.YOffset) continue; - if (bounds.Left >= Game.CellSize * (self.World.Map.XOffset + self.World.Map.Width)) continue; - if (bounds.Top >= Game.CellSize * (self.World.Map.YOffset + self.World.Map.Height)) continue; + if (bounds.Right <= Game.CellSize * self.World.Map.TopLeft.X) continue; + if (bounds.Bottom <= Game.CellSize * self.World.Map.TopLeft.Y) continue; + if (bounds.Left >= Game.CellSize * self.World.Map.BottomRight.X) continue; + if (bounds.Top >= Game.CellSize * self.World.Map.BottomRight.Y) continue; var i1 = Math.Max(0, (int)bounds.Left / scale); var i2 = Math.Min(bins.GetUpperBound(0), (int)bounds.Right / scale); diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index 0baee936d2..1dd96ca515 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -54,10 +54,10 @@ namespace OpenRA { var min = a - new int2(r, r); var max = a + new int2(r, r); - if (min.X < world.Map.XOffset) min.X = world.Map.XOffset; - if (min.Y < world.Map.YOffset) min.Y = world.Map.YOffset; - if (max.X > world.Map.XOffset + world.Map.Width - 1) max.X = world.Map.XOffset + world.Map.Width - 1; - if (max.Y > world.Map.YOffset + world.Map.Height - 1) max.Y = world.Map.YOffset + world.Map.Height - 1; + if (min.X < world.Map.TopLeft.X) min.X = world.Map.TopLeft.X; + if (min.Y < world.Map.TopLeft.Y) min.Y = world.Map.TopLeft.Y; + if (max.X > world.Map.BottomRight.X - 1) max.X = world.Map.BottomRight.X - 1; + if (max.Y > world.Map.BottomRight.Y - 1) max.Y = world.Map.BottomRight.Y - 1; for (var j = min.Y; j <= max.Y; j++) for (var i = min.X; i <= max.X; i++) @@ -103,17 +103,17 @@ namespace OpenRA var edge = w.SharedRandom.Next(2) == 0; return new int2( - isX ? w.SharedRandom.Next(w.Map.XOffset, w.Map.XOffset + w.Map.Width) - : (edge ? w.Map.XOffset : w.Map.XOffset + w.Map.Width), - !isX ? w.SharedRandom.Next(w.Map.YOffset, w.Map.YOffset + w.Map.Height) - : (edge ? w.Map.YOffset : w.Map.YOffset + w.Map.Height)); + isX ? w.SharedRandom.Next(w.Map.TopLeft.X, w.Map.BottomRight.X) + : (edge ? w.Map.TopLeft.X : w.Map.BottomRight.X), + !isX ? w.SharedRandom.Next(w.Map.TopLeft.Y, w.Map.BottomRight.Y) + : (edge ? w.Map.TopLeft.Y : w.Map.BottomRight.Y)); } public static int2 ChooseRandomCell(this World w, Thirdparty.Random r) { return new int2( - r.Next(w.Map.XOffset, w.Map.XOffset + w.Map.Width), - r.Next(w.Map.YOffset, w.Map.YOffset + w.Map.Height)); + r.Next(w.Map.TopLeft.X, w.Map.BottomRight.X), + r.Next(w.Map.TopLeft.Y, w.Map.BottomRight.Y)); } public static IEnumerable GetCountries(this World w) diff --git a/OpenRA.Mods.Cnc/ProductionAirdrop.cs b/OpenRA.Mods.Cnc/ProductionAirdrop.cs index 137e0f6bc7..2189457016 100644 --- a/OpenRA.Mods.Cnc/ProductionAirdrop.cs +++ b/OpenRA.Mods.Cnc/ProductionAirdrop.cs @@ -33,8 +33,8 @@ namespace OpenRA.Mods.Cnc var owner = self.Owner; // Start and end beyond the edge of the map, to give a finite delay, and ability to land when AFLD is on map edge - var startPos = new int2(owner.World.Map.XOffset + owner.World.Map.Width+5, self.Location.Y); - var endPos = new int2(owner.World.Map.XOffset-5, self.Location.Y); + var startPos = new int2(owner.World.Map.BottomRight.X + 5, self.Location.Y); + var endPos = new int2(owner.World.Map.TopLeft.X - 5, self.Location.Y); // Assume a single exit point for simplicity var exit = self.Info.Traits.WithInterface().First();