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