Change Map.MapSize from int2 to Size.

This commit is contained in:
Paul Chote
2025-04-19 09:36:00 +01:00
committed by Gustas Kažukauskas
parent 2fbbff2860
commit ede12610a8
28 changed files with 94 additions and 91 deletions

View File

@@ -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<Vertex>(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++; }

View File

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

View File

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

View File

@@ -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<MiniYamlNode> 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.
/// </summary>
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<MapGrid>();
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<TerrainTile>(Grid.Type, size);
Resources = new CellLayer<ResourceTile>(Grid.Type, size);
Height = new CellLayer<byte>(Grid.Type, size);
Ramp = new CellLayer<byte>(Grid.Type, size);
Tiles = new CellLayer<TerrainTile>(Grid.Type, MapSize);
Resources = new CellLayer<ResourceTile>(Grid.Type, MapSize);
Height = new CellLayer<byte>(Grid.Type, MapSize);
Ramp = new CellLayer<byte>(Grid.Type, MapSize);
Tiles.Clear(terrainInfo.DefaultTerrainTile);
if (Grid.MaximumTerrainHeight > 0)
@@ -372,11 +371,10 @@ namespace OpenRA
Grid = modData.Manifest.Get<MapGrid>();
var size = new Size(MapSize.X, MapSize.Y);
Tiles = new CellLayer<TerrainTile>(Grid.Type, size);
Resources = new CellLayer<ResourceTile>(Grid.Type, size);
Height = new CellLayer<byte>(Grid.Type, size);
Ramp = new CellLayer<byte>(Grid.Type, size);
Tiles = new CellLayer<TerrainTile>(Grid.Type, MapSize);
Resources = new CellLayer<ResourceTile>(Grid.Type, MapSize);
Height = new CellLayer<byte>(Grid.Type, MapSize);
Ramp = new CellLayer<byte>(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));
}

View File

@@ -264,7 +264,7 @@ namespace OpenRA.Traits
frozenActorsById = [];
partitionedFrozenActors = new SpatiallyPartitioned<FrozenActor>(
world.Map.MapSize.X, world.Map.MapSize.Y, binSize);
world.Map.MapSize.Width, world.Map.MapSize.Height, binSize);
self.Trait<Shroud>().OnShroudChanged += uv =>
{

View File

@@ -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<Player, SpatiallyPartitioned<FrozenActor>>(
_ => new SpatiallyPartitioned<FrozenActor>(width, height, info.BinSize));

View File

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

View File

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

View File

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

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Lint
public void Run(Action<string> emitError, Action<string> 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.");

View File

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

View File

@@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.MapGenerator
/// </summary>
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);
}
/// <summary>

View File

@@ -533,8 +533,9 @@ namespace OpenRA.Mods.Common.MapGenerator
var size = map.MapSize;
var replaceMposes = new List<MPos>();
var remaining = new CellLayer<bool>(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()

View File

@@ -70,7 +70,6 @@ namespace OpenRA.Mods.Common.MapGenerator
List<ActorPlan> actorPlans,
Dictionary<TerrainTile, Playability> playabilityMap)
{
var size = map.MapSize;
var regions = new List<Region>();
var regionMap = new CellLayer<int>(map);
regionMap.Clear(NullRegion);

View File

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

View File

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

View File

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

View File

@@ -194,8 +194,8 @@ namespace OpenRA.Mods.Common.Traits
map = world.Map;
influence = [new CellLayer<InfluenceNode>(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++)

View File

@@ -85,8 +85,8 @@ namespace OpenRA.Mods.Common.Traits
cellMap = new SpatiallyPartitioned<EditorActorPreview>(
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<EditorActorPreview>(width, height, Info.BinSize);
foreach (var kv in world.Map.ActorDefinitions)

View File

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

View File

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

View File

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

View File

@@ -61,8 +61,8 @@ namespace OpenRA.Mods.Common.Traits
var tileScale = map.Grid.TileScale;
partitionedLightSources = new SpatiallyPartitioned<LightSource>(
(map.MapSize.X + 1) * tileScale,
(map.MapSize.Y + 1) * tileScale,
(map.MapSize.Width + 1) * tileScale,
(map.MapSize.Height + 1) * tileScale,
info.BinSize * tileScale);
}

View File

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

View File

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

View File

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

View File

@@ -75,8 +75,8 @@ namespace OpenRA.Mods.Common.Widgets
radarTerrainLayers = world.WorldActor.TraitsImplementing<IRadarTerrainLayer>().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;
}

View File

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