diff --git a/MapConverter/MapConverter.cs b/MapConverter/MapConverter.cs index 6994b1d8ca..42b6bc6f98 100644 --- a/MapConverter/MapConverter.cs +++ b/MapConverter/MapConverter.cs @@ -92,9 +92,10 @@ namespace MapConverter Height = int.Parse(map.GetValue("Height", "0")); MapSize = (INIFormat == 3) ? 128 : 64; - Map.Size.X = MapSize; - Map.Size.Y = MapSize; - Map.Bounds = new int[] {XOffset, YOffset, Width, Height}; + Map.MapSize.X = MapSize; + Map.MapSize.Y = MapSize; + Map.TopLeft = new int2 (XOffset, YOffset); + Map.BottomRight = new int2(XOffset+Width,YOffset+Height); if (INIFormat == 3) // RA map { @@ -184,28 +185,28 @@ namespace MapConverter void UnpackRATileData( MemoryStream ms ) { Map.MapTiles = new TileReference[ MapSize, MapSize ]; - for( int i = 0 ; i < MapSize ; i++ ) - for( int j = 0 ; j < MapSize ; j++ ) - Map.MapTiles[j, i] = new TileReference(); + for( int j = 0 ; j < MapSize ; j++ ) + for( int i = 0 ; i < MapSize ; i++ ) + Map.MapTiles[i,j] = new TileReference(); - for( int i = 0 ; i < MapSize ; i++ ) - for( int j = 0 ; j < MapSize ; j++ ) - Map.MapTiles[j, i].type = ReadWord(ms); + for( int j = 0 ; j < MapSize ; j++ ) + for( int i = 0 ; i < MapSize ; i++ ) + Map.MapTiles[i,j].type = ReadWord(ms); - for( int i = 0 ; i < MapSize ; i++ ) - for( int j = 0 ; j < MapSize ; j++ ) + for( int j = 0 ; j < MapSize ; j++ ) + for( int i = 0 ; i < MapSize ; i++ ) { - Map.MapTiles[j, i].index = (byte)ms.ReadByte(); - if( Map.MapTiles[ j, i ].type == 0xff || Map.MapTiles[ j, i ].type == 0xffff ) - Map.MapTiles[ j, i ].index = byte.MaxValue; + Map.MapTiles[i,j].index = (byte)ms.ReadByte(); + if( Map.MapTiles[i,j].type == 0xff || Map.MapTiles[i,j].type == 0xffff ) + Map.MapTiles[i,j].index = byte.MaxValue; } } void UnpackRAOverlayData( MemoryStream ms ) { Map.MapResources = new TileReference[ MapSize, MapSize ]; - for( int i = 0 ; i < MapSize ; i++ ) - for( int j = 0 ; j < MapSize ; j++ ) + for( int j = 0 ; j < MapSize ; j++ ) + for( int i = 0 ; i < MapSize ; i++ ) { byte o = ReadByte( ms ); var res = Pair.New((byte)0,(byte)0); @@ -213,7 +214,7 @@ namespace MapConverter if (o != 255 && resourceMapping.ContainsKey(raOverlayNames[o])) res = resourceMapping[raOverlayNames[o]]; - Map.MapResources[j, i] = new TileReference(res.First, res.Second); + Map.MapResources[i,j] = new TileReference(res.First, res.Second); } } diff --git a/OpenRA.FileFormats/ConnectedComponents.cs b/OpenRA.FileFormats/ConnectedComponents.cs index c5500ac162..822cba0d98 100644 --- a/OpenRA.FileFormats/ConnectedComponents.cs +++ b/OpenRA.FileFormats/ConnectedComponents.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -30,8 +30,8 @@ namespace OpenRA.FileFormats public static int[,] Extract(Map m, Func f) { - var result = new int[m.MapSize, m.MapSize]; - var types = new int[m.MapSize, m.MapSize]; + var result = new int[m.MapSize.X, m.MapSize.Y]; + var types = new int[m.MapSize.X, m.MapSize.Y]; var d = new Dictionary(); var n = 1; diff --git a/OpenRA.FileFormats/Map/NewMap.cs b/OpenRA.FileFormats/Map/NewMap.cs index c45f2ecdc4..73cb507099 100644 --- a/OpenRA.FileFormats/Map/NewMap.cs +++ b/OpenRA.FileFormats/Map/NewMap.cs @@ -36,7 +36,6 @@ namespace OpenRA.FileFormats public string Author; public int PlayerCount; public string Preview; - public int[] Bounds; public string Tileset; public Dictionary Actors = new Dictionary(); @@ -46,26 +45,25 @@ namespace OpenRA.FileFormats // Binary map data public string Tiledata; public byte TileFormat = 1; - public int2 Size; + public int2 MapSize; + + public int2 TopLeft; + public int2 BottomRight; + public TileReference[ , ] MapTiles; public TileReference[ , ] MapResources; // Temporary compat hacks - public int MapSize {get {return Size.X;}} - public int XOffset {get {return Bounds[0];}} - public int YOffset {get {return Bounds[1];}} - public int2 Offset { get { return new int2( Bounds[0], Bounds[1] ); } } - public int Width {get {return Bounds[2];}} - public int Height {get {return Bounds[3];}} + public int XOffset {get {return TopLeft.X;}} + public int YOffset {get {return TopLeft.Y;}} + public int Width {get {return BottomRight.X-TopLeft.X;}} + public int Height {get {return BottomRight.Y-TopLeft.Y;}} public string Theater {get {return Tileset;}} public IEnumerable SpawnPoints {get {return Waypoints.Select(kv => kv.Value);}} - - - List SimpleFields = new List() { - "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "Tiledata", "Preview", "Size", "Bounds" + "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "Tiledata", "Preview", "MapSize", "TopLeft", "BottomRight" }; public Map() {} @@ -150,26 +148,26 @@ namespace OpenRA.FileFormats // Load header info byte version = ReadByte(dataStream); - Size.X = ReadWord(dataStream); - Size.Y = ReadWord(dataStream); + MapSize.X = ReadWord(dataStream); + MapSize.Y = ReadWord(dataStream); - MapTiles = new TileReference[ Size.X, Size.Y ]; - MapResources = new TileReference[ Size.X, Size.Y ]; + MapTiles = new TileReference[ MapSize.X, MapSize.Y ]; + MapResources = new TileReference[ MapSize.X, MapSize.Y ]; // Load tile data - for( int i = 0 ; i < Size.X ; i++ ) - for( int j = 0 ; j < Size.Y ; j++ ) + for( int i = 0 ; i < MapSize.X ; i++ ) + for( int j = 0 ; j < MapSize.Y ; j++ ) { ushort tile = ReadWord(dataStream); byte index = ReadByte(dataStream); byte image = (index == byte.MaxValue) ? (byte)( i % 4 + ( j % 4 ) * 4 ) : index; - MapTiles[i, j] = new TileReference(tile,index, image); + MapTiles[i,j] = new TileReference(tile,index, image); } // Load resource data - for( int i = 0 ; i < Size.X ; i++ ) - for( int j = 0 ; j < Size.Y ; j++ ) - MapResources[i, j] = new TileReference(ReadByte(dataStream),ReadByte(dataStream)); + for( int i = 0 ; i < MapSize.X ; i++ ) + for( int j = 0 ; j < MapSize.Y ; j++ ) + MapResources[i,j] = new TileReference(ReadByte(dataStream),ReadByte(dataStream)); } public void SaveBinaryData(string filepath) @@ -180,23 +178,23 @@ namespace OpenRA.FileFormats // File header consists of a version byte, followed by 2 ushorts for width and height writer.Write(TileFormat); - writer.Write((ushort)Size.X); - writer.Write((ushort)Size.Y); + writer.Write((ushort)MapSize.X); + writer.Write((ushort)MapSize.Y); // Tile data - for( int i = 0 ; i < Size.X ; i++ ) - for( int j = 0 ; j < Size.Y ; j++ ) + for( int i = 0 ; i < MapSize.X ; i++ ) + for( int j = 0 ; j < MapSize.Y ; j++ ) { - writer.Write( MapTiles[j,i].type ); - writer.Write( MapTiles[ j, i ].index ); + writer.Write( MapTiles[i,j].type ); + writer.Write( MapTiles[i,j].index ); } // Resource data - for( int i = 0 ; i < Size.X ; i++ ) - for( int j = 0 ; j < Size.Y ; j++ ) + for( int i = 0 ; i < MapSize.X ; i++ ) + for( int j = 0 ; j < MapSize.Y ; j++ ) { - writer.Write( MapResources[j,i].type ); - writer.Write( MapResources[j,i].index ); + writer.Write( MapResources[i,j].type ); + writer.Write( MapResources[i,j].index ); } writer.Flush(); @@ -211,7 +209,7 @@ namespace OpenRA.FileFormats public bool IsInMap(int x, int y) { - return (x >= Bounds[0] && y >= Bounds[1] && x < Bounds[0] + Bounds[2] && y < Bounds[1] + Bounds[3]); + return (x >= TopLeft.X && y >= TopLeft.Y && x < BottomRight.X && y < BottomRight.Y); } public void DebugContents() diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index 2c32ae5a25..2c8b59b137 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -317,8 +317,8 @@ namespace OpenRA if (mapPreviewDirty) { - if (mapChooserSheet == null || mapChooserSheet.Size.Width != currentMap.Map.MapSize) - mapChooserSheet = new Sheet(renderer, new Size(currentMap.Map.MapSize, currentMap.Map.MapSize)); + if (mapChooserSheet == null || mapChooserSheet.Size.Width != currentMap.Map.MapSize.X || mapChooserSheet.Size.Height != currentMap.Map.MapSize.Y) + mapChooserSheet = new Sheet(renderer, new Size(currentMap.Map.MapSize.X, currentMap.Map.MapSize.Y)); var b = Minimap.RenderTerrainBitmapWithSpawnPoints(currentMap.Map, Game.world.TileSet); // tileset -> hack mapChooserSheet.Texture.SetData(b); diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 882a5df9d6..791e0dfe9b 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -125,7 +125,7 @@ namespace OpenRA Timer.Time( "world: {0}" ); SequenceProvider.Initialize(manifest.Sequences); - viewport = new Viewport(clientSize, Game.world.Map.Offset, Game.world.Map.Offset + Game.world.Map.Size, renderer); + viewport = new Viewport(clientSize, Game.world.Map.TopLeft, Game.world.Map.BottomRight, renderer); Timer.Time( "ChromeProv, SeqProv, viewport: {0}" ); chrome = new Chrome(renderer, manifest); diff --git a/OpenRA.Game/Graphics/Minimap.cs b/OpenRA.Game/Graphics/Minimap.cs index 5f710ac7be..d45a570c51 100644 --- a/OpenRA.Game/Graphics/Minimap.cs +++ b/OpenRA.Game/Graphics/Minimap.cs @@ -47,8 +47,8 @@ namespace OpenRA.Graphics public Minimap(World world, Renderer r) { this.world = world; - sheet = new Sheet(r, new Size(world.Map.MapSize, world.Map.MapSize)); - mapOnlySheet = new Sheet(r, new Size(world.Map.MapSize, world.Map.MapSize)); + sheet = new Sheet(r, new Size(world.Map.MapSize.X, world.Map.MapSize.Y)); + mapOnlySheet = new Sheet(r, new Size(world.Map.MapSize.X, world.Map.MapSize.Y)); lineRenderer = new LineRenderer(r); rgbaRenderer = new SpriteRenderer(r, true, r.RgbaSpriteShader); @@ -56,7 +56,7 @@ namespace OpenRA.Graphics var dw = (size - world.Map.Width) / 2; var dh = (size - world.Map.Height) / 2; - bounds = new Rectangle(world.Map.Offset.X - dw, world.Map.Offset.Y - dh, size, size); + bounds = new Rectangle(world.Map.TopLeft.X - dw, world.Map.TopLeft.Y - dh, size, size); sprite = new Sprite(sheet, bounds, TextureChannel.Alpha); mapOnlySprite = new Sprite(mapOnlySheet, bounds, TextureChannel.Alpha); @@ -73,7 +73,7 @@ namespace OpenRA.Graphics var dw = (size - m.Width) / 2; var dh = (size - m.Height) / 2; - return new Rectangle(m.Offset.X - dw, m.Offset.Y - dh, size, size); + return new Rectangle(m.TopLeft.X - dw, m.TopLeft.Y - dh, size, size); } static Cache terrainTypeColors = new Cache( @@ -88,9 +88,9 @@ namespace OpenRA.Graphics public static Bitmap RenderTerrainBitmap(Map map, TileSet tileset) { - var terrain = new Bitmap(map.MapSize, map.MapSize); - for (var y = 0; y < map.MapSize; y++) - for (var x = 0; x < map.MapSize; x++) + var terrain = new Bitmap(map.MapSize.X, map.MapSize.Y); + for (var y = 0; y < map.MapSize.Y; y++) + for (var x = 0; x < map.MapSize.X; x++) terrain.SetPixel(x, y, map.IsInMap(x, y) ? Color.FromArgb(alpha, terrainTypeColors[map.Theater].ColorForTerrainType(tileset.GetTerrainType(map.MapTiles[x, y]))) : shroudColor); @@ -117,8 +117,8 @@ namespace OpenRA.Graphics var res = world.WorldActor.traits.Get(); oreLayer = new Bitmap(terrain); - for (var y = world.Map.YOffset; y < world.Map.YOffset + world.Map.Height; y++) - for (var x = world.Map.XOffset; x < world.Map.XOffset + world.Map.Width; x++) + for (var y = world.Map.TopLeft.Y; y < world.Map.BottomRight.Y; y++) + for (var x = world.Map.TopLeft.X; x < world.Map.BottomRight.X; x++) if (res.GetResource(new int2(x,y)) != null) oreLayer.SetPixel(x, y, Color.FromArgb(alpha, terrainTypeColors[world.Map.Theater].ColorForTerrainType(TerrainType.Ore))); } @@ -140,8 +140,8 @@ namespace OpenRA.Graphics *(c + (a.Actor.Location.Y * bitmapData.Stride >> 2) + a.Actor.Location.X) = Color.FromArgb(alpha, a.Actor.Owner.Color).ToArgb(); - for (var y = world.Map.YOffset; y < world.Map.YOffset + world.Map.Height; y++) - for (var x = world.Map.XOffset; x < world.Map.XOffset + world.Map.Width; x++) + for (var y = world.Map.BottomRight.Y; y < world.Map.YOffset + world.Map.BottomRight.Y; y++) + for (var x = world.Map.TopLeft.X; x < world.Map.BottomRight.X; x++) { if (!world.LocalPlayer.Shroud.DisplayOnRadar(x, y)) { diff --git a/OpenRA.Game/Graphics/TerrainRenderer.cs b/OpenRA.Game/Graphics/TerrainRenderer.cs index 6e607c5773..6b86a8546a 100644 --- a/OpenRA.Game/Graphics/TerrainRenderer.cs +++ b/OpenRA.Game/Graphics/TerrainRenderer.cs @@ -50,10 +50,11 @@ namespace OpenRA.Graphics int nv = 0; int ni = 0; - for( int j = map.YOffset ; j < map.YOffset + map.Height ; j++ ) - for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ ) + for( int i = map.TopLeft.X ; i < map.BottomRight.X; i++ ) + for( int j = map.TopLeft.Y ; j < map.BottomRight.Y; j++ ) { - Sprite tile = tileMapping[map.MapTiles[i, j]]; + Log.Write("{0} {1}",i,j); + Sprite tile = tileMapping[map.MapTiles[i, j]]; // TODO: The zero below should explicitly refer to the terrain palette, but this code is called // before the palettes are created Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size); @@ -61,7 +62,7 @@ namespace OpenRA.Graphics ni += 6; } - terrainSheet = tileMapping[map.MapTiles[map.XOffset, map.YOffset]].sheet; + terrainSheet = tileMapping[map.MapTiles[map.TopLeft.X, map.TopLeft.Y]].sheet; vertexBuffer = renderer.Device.CreateVertexBuffer( vertices.Length ); vertexBuffer.SetData( vertices ); diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index af418b34ab..670ff89f45 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -170,11 +170,11 @@ namespace OpenRA.Graphics lineRenderer.DrawLine(a, a + c, Color.Blue, Color.Blue); } - for (var j = 0; j < Game.world.Map.MapSize; + for (var j = 0; j < Game.world.Map.MapSize.Y; j += Game.world.WorldActor.Info.Traits.Get().BinSize) { - lineRenderer.DrawLine(new float2(0, j * 24), new float2(Game.world.Map.MapSize * 24, j * 24), Color.Black, Color.Black); - lineRenderer.DrawLine(new float2(j * 24, 0), new float2(j * 24, Game.world.Map.MapSize * 24), Color.Black, Color.Black); + lineRenderer.DrawLine(new float2(0, j * 24), new float2(Game.world.Map.MapSize.X * 24, j * 24), Color.Black, Color.Black); + lineRenderer.DrawLine(new float2(j * 24, 0), new float2(j * 24, Game.world.Map.MapSize.Y * 24), Color.Black, Color.Black); } } diff --git a/OpenRA.Game/PathFinder.cs b/OpenRA.Game/PathFinder.cs index e1dda7184a..4fbc4fe903 100644 --- a/OpenRA.Game/PathFinder.cs +++ b/OpenRA.Game/PathFinder.cs @@ -38,13 +38,13 @@ namespace OpenRA this.world = world; var map = world.Map; for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++) - passableCost[(int)umt] = new float[map.MapSize, map.MapSize]; - for (int x = 0; x < map.MapSize; x++) - for (int y = 0; y < map.MapSize; y++) - for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++) - passableCost[(int)umt][x, y] = (world.Map.IsInMap(x, y)) + passableCost[(int)umt] = new float[map.MapSize.X, map.MapSize.Y]; + for( int x = 0 ; x < map.MapSize.X ; x++ ) + for( int y = 0 ; y < map.MapSize.Y ; y++ ) + for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++ ) + passableCost[(int)umt][ x, y ] = ( world.Map.IsInMap( x, y ) ) ? (float)Rules.TerrainTypes[world.TileSet.GetTerrainType(world.Map.MapTiles[x, y])] - .GetCost(umt) + .GetCost(umt) : float.PositiveInfinity; } diff --git a/OpenRA.Game/PathSearch.cs b/OpenRA.Game/PathSearch.cs index 59182f94f9..e465facfeb 100755 --- a/OpenRA.Game/PathSearch.cs +++ b/OpenRA.Game/PathSearch.cs @@ -173,9 +173,9 @@ namespace OpenRA static CellInfo[ , ] InitCellInfo() { - var cellInfo = new CellInfo[ Game.world.Map.MapSize, Game.world.Map.MapSize ]; - for( int x = 0 ; x < Game.world.Map.MapSize ; x++ ) - for( int y = 0 ; y < Game.world.Map.MapSize ; y++ ) + var cellInfo = new CellInfo[ Game.world.Map.MapSize.X, Game.world.Map.MapSize.Y ]; + for( int x = 0 ; x < Game.world.Map.MapSize.X ; x++ ) + for( int y = 0 ; y < Game.world.Map.MapSize.Y ; y++ ) cellInfo[ x, y ] = new CellInfo( float.PositiveInfinity, new int2( x, y ), false ); return cellInfo; } diff --git a/OpenRA.Game/ShroudRenderer.cs b/OpenRA.Game/ShroudRenderer.cs index 78ba461704..0c32d136ef 100644 --- a/OpenRA.Game/ShroudRenderer.cs +++ b/OpenRA.Game/ShroudRenderer.cs @@ -44,8 +44,8 @@ namespace OpenRA this.owner = owner; this.map = map; - sprites = new Sprite[map.MapSize, map.MapSize]; - fogSprites = new Sprite[map.MapSize, map.MapSize]; + sprites = new Sprite[map.MapSize.X, map.MapSize.Y]; + fogSprites = new Sprite[map.MapSize.X, map.MapSize.Y]; shroud.Dirty += () => dirty = true; } @@ -135,11 +135,11 @@ namespace OpenRA if (dirty) { dirty = false; - for (int j = map.YOffset; j < map.YOffset + map.Height; j++) - for (int i = map.XOffset; i < map.XOffset + map.Width; i++) + for (int i = map.TopLeft.X; i < map.BottomRight.X; i++) + for (int j = map.TopLeft.Y; j < map.BottomRight.Y; j++) sprites[i, j] = ChooseShroud(i, j); - for (int j = map.YOffset; j < map.YOffset + map.Height; j++) - for (int i = map.XOffset; i < map.XOffset + map.Width; i++) + for (int i = map.TopLeft.X; i < map.BottomRight.X; i++) + for (int j = map.TopLeft.Y; j < map.BottomRight.Y; j++) fogSprites[i, j] = ChooseFog(i, j); } diff --git a/OpenRA.Game/Traits/World/BuildingInfluence.cs b/OpenRA.Game/Traits/World/BuildingInfluence.cs index 3671ad2dc2..45262fc981 100644 --- a/OpenRA.Game/Traits/World/BuildingInfluence.cs +++ b/OpenRA.Game/Traits/World/BuildingInfluence.cs @@ -38,8 +38,8 @@ namespace OpenRA.Traits { map = self.World.Map; - blocked = new bool[map.MapSize, map.MapSize]; - influence = new Actor[map.MapSize, map.MapSize]; + blocked = new bool[map.MapSize.X, map.MapSize.Y]; + influence = new Actor[map.MapSize.X, map.MapSize.Y]; self.World.ActorAdded += a => { if (a.traits.Contains()) diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index dc59e8d0f6..8e3c7dc0ea 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -44,8 +44,8 @@ namespace OpenRA.Traits public Shroud(Actor self, ShroudInfo info) { map = self.World.Map; - visibleCells = new int[map.MapSize, map.MapSize]; - exploredCells = new bool[map.MapSize, map.MapSize]; + visibleCells = new int[map.MapSize.X, map.MapSize.Y]; + exploredCells = new bool[map.MapSize.X, map.MapSize.Y]; self.World.ActorAdded += AddActor; self.World.ActorRemoved += RemoveActor; diff --git a/OpenRA.Game/Traits/World/SpatialBins.cs b/OpenRA.Game/Traits/World/SpatialBins.cs index 432cac2957..f87577e6f0 100644 --- a/OpenRA.Game/Traits/World/SpatialBins.cs +++ b/OpenRA.Game/Traits/World/SpatialBins.cs @@ -20,8 +20,8 @@ namespace OpenRA.Traits public SpatialBins(Actor self, SpatialBinsInfo info) { bins = new List[ - self.World.Map.MapSize / info.BinSize, - self.World.Map.MapSize / info.BinSize]; + self.World.Map.MapSize.X / info.BinSize, + self.World.Map.MapSize.Y / info.BinSize]; scale = Game.CellSize * info.BinSize; } diff --git a/OpenRA.Game/Traits/World/UnitInfluence.cs b/OpenRA.Game/Traits/World/UnitInfluence.cs index 8846ae25a8..005379e348 100644 --- a/OpenRA.Game/Traits/World/UnitInfluence.cs +++ b/OpenRA.Game/Traits/World/UnitInfluence.cs @@ -39,10 +39,9 @@ namespace OpenRA.Traits public UnitInfluence( Actor self ) { map = self.World.Map; - var size = self.World.Map.MapSize; - influence = new List[size, size]; - for (int i = 0; i < size; i++) - for (int j = 0; j < size; j++) + influence = new List[self.World.Map.MapSize.X, self.World.Map.MapSize.Y]; + for (int i = 0; i < self.World.Map.MapSize.X; i++) + for (int j = 0; j < self.World.Map.MapSize.Y; j++) influence[ i, j ] = new List(); self.World.ActorRemoved += a => Remove( a, a.traits.GetOrDefault() ); @@ -77,8 +76,8 @@ namespace OpenRA.Traits [Conditional( "SANITY_CHECKS" )] void SanityCheck( Actor self ) { - for( int y = 0 ; y < self.World.Map.MapSize ; y++ ) - for( int x = 0 ; x < self.World.Map.MapSize ; x++ ) + for( int y = 0 ; y < self.World.Map.MapSize.Y ; y++ ) + for( int x = 0 ; x < self.World.Map.MapSize.X ; x++ ) if( influence[ x, y ] != null ) foreach (var a in influence[ x, y ]) if (!a.traits.Get().OccupiedCells().Contains( new int2( x, y ) ) ) diff --git a/OpenRA.Game/UiOverlay.cs b/OpenRA.Game/UiOverlay.cs index 6cc6152cb8..6d0018adc4 100644 --- a/OpenRA.Game/UiOverlay.cs +++ b/OpenRA.Game/UiOverlay.cs @@ -55,8 +55,8 @@ namespace OpenRA public void Draw( World world ) { if (Game.Settings.UnitDebug) - for (var j = 0; j < world.Map.MapSize; j++) - for (var i = 0; i < world.Map.MapSize; i++) + for (var j = 0; j < world.Map.MapSize.Y; j++) + for (var i = 0; i < world.Map.MapSize.X; i++) if (world.WorldActor.traits.Get().GetUnitsAt(new int2(i, j)).Any()) spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), "terrain"); } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 104e45dbdd..2ffd574fc8 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -79,7 +79,7 @@ namespace OpenRA Timer.Time( "----World.ctor" ); Map = new Map( Game.LobbyInfo.GlobalSettings.Map ); - customTerrain = new ICustomTerrain[Map.MapSize, Map.MapSize]; + customTerrain = new ICustomTerrain[Map.MapSize.X, Map.MapSize.Y]; Timer.Time( "new Map: {0}" ); var theaterInfo = Rules.Info["world"].Traits.WithInterface() diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index 4ce3391662..4326b31134 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -179,8 +179,9 @@ namespace OpenRA static int2 ClampToWorld( this World world, int2 xy ) { - var mapStart = world.Map.Offset; - var mapEnd = world.Map.Offset + world.Map.Size; + var mapStart = world.Map.TopLeft; + // TODO: Revist this and fix properly + var mapEnd = world.Map.BottomRight; if( xy.X < mapStart.X ) xy.X = mapStart.X; if( xy.X > mapEnd.X ) diff --git a/mods/ra/testmap.bin b/mods/ra/testmap.bin index 8bd94fb173..464010b961 100644 Binary files a/mods/ra/testmap.bin and b/mods/ra/testmap.bin differ diff --git a/mods/ra/testmap.yaml b/mods/ra/testmap.yaml index 97daa5c23f..1a4f881c51 100644 --- a/mods/ra/testmap.yaml +++ b/mods/ra/testmap.yaml @@ -1,68 +1,61 @@ MapFormat: 1 -Title: Isle of Fury (6-8) +Title: Middle Mayhem (2) Author: Westwood Studios -PlayerCount: 8 +PlayerCount: 2 -Tileset: TEMPERAT +Tileset: SNOW Tiledata: testmap.bin -Size: 128,128 +MapSize: 128,128 -Bounds: 14,17,96,96 +TopLeft: 27,26 + +BottomRight: 102,91 Actors: - Actor0: TC05 Neutral 93,90 - Actor1: TC04 Neutral 92,92 - Actor2: TC01 Neutral 88,92 - Actor3: T11 Neutral 96,93 - Actor4: T08 Neutral 90,94 - Actor5: MINE Neutral 67,103 - Actor6: MINE Neutral 52,97 - Actor7: MINE Neutral 48,81 - Actor8: TC05 Neutral 59,103 - Actor9: TC01 Neutral 52,102 - Actor10: T08 Neutral 71,97 - Actor11: T08 Neutral 50,94 - Actor12: MINE Neutral 47,78 - Actor13: T14 Neutral 41,52 - Actor14: MINE Neutral 37,44 - Actor15: MINE Neutral 27,52 - Actor16: MINE Neutral 64,79 - Actor17: MINE Neutral 64,62 - Actor18: MINE Neutral 61,24 - Actor19: MINE Neutral 68,27 - Actor20: MINE Neutral 61,35 - Actor21: MINE Neutral 89,50 - Actor22: MINE Neutral 67,98 - Actor23: TC04 Neutral 53,73 - Actor24: TC03 Neutral 81,65 - Actor25: TC04 Neutral 97,41 - Actor26: TC05 Neutral 67,49 - Actor27: TC02 Neutral 53,59 - Actor28: TC03 Neutral 22,51 - Actor29: TC01 Neutral 25,53 - Actor30: TC01 Neutral 47,22 - Actor31: TC02 Neutral 32,36 - Actor32: TC02 Neutral 25,77 - Actor33: TC04 Neutral 28,81 - Actor34: TC02 Neutral 29,87 - Actor35: T08 Neutral 25,81 - Actor36: T08 Neutral 52,59 - Actor37: T08 Neutral 51,57 + Actor0: TC05 Neutral 62,58 + Actor1: TC04 Neutral 64,63 + Actor2: TC03 Neutral 73,60 + Actor3: TC03 Neutral 55,48 + Actor4: TC01 Neutral 58,51 + Actor5: TC01 Neutral 54,68 + Actor6: T17 Neutral 60,68 + Actor7: TC02 Neutral 48,57 + Actor8: TC05 Neutral 68,63 + Actor9: T16 Neutral 71,63 + Actor10: T16 Neutral 70,55 + Actor11: TC01 Neutral 83,57 + Actor12: TC02 Neutral 62,54 + Actor13: T08 Neutral 62,56 + Actor14: T01 Neutral 49,80 + Actor15: TC04 Neutral 50,81 + Actor16: T16 Neutral 53,82 + Actor17: TC02 Neutral 42,79 + Actor18: TC03 Neutral 27,26 + Actor19: T01 Neutral 29,48 + Actor20: T02 Neutral 31,50 + Actor21: T03 Neutral 32,59 + Actor22: TC05 Neutral 56,88 + Actor23: TC03 Neutral 54,89 + Actor24: T16 Neutral 56,89 + Actor25: T15 Neutral 52,89 + Actor26: T14 Neutral 64,78 + Actor27: TC01 Neutral 27,44 + Actor28: TC01 Neutral 45,39 + Actor29: T17 Neutral 76,26 + Actor30: MINE Neutral 68,53 + Actor31: MINE Neutral 54,57 + Actor32: MINE Neutral 53,65 + Actor33: MINE Neutral 65,68 + Actor34: MINE Neutral 80,61 Waypoints: - spawn0: 87,100 - spawn1: 36,75 - spawn2: 92,29 - spawn3: 31,30 - spawn4: 61,54 - spawn5: 91,63 - spawn6: 34,97 - spawn7: 63,83 + spawn0: 34,84 + spawn1: 35,34 Rules: