diff --git a/OpenRA.Game/Graphics/TerrainSpriteLayer.cs b/OpenRA.Game/Graphics/TerrainSpriteLayer.cs index aef71e7a43..84dece7838 100644 --- a/OpenRA.Game/Graphics/TerrainSpriteLayer.cs +++ b/OpenRA.Game/Graphics/TerrainSpriteLayer.cs @@ -49,23 +49,23 @@ namespace OpenRA.Graphics BlendMode = blendMode; map = world.Map; - vertexRowStride = 4 * map.MapSize.X; - vertices = new Vertex[vertexRowStride * map.MapSize.Y]; + vertexRowStride = 4 * map.MapSize.Width; + vertices = new Vertex[vertexRowStride * map.MapSize.Height]; vertexBuffer = Game.Renderer.Context.CreateEmptyVertexBuffer(vertices.Length); - indexRowStride = 6 * map.MapSize.X; + indexRowStride = 6 * map.MapSize.Width; lock (IndexBuffers) { indexBufferWrapper = IndexBuffers.GetValue(world, world => new IndexBufferRc(world)); indexBufferWrapper.AddRef(); } - palettes = new PaletteReference[map.MapSize.X * map.MapSize.Y]; + palettes = new PaletteReference[map.MapSize.Width * map.MapSize.Height]; wr.PaletteInvalidated += UpdatePaletteIndices; if (wr.TerrainLighting != null) { - ignoreTint = new bool[vertexRowStride * map.MapSize.Y]; + ignoreTint = new bool[vertexRowStride * map.MapSize.Height]; wr.TerrainLighting.CellChanged += UpdateTint; } } @@ -80,7 +80,7 @@ namespace OpenRA.Graphics vertices[i] = new Vertex(v.X, v.Y, v.Z, v.S, v.T, v.U, v.V, c, v.R, v.G, v.B, v.A); } - for (var row = 0; row < map.MapSize.Y; row++) + for (var row = 0; row < map.MapSize.Height; row++) dirtyRows.Add(row); } @@ -193,7 +193,7 @@ namespace OpenRA.Graphics var offset = vertexRowStride * uv.V + 4 * uv.U; Util.FastCreateQuad(vertices, pos, sprite, samplers, palette?.TextureIndex ?? 0, offset, scale * sprite.Size, alpha * float3.Ones, alpha); - palettes[uv.V * map.MapSize.X + uv.U] = palette; + palettes[uv.V * map.MapSize.Width + uv.U] = palette; if (worldRenderer.TerrainLighting != null) { @@ -209,8 +209,8 @@ namespace OpenRA.Graphics var cells = restrictToBounds ? viewport.VisibleCellsInsideBounds : viewport.AllVisibleCells; // Only draw the rows that are visible. - var firstRow = cells.CandidateMapCoords.TopLeft.V.Clamp(0, map.MapSize.Y); - var lastRow = (cells.CandidateMapCoords.BottomRight.V + 1).Clamp(firstRow, map.MapSize.Y); + var firstRow = cells.CandidateMapCoords.TopLeft.V.Clamp(0, map.MapSize.Height); + var lastRow = (cells.CandidateMapCoords.BottomRight.V + 1).Clamp(firstRow, map.MapSize.Height); Game.Renderer.Flush(); @@ -250,7 +250,8 @@ namespace OpenRA.Graphics public IndexBufferRc(World world) { - Buffer = Game.Renderer.Context.CreateIndexBuffer(Util.CreateQuadIndices(world.Map.MapSize.X * world.Map.MapSize.Y)); + Buffer = Game.Renderer.Context.CreateIndexBuffer( + Util.CreateQuadIndices(world.Map.MapSize.Width * world.Map.MapSize.Height)); } public void AddRef() { count++; } diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index d1ce3f2023..7ca7619f3e 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -155,8 +155,8 @@ namespace OpenRA.Graphics if (wr.World.Type == WorldType.Editor) { // The full map is visible in the editor - var width = map.MapSize.X * tileSize.Width; - var height = map.MapSize.Y * tileSize.Height; + var width = map.MapSize.Width * tileSize.Width; + var height = map.MapSize.Height * tileSize.Height; if (wr.World.Map.Grid.Type == MapGridType.RectangularIsometric) height /= 2; diff --git a/OpenRA.Game/Map/CellLayerBase.cs b/OpenRA.Game/Map/CellLayerBase.cs index 00ce5d7c13..b2f34041bc 100644 --- a/OpenRA.Game/Map/CellLayerBase.cs +++ b/OpenRA.Game/Map/CellLayerBase.cs @@ -25,7 +25,7 @@ namespace OpenRA protected readonly Rectangle Bounds; protected CellLayerBase(Map map) - : this(map.Grid.Type, new Size(map.MapSize.X, map.MapSize.Y)) { } + : this(map.Grid.Type, map.MapSize) { } protected CellLayerBase(MapGridType gridType, Size size) { diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 937a2dc2ab..d5ab941116 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -32,12 +32,12 @@ namespace OpenRA public readonly uint HeightsOffset; public readonly uint ResourcesOffset; - public BinaryDataHeader(Stream s, int2 expectedSize) + public BinaryDataHeader(Stream s, Size expectedSize) { Format = s.ReadUInt8(); var width = s.ReadUInt16(); var height = s.ReadUInt16(); - if (width != expectedSize.X || height != expectedSize.Y) + if (width != expectedSize.Width || height != expectedSize.Height) throw new InvalidDataException("Invalid tile data"); if (Format == 1) @@ -194,7 +194,7 @@ namespace OpenRA public MapVisibility Visibility = MapVisibility.Lobby; public string[] Categories = ["Conquest"]; - public int2 MapSize { get; private set; } + public Size MapSize { get; private set; } // Player and actor yaml. Public for access by the map importers and lint checks. public IReadOnlyCollection PlayerDefinitions = []; @@ -320,26 +320,25 @@ namespace OpenRA /// Initializes a new map created by the editor or importer. /// The map will not receive a valid UID until after it has been saved and reloaded. /// - public Map(ModData modData, ITerrainInfo terrainInfo, int width, int height) + public Map(ModData modData, ITerrainInfo terrainInfo, Size size) { this.modData = modData; - var size = new Size(width, height); + MapSize = size; Grid = modData.Manifest.Get(); Title = "Name your map here"; Author = "Your name here"; - MapSize = new int2(size); Tileset = terrainInfo.Id; // Empty rules that can be added to by the importers. // Will be dropped on save if nothing is added to it RuleDefinitions = new MiniYaml(""); - Tiles = new CellLayer(Grid.Type, size); - Resources = new CellLayer(Grid.Type, size); - Height = new CellLayer(Grid.Type, size); - Ramp = new CellLayer(Grid.Type, size); + Tiles = new CellLayer(Grid.Type, MapSize); + Resources = new CellLayer(Grid.Type, MapSize); + Height = new CellLayer(Grid.Type, MapSize); + Ramp = new CellLayer(Grid.Type, MapSize); Tiles.Clear(terrainInfo.DefaultTerrainTile); if (Grid.MaximumTerrainHeight > 0) @@ -372,11 +371,10 @@ namespace OpenRA Grid = modData.Manifest.Get(); - var size = new Size(MapSize.X, MapSize.Y); - Tiles = new CellLayer(Grid.Type, size); - Resources = new CellLayer(Grid.Type, size); - Height = new CellLayer(Grid.Type, size); - Ramp = new CellLayer(Grid.Type, size); + Tiles = new CellLayer(Grid.Type, MapSize); + Resources = new CellLayer(Grid.Type, MapSize); + Height = new CellLayer(Grid.Type, MapSize); + Ramp = new CellLayer(Grid.Type, MapSize); using (var s = Package.GetStream("map.bin")) { @@ -384,9 +382,9 @@ namespace OpenRA if (header.TilesOffset > 0) { s.Position = header.TilesOffset; - for (var i = 0; i < MapSize.X; i++) + for (var i = 0; i < MapSize.Width; i++) { - for (var j = 0; j < MapSize.Y; j++) + for (var j = 0; j < MapSize.Height; j++) { var tile = s.ReadUInt16(); var index = s.ReadUInt8(); @@ -403,9 +401,9 @@ namespace OpenRA if (header.ResourcesOffset > 0) { s.Position = header.ResourcesOffset; - for (var i = 0; i < MapSize.X; i++) + for (var i = 0; i < MapSize.Width; i++) { - for (var j = 0; j < MapSize.Y; j++) + for (var j = 0; j < MapSize.Height; j++) { var type = s.ReadUInt8(); var density = s.ReadUInt8(); @@ -417,8 +415,8 @@ namespace OpenRA if (header.HeightsOffset > 0) { s.Position = header.HeightsOffset; - for (var i = 0; i < MapSize.X; i++) - for (var j = 0; j < MapSize.Y; j++) + for (var i = 0; i < MapSize.Width; i++) + for (var j = 0; j < MapSize.Height; j++) Height[new MPos(i, j)] = s.ReadUInt8().Clamp((byte)0, Grid.MaximumTerrainHeight); } } @@ -454,7 +452,7 @@ namespace OpenRA Sequences = new SequenceSet(this, modData, Tileset, SequenceDefinitions); var tl = new MPos(0, 0).ToCPos(this); - var br = new MPos(MapSize.X - 1, MapSize.Y - 1).ToCPos(this); + var br = new MPos(MapSize.Width - 1, MapSize.Height - 1).ToCPos(this); AllCells = new CellRegion(Grid.Type, tl, br); var btl = new PPos(Bounds.Left, Bounds.Top); @@ -683,13 +681,13 @@ namespace OpenRA writer.Write(TileFormat); // Size - writer.Write((ushort)MapSize.X); - writer.Write((ushort)MapSize.Y); + writer.Write((ushort)MapSize.Width); + writer.Write((ushort)MapSize.Height); // Data offsets const int TilesOffset = 17; - var heightsOffset = Grid.MaximumTerrainHeight > 0 ? 3 * MapSize.X * MapSize.Y + 17 : 0; - var resourcesOffset = (Grid.MaximumTerrainHeight > 0 ? 4 : 3) * MapSize.X * MapSize.Y + 17; + var heightsOffset = Grid.MaximumTerrainHeight > 0 ? 3 * MapSize.Width * MapSize.Height + 17 : 0; + var resourcesOffset = (Grid.MaximumTerrainHeight > 0 ? 4 : 3) * MapSize.Width * MapSize.Height + 17; writer.Write((uint)TilesOffset); writer.Write((uint)heightsOffset); @@ -698,9 +696,9 @@ namespace OpenRA // Tile data if (TilesOffset != 0) { - for (var i = 0; i < MapSize.X; i++) + for (var i = 0; i < MapSize.Width; i++) { - for (var j = 0; j < MapSize.Y; j++) + for (var j = 0; j < MapSize.Height; j++) { var tile = Tiles[new MPos(i, j)]; writer.Write(tile.Type); @@ -711,16 +709,16 @@ namespace OpenRA // Height data if (heightsOffset != 0) - for (var i = 0; i < MapSize.X; i++) - for (var j = 0; j < MapSize.Y; j++) + for (var i = 0; i < MapSize.Width; i++) + for (var j = 0; j < MapSize.Height; j++) writer.Write(Height[new MPos(i, j)]); // Resource data if (resourcesOffset != 0) { - for (var i = 0; i < MapSize.X; i++) + for (var i = 0; i < MapSize.Width; i++) { - for (var j = 0; j < MapSize.Y; j++) + for (var j = 0; j < MapSize.Height; j++) { var tile = Resources[new MPos(i, j)]; writer.Write(tile.Type); @@ -1088,16 +1086,15 @@ namespace OpenRA var oldMapResources = Resources; var oldMapHeight = Height; var oldMapRamp = Ramp; - var newSize = new Size(width, height); - Tiles = CellLayer.Resize(oldMapTiles, newSize, oldMapTiles[MPos.Zero]); - Resources = CellLayer.Resize(oldMapResources, newSize, oldMapResources[MPos.Zero]); - Height = CellLayer.Resize(oldMapHeight, newSize, oldMapHeight[MPos.Zero]); - Ramp = CellLayer.Resize(oldMapRamp, newSize, oldMapRamp[MPos.Zero]); - MapSize = new int2(newSize); + MapSize = new Size(width, height); + Tiles = CellLayer.Resize(oldMapTiles, MapSize, oldMapTiles[MPos.Zero]); + Resources = CellLayer.Resize(oldMapResources, MapSize, oldMapResources[MPos.Zero]); + Height = CellLayer.Resize(oldMapHeight, MapSize, oldMapHeight[MPos.Zero]); + Ramp = CellLayer.Resize(oldMapRamp, MapSize, oldMapRamp[MPos.Zero]); var tl = new MPos(0, 0); - var br = new MPos(MapSize.X - 1, MapSize.Y - 1); + var br = new MPos(MapSize.Width - 1, MapSize.Height - 1); AllCells = new CellRegion(Grid.Type, tl.ToCPos(this), br.ToCPos(this)); SetBounds(new PPos(tl.U + 1, tl.V + 1), new PPos(br.U - 1, br.V - 1)); } diff --git a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs index 16585f84e2..eaed97ee64 100644 --- a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs +++ b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs @@ -264,7 +264,7 @@ namespace OpenRA.Traits frozenActorsById = []; partitionedFrozenActors = new SpatiallyPartitioned( - world.Map.MapSize.X, world.Map.MapSize.Y, binSize); + world.Map.MapSize.Width, world.Map.MapSize.Height, binSize); self.Trait().OnShroudChanged += uv => { diff --git a/OpenRA.Game/Traits/World/ScreenMap.cs b/OpenRA.Game/Traits/World/ScreenMap.cs index 0cfd92905f..079f811e4f 100644 --- a/OpenRA.Game/Traits/World/ScreenMap.cs +++ b/OpenRA.Game/Traits/World/ScreenMap.cs @@ -62,8 +62,8 @@ namespace OpenRA.Traits public ScreenMap(World world, ScreenMapInfo info) { var size = world.Map.Rules.TerrainInfo.TileSize; - var width = world.Map.MapSize.X * size.Width; - var height = world.Map.MapSize.Y * size.Height; + var width = world.Map.MapSize.Width * size.Width; + var height = world.Map.MapSize.Height * size.Height; partitionedMouseFrozenActors = new Cache>( _ => new SpatiallyPartitioned(width, height, info.BinSize)); diff --git a/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs b/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs index 40be41418f..02e0ded424 100644 --- a/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs +++ b/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs @@ -74,9 +74,9 @@ namespace OpenRA.Mods.Cnc.Traits var terrainInfo = map.Rules.TerrainInfo; var info = terrainInfo.TerrainTypes[terrainInfo.GetTerrainIndex(terrainType)]; - for (var i = 0; i < map.MapSize.X; i++) + for (var i = 0; i < map.MapSize.Width; i++) { - for (var j = 0; j < map.MapSize.Y; j++) + for (var j = 0; j < map.MapSize.Height; j++) { var uv = new MPos(i, j); diff --git a/OpenRA.Mods.Cnc/UtilityCommands/ImportGen1MapCommand.cs b/OpenRA.Mods.Cnc/UtilityCommands/ImportGen1MapCommand.cs index 0a93c0e0be..42113db9d3 100644 --- a/OpenRA.Mods.Cnc/UtilityCommands/ImportGen1MapCommand.cs +++ b/OpenRA.Mods.Cnc/UtilityCommands/ImportGen1MapCommand.cs @@ -74,7 +74,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands if (!ModData.DefaultTerrainInfo.TryGetValue(tileset, out var terrainInfo)) throw new InvalidDataException($"Unknown tileset {tileset}"); - Map = new Map(ModData, terrainInfo, MapSize, MapSize) + Map = new Map(ModData, terrainInfo, new Size(MapSize, MapSize)) { Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename)), Author = author, diff --git a/OpenRA.Mods.Cnc/UtilityCommands/ImportGen2MapCommand.cs b/OpenRA.Mods.Cnc/UtilityCommands/ImportGen2MapCommand.cs index 52952d2c72..39aad5f091 100644 --- a/OpenRA.Mods.Cnc/UtilityCommands/ImportGen2MapCommand.cs +++ b/OpenRA.Mods.Cnc/UtilityCommands/ImportGen2MapCommand.cs @@ -76,7 +76,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands var usedAreaSize = new Size(iniSize[2], 2 * iniSize[3]); var mapCanvasSize = new Size(usedAreaSize.Width + Cordon.Left + Cordon.Right, usedAreaSize.Height + Cordon.Top + Cordon.Bottom); - var map = new Map(Game.ModData, terrainInfo, mapCanvasSize.Width, mapCanvasSize.Height) + var map = new Map(Game.ModData, terrainInfo, mapCanvasSize) { Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename)), Author = author, diff --git a/OpenRA.Mods.Common/Lint/CheckMapCordon.cs b/OpenRA.Mods.Common/Lint/CheckMapCordon.cs index dcb65fb7be..0170437e6c 100644 --- a/OpenRA.Mods.Common/Lint/CheckMapCordon.cs +++ b/OpenRA.Mods.Common/Lint/CheckMapCordon.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Lint public void Run(Action emitError, Action emitWarning, ModData modData, Map map) { if (map.Bounds.Left == 0 || map.Bounds.Top == 0 - || map.Bounds.Right == map.MapSize.X || map.Bounds.Bottom == map.MapSize.Y) + || map.Bounds.Right == map.MapSize.Width || map.Bounds.Bottom == map.MapSize.Height) 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."); diff --git a/OpenRA.Mods.Common/Lint/CheckMultiBrushes.cs b/OpenRA.Mods.Common/Lint/CheckMultiBrushes.cs index c45b6da7a1..c4cd8573ab 100644 --- a/OpenRA.Mods.Common/Lint/CheckMultiBrushes.cs +++ b/OpenRA.Mods.Common/Lint/CheckMultiBrushes.cs @@ -12,6 +12,7 @@ using System; using OpenRA.Mods.Common.MapGenerator; using OpenRA.Mods.Common.Terrain; +using OpenRA.Primitives; namespace OpenRA.Mods.Common.Lint { @@ -23,8 +24,9 @@ namespace OpenRA.Mods.Common.Lint { if (terrainInfo is ITemplatedTerrainInfo templatedTerrainInfo && templatedTerrainInfo.MultiBrushCollections.Count > 0) { - var map = new Map(modData, terrainInfo, 1, 1); + var map = new Map(modData, terrainInfo, new Size(1, 1)); foreach (var (collectionName, collection) in templatedTerrainInfo.MultiBrushCollections) + { foreach (var info in collection) { try @@ -41,6 +43,7 @@ namespace OpenRA.Mods.Common.Lint emitError($"Tileset {terrainInfoName} has invalid MultiBrush collection `{collectionName}`: {e.Message}"); } } + } } } } diff --git a/OpenRA.Mods.Common/MapGenerator/CellLayerUtils.cs b/OpenRA.Mods.Common/MapGenerator/CellLayerUtils.cs index 2e3e99a6ad..d92bf196f2 100644 --- a/OpenRA.Mods.Common/MapGenerator/CellLayerUtils.cs +++ b/OpenRA.Mods.Common/MapGenerator/CellLayerUtils.cs @@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.MapGenerator /// public static Rectangle CellBounds(Map map) { - return CellBounds(new Size(map.MapSize.X, map.MapSize.Y), map.Grid.Type); + return CellBounds(map.MapSize, map.Grid.Type); } /// diff --git a/OpenRA.Mods.Common/MapGenerator/MultiBrush.cs b/OpenRA.Mods.Common/MapGenerator/MultiBrush.cs index 4ff32bc256..76945aff2c 100644 --- a/OpenRA.Mods.Common/MapGenerator/MultiBrush.cs +++ b/OpenRA.Mods.Common/MapGenerator/MultiBrush.cs @@ -533,8 +533,9 @@ namespace OpenRA.Mods.Common.MapGenerator var size = map.MapSize; var replaceMposes = new List(); var remaining = new CellLayer(map); - for (var v = 0; v < size.Y; v++) - for (var u = 0; u < size.X; u++) + for (var v = 0; v < size.Height; v++) + { + for (var u = 0; u < size.Width; u++) { var mpos = new MPos(u, v); if (replace[mpos] != Replaceability.None) @@ -547,8 +548,9 @@ namespace OpenRA.Mods.Common.MapGenerator remaining[mpos] = false; } } + } - var mposes = new MPos[size.X * size.Y]; + var mposes = new MPos[size.Width * size.Height]; int mposCount; void RefreshIndices() diff --git a/OpenRA.Mods.Common/MapGenerator/PlayableSpace.cs b/OpenRA.Mods.Common/MapGenerator/PlayableSpace.cs index df04a02532..383cf219b6 100644 --- a/OpenRA.Mods.Common/MapGenerator/PlayableSpace.cs +++ b/OpenRA.Mods.Common/MapGenerator/PlayableSpace.cs @@ -70,7 +70,6 @@ namespace OpenRA.Mods.Common.MapGenerator List actorPlans, Dictionary playabilityMap) { - var size = map.MapSize; var regions = new List(); var regionMap = new CellLayer(map); regionMap.Clear(NullRegion); diff --git a/OpenRA.Mods.Common/Pathfinder/HierarchicalPathFinder.cs b/OpenRA.Mods.Common/Pathfinder/HierarchicalPathFinder.cs index 2456676452..65cc26e7bb 100644 --- a/OpenRA.Mods.Common/Pathfinder/HierarchicalPathFinder.cs +++ b/OpenRA.Mods.Common/Pathfinder/HierarchicalPathFinder.cs @@ -319,7 +319,7 @@ namespace OpenRA.Mods.Common.Pathfinder false); } - return new Grid(CPos.Zero, (CPos)map.MapSize, false); + return new Grid(CPos.Zero, new CPos(map.MapSize.Width, map.MapSize.Height), false); } mapBounds = GetCPosBounds(world.Map); diff --git a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs index 2caa71e76f..5c3601716d 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs @@ -61,8 +61,8 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads var dangerRadius = owner.SquadManager.Info.DangerScanRadius; detectedEnemyTarget = null; - var columnCount = (map.MapSize.X + dangerRadius - 1) / dangerRadius; - var rowCount = (map.MapSize.Y + dangerRadius - 1) / dangerRadius; + var columnCount = (map.MapSize.Width + dangerRadius - 1) / dangerRadius; + var rowCount = (map.MapSize.Height + dangerRadius - 1) / dangerRadius; var checkIndices = Exts.MakeArray(columnCount * rowCount, i => i).Shuffle(owner.World.LocalRandom); foreach (var i in checkIndices) diff --git a/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs index 24feb72a7e..f69db9d138 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs @@ -140,9 +140,9 @@ namespace OpenRA.Mods.Common.Traits var suitableLocations = new List<(MPos UV, int Attractiveness)>(); var totalAttractiveness = 0; - for (var i = 0; i < map.MapSize.X; i += checkRadius) + for (var i = 0; i < map.MapSize.Width; i += checkRadius) { - for (var j = 0; j < map.MapSize.Y; j += checkRadius) + for (var j = 0; j < map.MapSize.Height; j += checkRadius) { var tl = new MPos(i, j); var br = new MPos(i + checkRadius, j + checkRadius); diff --git a/OpenRA.Mods.Common/Traits/World/ActorMap.cs b/OpenRA.Mods.Common/Traits/World/ActorMap.cs index de7b9d3eef..b3c2b073cf 100644 --- a/OpenRA.Mods.Common/Traits/World/ActorMap.cs +++ b/OpenRA.Mods.Common/Traits/World/ActorMap.cs @@ -194,8 +194,8 @@ namespace OpenRA.Mods.Common.Traits map = world.Map; influence = [new CellLayer(world.Map)]; - cols = CellCoordToBinIndex(world.Map.MapSize.X) + 1; - rows = CellCoordToBinIndex(world.Map.MapSize.Y) + 1; + cols = CellCoordToBinIndex(world.Map.MapSize.Width) + 1; + rows = CellCoordToBinIndex(world.Map.MapSize.Height) + 1; bins = new Bin[rows * cols]; for (var row = 0; row < rows; row++) for (var col = 0; col < cols; col++) diff --git a/OpenRA.Mods.Common/Traits/World/EditorActorLayer.cs b/OpenRA.Mods.Common/Traits/World/EditorActorLayer.cs index 5555fec721..f4cff0bfb8 100644 --- a/OpenRA.Mods.Common/Traits/World/EditorActorLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/EditorActorLayer.cs @@ -85,8 +85,8 @@ namespace OpenRA.Mods.Common.Traits cellMap = new SpatiallyPartitioned( mapCellSize.X, mapCellSize.Y, Exts.IntegerDivisionRoundingAwayFromZero(Info.BinSize, ts.Width)); - var width = world.Map.MapSize.X * ts.Width; - var height = world.Map.MapSize.Y * ts.Height; + var width = world.Map.MapSize.Width * ts.Width; + var height = world.Map.MapSize.Height * ts.Height; screenMap = new SpatiallyPartitioned(width, height, Info.BinSize); foreach (var kv in world.Map.ActorDefinitions) diff --git a/OpenRA.Mods.Common/Traits/World/ExperimentalMapGenerator.cs b/OpenRA.Mods.Common/Traits/World/ExperimentalMapGenerator.cs index 47237fb474..65db797331 100644 --- a/OpenRA.Mods.Common/Traits/World/ExperimentalMapGenerator.cs +++ b/OpenRA.Mods.Common/Traits/World/ExperimentalMapGenerator.cs @@ -489,9 +489,8 @@ namespace OpenRA.Mods.Common.Traits const int ExternalBias = 4096; var size = map.MapSize; - var minSpan = Math.Min(size.X, size.Y); - var maxSpan = Math.Max(size.X, size.Y); - var mapCenter1024ths = size * 512; + var minSpan = Math.Min(size.Width, size.Height); + var mapCenter1024ths = size.ToInt2() * 512; var wMapCenter = CellLayerUtils.Center(map.Tiles); var matrixMapCenter1024ths = CellLayerUtils.CellBounds(map).Size.ToInt2() * 512; var cellBounds = CellLayerUtils.CellBounds(map); @@ -756,7 +755,7 @@ namespace OpenRA.Mods.Common.Traits // Limit mountain area to the existing mountain space (starting with all available land) var roominess = MatrixUtils.ChebyshevRoom(cliffPlan, true); var available = 0; - var total = size.X * size.Y; + var total = size.Width * size.Height; for (var n = 0; n < mountainElevation.Data.Length; n++) { if (roominess.Data[n] < param.MinimumTerrainContourSpacing) @@ -1719,7 +1718,7 @@ namespace OpenRA.Mods.Common.Traits decorationNoise[mpos] = -1024 * 1024; } - var mapArea = map.MapSize.X * map.MapSize.Y; + var mapArea = map.MapSize.Width * map.MapSize.Height; CellLayerUtils.CalibrateQuantileInPlace( decorationNoise, 0, diff --git a/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs b/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs index 732ee7b141..3a6124056c 100644 --- a/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs @@ -80,9 +80,9 @@ namespace OpenRA.Mods.Common.Traits colors.Add(resourceIndex, info.Color); } - for (var i = 0; i < map.MapSize.X; i++) + for (var i = 0; i < map.MapSize.Width; i++) { - for (var j = 0; j < map.MapSize.Y; j++) + for (var j = 0; j < map.MapSize.Height; j++) { var cell = new MPos(i, j); if (colors.TryGetValue(map.Resources[cell].Type, out var color)) diff --git a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs index 6d0cd33b75..833f31a170 100644 --- a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs @@ -314,7 +314,7 @@ namespace OpenRA.Mods.Common.Traits cellsDirty.Clear(true); anyCellDirty = true; var tl = new PPos(0, 0); - var br = new PPos(map.MapSize.X - 1, map.MapSize.Y - 1); + var br = new PPos(map.MapSize.Width - 1, map.MapSize.Height - 1); UpdateShroud(new ProjectedCellRegion(map, tl, br)); } diff --git a/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs b/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs index ecdd6d83b5..7d69f7c100 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs @@ -61,8 +61,8 @@ namespace OpenRA.Mods.Common.Traits var tileScale = map.Grid.TileScale; partitionedLightSources = new SpatiallyPartitioned( - (map.MapSize.X + 1) * tileScale, - (map.MapSize.Y + 1) * tileScale, + (map.MapSize.Width + 1) * tileScale, + (map.MapSize.Height + 1) * tileScale, info.BinSize * tileScale); } diff --git a/OpenRA.Mods.Common/UtilityCommands/FuzzMapGeneratorCommand.cs b/OpenRA.Mods.Common/UtilityCommands/FuzzMapGeneratorCommand.cs index 60981bc57d..b046b7255a 100644 --- a/OpenRA.Mods.Common/UtilityCommands/FuzzMapGeneratorCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/FuzzMapGeneratorCommand.cs @@ -17,6 +17,7 @@ using System.Linq; using System.Text; using OpenRA.Mods.Common.MapGenerator; using OpenRA.Mods.Common.Traits; +using OpenRA.Primitives; namespace OpenRA.Mods.Common.UtilityCommands { @@ -264,7 +265,7 @@ namespace OpenRA.Mods.Common.UtilityCommands if (size.Length != 2) throw new ArgumentException($"bad map size `{iterationChoices[Configuration.SizeVariable]}`"); - var map = new Map(modData, terrainInfo, size[0], size[1]); + var map = new Map(modData, terrainInfo, new Size(size[0], size[1])); var maxTerrainHeight = map.Grid.MaximumTerrainHeight; var tl = new PPos(1, 1 + maxTerrainHeight); var br = new PPos(size[0], size[1] + maxTerrainHeight); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapGeneratorToolLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapGeneratorToolLogic.cs index 13f8bc3d2b..2f693b9beb 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapGeneratorToolLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapGeneratorToolLogic.cs @@ -262,7 +262,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var map = world.Map; var terrainInfo = map.Rules.TerrainInfo; - var generatedMap = new Map(modData, terrainInfo, map.MapSize.X, map.MapSize.Y); + var generatedMap = new Map(modData, terrainInfo, map.MapSize); var bounds = map.Bounds; generatedMap.SetBounds(new PPos(bounds.Left, bounds.Top), new PPos(bounds.Right - 1, bounds.Bottom - 1)); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/NewMapLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/NewMapLogic.cs index a20c643d95..e89600d82b 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/NewMapLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/NewMapLogic.cs @@ -13,6 +13,7 @@ using System; using System.Linq; using OpenRA.FileSystem; using OpenRA.Mods.Common.Terrain; +using OpenRA.Primitives; using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets.Logic @@ -59,7 +60,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var maxTerrainHeight = world.Map.Grid.MaximumTerrainHeight; var tileset = modData.DefaultTerrainInfo[tilesetDropDown.GetText()]; - var map = new Map(Game.ModData, tileset, width + 2, height + maxTerrainHeight + 2); + var map = new Map(Game.ModData, tileset, new Size(width + 2, height + maxTerrainHeight + 2)); var tl = new PPos(1, 1 + maxTerrainHeight); var br = new PPos(width, height + maxTerrainHeight); diff --git a/OpenRA.Mods.Common/Widgets/RadarWidget.cs b/OpenRA.Mods.Common/Widgets/RadarWidget.cs index d14e6ce15d..769d18eedc 100644 --- a/OpenRA.Mods.Common/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.Common/Widgets/RadarWidget.cs @@ -75,8 +75,8 @@ namespace OpenRA.Mods.Common.Widgets radarTerrainLayers = world.WorldActor.TraitsImplementing().ToArray(); isRectangularIsometric = world.Map.Grid.Type == MapGridType.RectangularIsometric; cellWidth = isRectangularIsometric ? 2 : 1; - previewWidth = world.Map.MapSize.X; - previewHeight = world.Map.MapSize.Y; + previewWidth = world.Map.MapSize.Width; + previewHeight = world.Map.MapSize.Height; if (isRectangularIsometric) previewWidth = 2 * previewWidth - 1; } diff --git a/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs b/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs index 758c437d71..a285249f53 100644 --- a/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs +++ b/OpenRA.Mods.D2k/UtilityCommands/D2kMapImporter.cs @@ -326,7 +326,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands if (terrainInfo == null) throw new InvalidDataException("The D2k map importer requires the DefaultTerrain parser."); - map = new Map(Game.ModData, terrainInfo, mapSize.Width + 2 * MapCordonWidth, mapSize.Height + 2 * MapCordonWidth) + map = new Map(Game.ModData, terrainInfo, new Size(mapSize.Width + 2 * MapCordonWidth, mapSize.Height + 2 * MapCordonWidth)) { Title = Path.GetFileNameWithoutExtension(mapFile), Author = "Westwood Studios"