Use var everywhere
This commit is contained in:
@@ -637,9 +637,9 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
public int CalculateTotalResource()
|
public int CalculateTotalResource()
|
||||||
{
|
{
|
||||||
int totalResource = 0;
|
var totalResource = 0;
|
||||||
for (int i = 0; i < surface1.Map.MapSize.X; i++)
|
for (var i = 0; i < surface1.Map.MapSize.X; i++)
|
||||||
for (int j = 0; j < surface1.Map.MapSize.Y; j++)
|
for (var j = 0; j < surface1.Map.MapSize.Y; j++)
|
||||||
{
|
{
|
||||||
if (surface1.Map.MapResources.Value[i, j].Type != 0)
|
if (surface1.Map.MapResources.Value[i, j].Type != 0)
|
||||||
totalResource += GetResourceValue(i, j);
|
totalResource += GetResourceValue(i, j);
|
||||||
@@ -650,7 +650,7 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
int GetAdjecentCellsWith(int resourceType, int x, int y)
|
int GetAdjecentCellsWith(int resourceType, int x, int y)
|
||||||
{
|
{
|
||||||
int sum = 0;
|
var sum = 0;
|
||||||
for (var u = -1; u < 2; u++)
|
for (var u = -1; u < 2; u++)
|
||||||
for (var v = -1; v < 2; v++)
|
for (var v = -1; v < 2; v++)
|
||||||
{
|
{
|
||||||
@@ -665,15 +665,15 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
int GetResourceValue(int x, int y)
|
int GetResourceValue(int x, int y)
|
||||||
{
|
{
|
||||||
int imageLength = 0;
|
var imageLength = 0;
|
||||||
int type = surface1.Map.MapResources.Value[x, y].Type;
|
int type = surface1.Map.MapResources.Value[x, y].Type;
|
||||||
var template = surface1.ResourceTemplates.FirstOrDefault(a => a.Value.Info.ResourceType == type).Value;
|
var template = surface1.ResourceTemplates.FirstOrDefault(a => a.Value.Info.ResourceType == type).Value;
|
||||||
if (type == 1)
|
if (type == 1)
|
||||||
imageLength = 12;
|
imageLength = 12;
|
||||||
else if (type == 2)
|
else if (type == 2)
|
||||||
imageLength = 3;
|
imageLength = 3;
|
||||||
int density = (GetAdjecentCellsWith(type, x, y) * imageLength - 1) / 9;
|
var density = (GetAdjecentCellsWith(type, x, y) * imageLength - 1) / 9;
|
||||||
int value = template.Info.ValuePerUnit;
|
var value = template.Info.ValuePerUnit;
|
||||||
return density * value;
|
return density * value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
foreach (var map in MapCache.FindMapsIn(MapFolderPath))
|
foreach (var map in MapCache.FindMapsIn(MapFolderPath))
|
||||||
{
|
{
|
||||||
ListViewItem map1 = new ListViewItem();
|
var map1 = new ListViewItem();
|
||||||
map1.Tag = map;
|
map1.Tag = map;
|
||||||
map1.Text = Path.GetFileNameWithoutExtension(map);
|
map1.Text = Path.GetFileNameWithoutExtension(map);
|
||||||
map1.ImageIndex = 0;
|
map1.ImageIndex = 0;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
byte* q = (byte*)data.Scan0.ToPointer();
|
var q = (byte*)data.Scan0.ToPointer();
|
||||||
var stride2 = data.Stride;
|
var stride2 = data.Stride;
|
||||||
|
|
||||||
for (var i = 0; i < frame.Size.Width; i++)
|
for (var i = 0; i < frame.Size.Width; i++)
|
||||||
@@ -92,7 +92,7 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
byte* q = (byte*)data.Scan0.ToPointer();
|
var q = (byte*)data.Scan0.ToPointer();
|
||||||
var stride = data.Stride;
|
var stride = data.Stride;
|
||||||
|
|
||||||
for (var i = 0; i < frame.Size.Width; i++)
|
for (var i = 0; i < frame.Size.Width; i++)
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int* p = (int*)data.Scan0.ToPointer();
|
var p = (int*)data.Scan0.ToPointer();
|
||||||
var stride = data.Stride >> 2;
|
var stride = data.Stride >> 2;
|
||||||
|
|
||||||
for (var i = 0; i < ChunkSize; i++)
|
for (var i = 0; i < ChunkSize; i++)
|
||||||
@@ -285,7 +285,7 @@ namespace OpenRA.Editor
|
|||||||
var srcdata = resourceImage.LockBits(resourceImage.Bounds(),
|
var srcdata = resourceImage.LockBits(resourceImage.Bounds(),
|
||||||
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
|
|
||||||
int* q = (int*)srcdata.Scan0.ToPointer();
|
var q = (int*)srcdata.Scan0.ToPointer();
|
||||||
var srcstride = srcdata.Stride >> 2;
|
var srcstride = srcdata.Stride >> 2;
|
||||||
|
|
||||||
for (var x = 0; x < TileSetRenderer.TileSize; x++)
|
for (var x = 0; x < TileSetRenderer.TileSize; x++)
|
||||||
@@ -344,10 +344,10 @@ namespace OpenRA.Editor
|
|||||||
float2 GetDrawPosition(CPos location, Bitmap bmp, bool centered)
|
float2 GetDrawPosition(CPos location, Bitmap bmp, bool centered)
|
||||||
{
|
{
|
||||||
float offsetX = centered ? bmp.Width / 2 - TileSetRenderer.TileSize / 2 : 0;
|
float offsetX = centered ? bmp.Width / 2 - TileSetRenderer.TileSize / 2 : 0;
|
||||||
float drawX = TileSetRenderer.TileSize * location.X * Zoom + Offset.X - offsetX;
|
var drawX = TileSetRenderer.TileSize * location.X * Zoom + Offset.X - offsetX;
|
||||||
|
|
||||||
float offsetY = centered ? bmp.Height / 2 - TileSetRenderer.TileSize / 2 : 0;
|
float offsetY = centered ? bmp.Height / 2 - TileSetRenderer.TileSize / 2 : 0;
|
||||||
float drawY = TileSetRenderer.TileSize * location.Y * Zoom + Offset.Y - offsetY;
|
var drawY = TileSetRenderer.TileSize * location.Y * Zoom + Offset.Y - offsetY;
|
||||||
|
|
||||||
return new float2(drawX, drawY);
|
return new float2(drawX, drawY);
|
||||||
}
|
}
|
||||||
@@ -417,8 +417,8 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
var drawX = TileSetRenderer.TileSize * (float)ChunkSize * (float)x.X * Zoom + Offset.X;
|
var drawX = TileSetRenderer.TileSize * (float)ChunkSize * (float)x.X * Zoom + Offset.X;
|
||||||
var drawY = TileSetRenderer.TileSize * (float)ChunkSize * (float)x.Y * Zoom + Offset.Y;
|
var drawY = TileSetRenderer.TileSize * (float)ChunkSize * (float)x.Y * Zoom + Offset.Y;
|
||||||
RectangleF sourceRect = new RectangleF(0, 0, bmp.Width, bmp.Height);
|
var sourceRect = new RectangleF(0, 0, bmp.Width, bmp.Height);
|
||||||
RectangleF destRect = new RectangleF(drawX, drawY, bmp.Width * Zoom, bmp.Height * Zoom);
|
var destRect = new RectangleF(drawX, drawY, bmp.Width * Zoom, bmp.Height * Zoom);
|
||||||
e.Graphics.DrawImage(bmp, destRect, sourceRect, GraphicsUnit.Pixel);
|
e.Graphics.DrawImage(bmp, destRect, sourceRect, GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,20 +467,20 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
if (ShowRuler && Zoom > 0.2)
|
if (ShowRuler && Zoom > 0.2)
|
||||||
{
|
{
|
||||||
for (int i = Map.Bounds.Left; i <= Map.Bounds.Right; i += 8)
|
for (var i = Map.Bounds.Left; i <= Map.Bounds.Right; i += 8)
|
||||||
{
|
{
|
||||||
if (i % 8 == 0)
|
if (i % 8 == 0)
|
||||||
{
|
{
|
||||||
PointF point = new PointF(i * TileSetRenderer.TileSize * Zoom + Offset.X, (Map.Bounds.Top - 8) * TileSetRenderer.TileSize * Zoom + Offset.Y);
|
var point = new PointF(i * TileSetRenderer.TileSize * Zoom + Offset.X, (Map.Bounds.Top - 8) * TileSetRenderer.TileSize * Zoom + Offset.Y);
|
||||||
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
|
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = Map.Bounds.Top; i <= Map.Bounds.Bottom; i += 8)
|
for (var i = Map.Bounds.Top; i <= Map.Bounds.Bottom; i += 8)
|
||||||
{
|
{
|
||||||
if (i % 8 == 0)
|
if (i % 8 == 0)
|
||||||
{
|
{
|
||||||
PointF point = new PointF((Map.Bounds.Left - 8) * TileSetRenderer.TileSize * Zoom + Offset.X, i * TileSetRenderer.TileSize * Zoom + Offset.Y);
|
var point = new PointF((Map.Bounds.Left - 8) * TileSetRenderer.TileSize * Zoom + Offset.X, i * TileSetRenderer.TileSize * Zoom + Offset.Y);
|
||||||
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
|
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -505,15 +505,15 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
if (start == end) return;
|
if (start == end) return;
|
||||||
|
|
||||||
int width = Math.Abs((start - end).X);
|
var width = Math.Abs((start - end).X);
|
||||||
int height = Math.Abs((start - end).Y);
|
var height = Math.Abs((start - end).Y);
|
||||||
|
|
||||||
TileSelection = new TileReference<ushort, byte>[width, height];
|
TileSelection = new TileReference<ushort, byte>[width, height];
|
||||||
ResourceSelection = new TileReference<byte, byte>[width, height];
|
ResourceSelection = new TileReference<byte, byte>[width, height];
|
||||||
|
|
||||||
for (int x = 0; x < width; x++)
|
for (var x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < height; y++)
|
for (var y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
// TODO: crash prevention
|
// TODO: crash prevention
|
||||||
TileSelection[x, y] = Map.MapTiles.Value[start.X + x, start.Y + y];
|
TileSelection[x, y] = Map.MapTiles.Value[start.X + x, start.Y + y];
|
||||||
@@ -528,9 +528,9 @@ namespace OpenRA.Editor
|
|||||||
var width = Math.Abs((SelectionStart - SelectionEnd).X);
|
var width = Math.Abs((SelectionStart - SelectionEnd).X);
|
||||||
var height = Math.Abs((SelectionStart - SelectionEnd).Y);
|
var height = Math.Abs((SelectionStart - SelectionEnd).Y);
|
||||||
|
|
||||||
for (int x = 0; x < width; x++)
|
for (var x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < height; y++)
|
for (var y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
var mapX = loc.X + x;
|
var mapX = loc.X + x;
|
||||||
var mapY = loc.Y + y;
|
var mapY = loc.Y + y;
|
||||||
|
|||||||
@@ -172,8 +172,8 @@ namespace OpenRA
|
|||||||
u = selector(t);
|
u = selector(t);
|
||||||
while (e.MoveNext())
|
while (e.MoveNext())
|
||||||
{
|
{
|
||||||
T nextT = e.Current;
|
var nextT = e.Current;
|
||||||
U nextU = selector(nextT);
|
var nextU = selector(nextT);
|
||||||
if (comparer.Compare(nextU, u) * modifier < 0)
|
if (comparer.Compare(nextU, u) * modifier < 0)
|
||||||
{
|
{
|
||||||
t = nextT;
|
t = nextT;
|
||||||
@@ -228,8 +228,8 @@ namespace OpenRA
|
|||||||
var d = new Dictionary<TKey, TElement>();
|
var d = new Dictionary<TKey, TElement>();
|
||||||
foreach (var item in source)
|
foreach (var item in source)
|
||||||
{
|
{
|
||||||
TKey key = keySelector(item);
|
var key = keySelector(item);
|
||||||
TElement element = elementSelector(item);
|
var element = elementSelector(item);
|
||||||
|
|
||||||
// Check for a key conflict:
|
// Check for a key conflict:
|
||||||
if (d.ContainsKey(key))
|
if (d.ContainsKey(key))
|
||||||
@@ -274,8 +274,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static T[] MakeArray<T>(int count, Func<int, T> f)
|
public static T[] MakeArray<T>(int count, Func<int, T> f)
|
||||||
{
|
{
|
||||||
T[] result = new T[count];
|
var result = new T[count];
|
||||||
for (int i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
result[i] = f(i);
|
result[i] = f(i);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ namespace OpenRA
|
|||||||
var parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
var parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
var ret = Array.CreateInstance(fieldType.GetElementType(), parts.Length);
|
var ret = Array.CreateInstance(fieldType.GetElementType(), parts.Length);
|
||||||
for (int i = 0; i < parts.Length; i++)
|
for (var i = 0; i < parts.Length; i++)
|
||||||
ret.SetValue(GetValue(fieldName, fieldType.GetElementType(), parts[i].Trim(), field), i);
|
ret.SetValue(GetValue(fieldName, fieldType.GetElementType(), parts[i].Trim(), field), i);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ namespace OpenRA.FileFormats
|
|||||||
while (dataSize > 0)
|
while (dataSize > 0)
|
||||||
{
|
{
|
||||||
var chunk = Chunk.Read(s);
|
var chunk = Chunk.Read(s);
|
||||||
for (int n = 0; n < chunk.CompressedSize; n++)
|
for (var n = 0; n < chunk.CompressedSize; n++)
|
||||||
{
|
{
|
||||||
var b = s.ReadUInt8();
|
var b = s.ReadUInt8();
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace OpenRA.FileFormats
|
|||||||
// Magic number for "done"
|
// Magic number for "done"
|
||||||
if (len == 519)
|
if (len == 519)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < next; i++)
|
for (var i = 0; i < next; i++)
|
||||||
ms.WriteByte(outBuffer[i]);
|
ms.WriteByte(outBuffer[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ namespace OpenRA.FileFormats
|
|||||||
// Flush window to outstream
|
// Flush window to outstream
|
||||||
if (next == MAXWIN)
|
if (next == MAXWIN)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < next; i++)
|
for (var i = 0; i < next; i++)
|
||||||
ms.WriteByte(outBuffer[i]);
|
ms.WriteByte(outBuffer[i]);
|
||||||
next = 0;
|
next = 0;
|
||||||
first = false;
|
first = false;
|
||||||
@@ -149,7 +149,7 @@ namespace OpenRA.FileFormats
|
|||||||
outBuffer[next++] = (byte)symbol;
|
outBuffer[next++] = (byte)symbol;
|
||||||
if (next == MAXWIN)
|
if (next == MAXWIN)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < next; i++)
|
for (var i = 0; i < next; i++)
|
||||||
ms.WriteByte(outBuffer[i]);
|
ms.WriteByte(outBuffer[i]);
|
||||||
next = 0;
|
next = 0;
|
||||||
first = false;
|
first = false;
|
||||||
@@ -236,7 +236,7 @@ namespace OpenRA.FileFormats
|
|||||||
var s = 0; // current symbol
|
var s = 0; // current symbol
|
||||||
|
|
||||||
// convert compact repeat counts into symbol bit length list
|
// convert compact repeat counts into symbol bit length list
|
||||||
foreach (byte code in rep)
|
foreach (var code in rep)
|
||||||
{
|
{
|
||||||
var num = (code >> 4) + 1; // Number of codes (top four bits plus 1)
|
var num = (code >> 4) + 1; // Number of codes (top four bits plus 1)
|
||||||
var len = (byte)(code & 15); // Code length (low four bits)
|
var len = (byte)(code & 15); // Code length (low four bits)
|
||||||
@@ -250,7 +250,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
// count number of codes of each length
|
// count number of codes of each length
|
||||||
Count = new short[Blast.MAXBITS + 1];
|
Count = new short[Blast.MAXBITS + 1];
|
||||||
for (int i = 0; i < n; i++)
|
for (var i = 0; i < n; i++)
|
||||||
Count[length[i]]++;
|
Count[length[i]]++;
|
||||||
|
|
||||||
// no codes!
|
// no codes!
|
||||||
@@ -259,7 +259,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
// check for an over-subscribed or incomplete set of lengths
|
// check for an over-subscribed or incomplete set of lengths
|
||||||
var left = 1; // one possible code of zero length
|
var left = 1; // one possible code of zero length
|
||||||
for (int len = 1; len <= Blast.MAXBITS; len++)
|
for (var len = 1; len <= Blast.MAXBITS; len++)
|
||||||
{
|
{
|
||||||
left <<= 1; // one more bit, double codes left
|
left <<= 1; // one more bit, double codes left
|
||||||
left -= Count[len]; // deduct count from possible codes
|
left -= Count[len]; // deduct count from possible codes
|
||||||
@@ -269,7 +269,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
// generate offsets into symbol table for each length for sorting
|
// generate offsets into symbol table for each length for sorting
|
||||||
var offs = new short[Blast.MAXBITS + 1];
|
var offs = new short[Blast.MAXBITS + 1];
|
||||||
for (int len = 1; len < Blast.MAXBITS; len++)
|
for (var len = 1; len < Blast.MAXBITS; len++)
|
||||||
offs[len + 1] = (short)(offs[len] + Count[len]);
|
offs[len + 1] = (short)(offs[len] + Count[len]);
|
||||||
|
|
||||||
// put symbols in table sorted by length, by symbol order within each length
|
// put symbols in table sorted by length, by symbol order within each length
|
||||||
|
|||||||
@@ -26,15 +26,15 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
uint l = 0, r = 0;
|
uint l = 0, r = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 18; )
|
for (var i = 0; i < 18; )
|
||||||
{
|
{
|
||||||
Encrypt(ref l, ref r);
|
Encrypt(ref l, ref r);
|
||||||
m_p[i++] = l;
|
m_p[i++] = l;
|
||||||
m_p[i++] = r;
|
m_p[i++] = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i)
|
for (var i = 0; i < 4; ++i)
|
||||||
for (int j = 0; j < 256; )
|
for (var j = 0; j < 256; )
|
||||||
{
|
{
|
||||||
Encrypt(ref l, ref r);
|
Encrypt(ref l, ref r);
|
||||||
m_s[i, j++] = l;
|
m_s[i, j++] = l;
|
||||||
@@ -49,14 +49,14 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
static uint[] RunCipher(uint[] data, CipherFunc f)
|
static uint[] RunCipher(uint[] data, CipherFunc f)
|
||||||
{
|
{
|
||||||
uint[] result = new uint[data.Length];
|
var result = new uint[data.Length];
|
||||||
|
|
||||||
int size = data.Length / 2;
|
var size = data.Length / 2;
|
||||||
int i = 0;
|
var i = 0;
|
||||||
while (size-- > 0)
|
while (size-- > 0)
|
||||||
{
|
{
|
||||||
uint a = SwapBytes(data[i]);
|
var a = SwapBytes(data[i]);
|
||||||
uint b = SwapBytes(data[i+1]);
|
var b = SwapBytes(data[i+1]);
|
||||||
|
|
||||||
f(ref a, ref b);
|
f(ref a, ref b);
|
||||||
|
|
||||||
@@ -72,8 +72,8 @@ namespace OpenRA.FileFormats
|
|||||||
uint _a = a, _b = b;
|
uint _a = a, _b = b;
|
||||||
_a ^= m_p[0];
|
_a ^= m_p[0];
|
||||||
|
|
||||||
bool x = false;
|
var x = false;
|
||||||
for( int i = 1; i <= 16; i++, x ^= true)
|
for( var i = 1; i <= 16; i++, x ^= true)
|
||||||
{
|
{
|
||||||
if (x)
|
if (x)
|
||||||
Round(ref _a, _b, i);
|
Round(ref _a, _b, i);
|
||||||
@@ -91,8 +91,8 @@ namespace OpenRA.FileFormats
|
|||||||
uint _a = a, _b = b;
|
uint _a = a, _b = b;
|
||||||
_a ^= m_p[17];
|
_a ^= m_p[17];
|
||||||
|
|
||||||
bool x = false;
|
var x = false;
|
||||||
for (int i = 16; i >= 1; i--, x ^= true)
|
for (var i = 16; i >= 1; i--, x ^= true)
|
||||||
{
|
{
|
||||||
if (x)
|
if (x)
|
||||||
Round(ref _a, _b, i);
|
Round(ref _a, _b, i);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
static void init_bignum(uint[] n, uint val, uint len)
|
static void init_bignum(uint[] n, uint val, uint len)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < len; i++) n[i] = 0;
|
for (var i = 0; i < len; i++) n[i] = 0;
|
||||||
n[0] = val;
|
n[0] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
fixed (uint* _pn = &n[0])
|
fixed (uint* _pn = &n[0])
|
||||||
{
|
{
|
||||||
byte* pn = (byte*)_pn;
|
var pn = (byte*)_pn;
|
||||||
uint i = blen * 4;
|
var i = blen * 4;
|
||||||
for (; i > klen; i--) pn[i - 1] = (byte)sign;
|
for (; i > klen; i--) pn[i - 1] = (byte)sign;
|
||||||
for (; i > 0; i--) pn[i - 1] = key[klen - i];
|
for (; i > 0; i--) pn[i - 1] = key[klen - i];
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ namespace OpenRA.FileFormats
|
|||||||
uint keylen;
|
uint keylen;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
int j = 0;
|
var j = 0;
|
||||||
|
|
||||||
if (key[j] != 2) return;
|
if (key[j] != 2) return;
|
||||||
j++;
|
j++;
|
||||||
@@ -118,7 +118,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
uint len_predata()
|
uint len_predata()
|
||||||
{
|
{
|
||||||
uint a = (pubkey.len - 1) / 8;
|
var a = (pubkey.len - 1) / 8;
|
||||||
return (55 / a + 1) * (a + 1);
|
return (55 / a + 1) * (a + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
static void shr_bignum(uint[] n, int bits, int len)
|
static void shr_bignum(uint[] n, int bits, int len)
|
||||||
{
|
{
|
||||||
int i; int i2 = bits / 32;
|
int i; var i2 = bits / 32;
|
||||||
|
|
||||||
if (i2 > 0)
|
if (i2 > 0)
|
||||||
{
|
{
|
||||||
@@ -183,9 +183,9 @@ namespace OpenRA.FileFormats
|
|||||||
fixed (uint* _ps2 = &src2[0])
|
fixed (uint* _ps2 = &src2[0])
|
||||||
fixed (uint* _pd = &dest[0])
|
fixed (uint* _pd = &dest[0])
|
||||||
{
|
{
|
||||||
ushort* ps1 = (ushort*)_ps1;
|
var ps1 = (ushort*)_ps1;
|
||||||
ushort* ps2 = (ushort*)_ps2;
|
var ps2 = (ushort*)_ps2;
|
||||||
ushort* pd = (ushort*)_pd;
|
var pd = (ushort*)_pd;
|
||||||
|
|
||||||
while (--len != -1)
|
while (--len != -1)
|
||||||
{
|
{
|
||||||
@@ -205,9 +205,9 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
len += len;
|
len += len;
|
||||||
|
|
||||||
ushort* ps1 = (ushort*)src1;
|
var ps1 = (ushort*)src1;
|
||||||
ushort* ps2 = (ushort*)src2;
|
var ps2 = (ushort*)src2;
|
||||||
ushort* pd = (ushort*)dest;
|
var pd = (ushort*)dest;
|
||||||
|
|
||||||
while (--len != -1)
|
while (--len != -1)
|
||||||
{
|
{
|
||||||
@@ -222,11 +222,11 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
static void inv_bignum(uint[] n1, uint[] n2, uint len)
|
static void inv_bignum(uint[] n1, uint[] n2, uint len)
|
||||||
{
|
{
|
||||||
uint[] n_tmp = new uint[64];
|
var n_tmp = new uint[64];
|
||||||
uint n2_bytelen, bit;
|
uint n2_bytelen, bit;
|
||||||
int n2_bitlen;
|
int n2_bitlen;
|
||||||
|
|
||||||
int j = 0;
|
var j = 0;
|
||||||
|
|
||||||
init_bignum(n_tmp, 0, len);
|
init_bignum(n_tmp, 0, len);
|
||||||
init_bignum(n1, 0, len);
|
init_bignum(n1, 0, len);
|
||||||
@@ -257,7 +257,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
static void inc_bignum(uint[] n, uint len)
|
static void inc_bignum(uint[] n, uint len)
|
||||||
{
|
{
|
||||||
int i = 0;
|
var i = 0;
|
||||||
while ((++n[i] == 0) && (--len > 0)) i++;
|
while ((++n[i] == 0) && (--len > 0)) i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
fixed (uint* _pn2 = &n2[0])
|
fixed (uint* _pn2 = &n2[0])
|
||||||
{
|
{
|
||||||
ushort* pn2 = (ushort*)_pn2;
|
var pn2 = (ushort*)_pn2;
|
||||||
|
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
@@ -314,8 +314,8 @@ namespace OpenRA.FileFormats
|
|||||||
fixed( uint * _psrc2 = &src2[0] )
|
fixed( uint * _psrc2 = &src2[0] )
|
||||||
fixed(uint* _pdest = &dest[0])
|
fixed(uint* _pdest = &dest[0])
|
||||||
{
|
{
|
||||||
ushort* psrc2 = (ushort*)_psrc2;
|
var psrc2 = (ushort*)_psrc2;
|
||||||
ushort* pdest = (ushort*)_pdest;
|
var pdest = (ushort*)_pdest;
|
||||||
|
|
||||||
init_bignum(dest, 0, len * 2);
|
init_bignum(dest, 0, len * 2);
|
||||||
for (i = 0; i < len * 2; i++)
|
for (i = 0; i < len * 2; i++)
|
||||||
@@ -338,8 +338,8 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
unsafe uint get_mulword(uint* n)
|
unsafe uint get_mulword(uint* n)
|
||||||
{
|
{
|
||||||
ushort* wn = (ushort*)n;
|
var wn = (ushort*)n;
|
||||||
uint i = (uint)((((((((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_lo + 0x10000) >> 1)
|
var i = (uint)((((((((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_lo + 0x10000) >> 1)
|
||||||
+ (((*(wn - 2) ^ 0xffff) * glob1_hi_inv_hi + glob1_hi_inv_hi) >> 1) + 1)
|
+ (((*(wn - 2) ^ 0xffff) * glob1_hi_inv_hi + glob1_hi_inv_hi) >> 1) + 1)
|
||||||
>> 16) + ((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_hi) >> 1) +
|
>> 16) + ((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_hi) >> 1) +
|
||||||
(((*wn ^ 0xffff) * glob1_hi_inv_lo) >> 1) + 1) >> 14) + glob1_hi_inv_hi
|
(((*wn ^ 0xffff) * glob1_hi_inv_lo) >> 1) + 1) >> 14) + glob1_hi_inv_hi
|
||||||
@@ -350,7 +350,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
static void dec_bignum(uint[] n, uint len)
|
static void dec_bignum(uint[] n, uint len)
|
||||||
{
|
{
|
||||||
int i = 0;
|
var i = 0;
|
||||||
while ((--n[i] == 0xffffffff) && (--len > 0))
|
while ((--n[i] == 0xffffffff) && (--len > 0))
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -371,12 +371,12 @@ namespace OpenRA.FileFormats
|
|||||||
inc_bignum(glob2, len * 2 + 1);
|
inc_bignum(glob2, len * 2 + 1);
|
||||||
neg_bignum(glob2, len * 2 + 1);
|
neg_bignum(glob2, len * 2 + 1);
|
||||||
len_diff = g2_len_x2 + 1 - glob1_len_x2;
|
len_diff = g2_len_x2 + 1 - glob1_len_x2;
|
||||||
ushort* esi = ((ushort*)g2) + (1 + g2_len_x2 - glob1_len_x2);
|
var esi = ((ushort*)g2) + (1 + g2_len_x2 - glob1_len_x2);
|
||||||
ushort* edi = ((ushort*)g2) + (g2_len_x2 + 1);
|
var edi = ((ushort*)g2) + (g2_len_x2 + 1);
|
||||||
for (; len_diff != 0; len_diff--)
|
for (; len_diff != 0; len_diff--)
|
||||||
{
|
{
|
||||||
edi--;
|
edi--;
|
||||||
uint tmp = get_mulword((uint*)edi);
|
var tmp = get_mulword((uint*)edi);
|
||||||
esi--;
|
esi--;
|
||||||
if (tmp > 0)
|
if (tmp > 0)
|
||||||
{
|
{
|
||||||
@@ -410,7 +410,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
void calc_a_key(uint[] n1, uint[] n2, uint[] n3, uint[] n4, uint len)
|
void calc_a_key(uint[] n1, uint[] n2, uint[] n3, uint[] n4, uint len)
|
||||||
{
|
{
|
||||||
uint[] n_tmp = new uint[64];
|
var n_tmp = new uint[64];
|
||||||
uint n3_len, n4_len;
|
uint n3_len, n4_len;
|
||||||
int n3_bitlen;
|
int n3_bitlen;
|
||||||
uint bit_mask;
|
uint bit_mask;
|
||||||
@@ -419,7 +419,7 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
fixed (uint* _pn3 = &n3[0])
|
fixed (uint* _pn3 = &n3[0])
|
||||||
{
|
{
|
||||||
uint* pn3 = _pn3;
|
var pn3 = _pn3;
|
||||||
|
|
||||||
init_bignum(n1, 1, len);
|
init_bignum(n1, 1, len);
|
||||||
n4_len = len_bignum(n4, len);
|
n4_len = len_bignum(n4, len);
|
||||||
@@ -457,10 +457,10 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
unsafe void process_predata(byte* pre, uint pre_len, byte *buf)
|
unsafe void process_predata(byte* pre, uint pre_len, byte *buf)
|
||||||
{
|
{
|
||||||
uint[] n2 = new uint[64];
|
var n2 = new uint[64];
|
||||||
uint[] n3 = new uint[64];
|
var n3 = new uint[64];
|
||||||
|
|
||||||
uint a = (pubkey.len - 1) / 8;
|
var a = (pubkey.len - 1) / 8;
|
||||||
while (a + 1 <= pre_len)
|
while (a + 1 <= pre_len)
|
||||||
{
|
{
|
||||||
init_bignum(n2, 0, 64);
|
init_bignum(n2, 0, 64);
|
||||||
@@ -480,7 +480,7 @@ namespace OpenRA.FileFormats
|
|||||||
public byte[] DecryptKey(byte[] src)
|
public byte[] DecryptKey(byte[] src)
|
||||||
{
|
{
|
||||||
init_pubkey();
|
init_pubkey();
|
||||||
byte[] dest = new byte[256];
|
var dest = new byte[256];
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ namespace OpenRA.FileFormats
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public static uint Calculate(byte[] data, uint polynomial)
|
public static uint Calculate(byte[] data, uint polynomial)
|
||||||
{
|
{
|
||||||
uint crc = polynomial;
|
var crc = polynomial;
|
||||||
for (int i = 0; i < data.Length; i++)
|
for (var i = 0; i < data.Length; i++)
|
||||||
crc = (crc >> 8) ^ lookUp[(crc & 0xFF) ^ data[i]];
|
crc = (crc >> 8) ^ lookUp[(crc & 0xFF) ^ data[i]];
|
||||||
crc ^= polynomial;
|
crc ^= polynomial;
|
||||||
return crc;
|
return crc;
|
||||||
@@ -119,8 +119,8 @@ namespace OpenRA.FileFormats
|
|||||||
/// <returns>The calculated checksum.</returns>
|
/// <returns>The calculated checksum.</returns>
|
||||||
public static unsafe uint Calculate(byte* data, uint len, uint polynomial)
|
public static unsafe uint Calculate(byte* data, uint len, uint polynomial)
|
||||||
{
|
{
|
||||||
uint crc = polynomial;
|
var crc = polynomial;
|
||||||
for (int i = 0; i < len; i++)
|
for (var i = 0; i < len; i++)
|
||||||
crc = (crc >> 8) ^ lookUp[(crc & 0xFF) ^ *data++];
|
crc = (crc >> 8) ^ lookUp[(crc & 0xFF) ^ *data++];
|
||||||
crc ^= polynomial;
|
crc ^= polynomial;
|
||||||
return crc;
|
return crc;
|
||||||
|
|||||||
@@ -15,32 +15,32 @@ namespace OpenRA.FileFormats
|
|||||||
public static int DecodeInto(byte[] src, byte[] dest, int srcOffset)
|
public static int DecodeInto(byte[] src, byte[] dest, int srcOffset)
|
||||||
{
|
{
|
||||||
var ctx = new FastByteReader(src, srcOffset);
|
var ctx = new FastByteReader(src, srcOffset);
|
||||||
int destIndex = 0;
|
var destIndex = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
byte i = ctx.ReadByte();
|
var i = ctx.ReadByte();
|
||||||
if ((i & 0x80) == 0)
|
if ((i & 0x80) == 0)
|
||||||
{
|
{
|
||||||
int count = i & 0x7F;
|
var count = i & 0x7F;
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
// case 6
|
// case 6
|
||||||
count = ctx.ReadByte();
|
count = ctx.ReadByte();
|
||||||
byte value = ctx.ReadByte();
|
var value = ctx.ReadByte();
|
||||||
for (int end = destIndex + count; destIndex < end; destIndex++)
|
for (var end = destIndex + count; destIndex < end; destIndex++)
|
||||||
dest[destIndex] ^= value;
|
dest[destIndex] ^= value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// case 5
|
// case 5
|
||||||
for (int end = destIndex + count; destIndex < end; destIndex++)
|
for (var end = destIndex + count; destIndex < end; destIndex++)
|
||||||
dest[destIndex] ^= ctx.ReadByte();
|
dest[destIndex] ^= ctx.ReadByte();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int count = i & 0x7F;
|
var count = i & 0x7F;
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
count = ctx.ReadWord();
|
count = ctx.ReadWord();
|
||||||
@@ -55,14 +55,14 @@ namespace OpenRA.FileFormats
|
|||||||
else if ((count & 0x4000) == 0)
|
else if ((count & 0x4000) == 0)
|
||||||
{
|
{
|
||||||
// case 3
|
// case 3
|
||||||
for (int end = destIndex + (count & 0x3FFF); destIndex < end; destIndex++)
|
for (var end = destIndex + (count & 0x3FFF); destIndex < end; destIndex++)
|
||||||
dest[destIndex] ^= ctx.ReadByte();
|
dest[destIndex] ^= ctx.ReadByte();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// case 4
|
// case 4
|
||||||
byte value = ctx.ReadByte();
|
var value = ctx.ReadByte();
|
||||||
for (int end = destIndex + (count & 0x3FFF); destIndex < end; destIndex++)
|
for (var end = destIndex + (count & 0x3FFF); destIndex < end; destIndex++)
|
||||||
dest[destIndex] ^= value;
|
dest[destIndex] ^= value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
public void Load(Stream s)
|
public void Load(Stream s)
|
||||||
{
|
{
|
||||||
StreamReader reader = new StreamReader(s);
|
var reader = new StreamReader(s);
|
||||||
IniSection currentSection = null;
|
IniSection currentSection = null;
|
||||||
|
|
||||||
while (!reader.EndOfStream)
|
while (!reader.EndOfStream)
|
||||||
@@ -55,10 +55,10 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
IniSection ProcessSection(string line)
|
IniSection ProcessSection(string line)
|
||||||
{
|
{
|
||||||
Match m = sectionPattern.Match(line);
|
var m = sectionPattern.Match(line);
|
||||||
if (!m.Success)
|
if (!m.Success)
|
||||||
return null;
|
return null;
|
||||||
string sectionName = m.Groups[1].Value.ToLowerInvariant();
|
var sectionName = m.Groups[1].Value.ToLowerInvariant();
|
||||||
|
|
||||||
IniSection ret;
|
IniSection ret;
|
||||||
if (!sections.TryGetValue(sectionName, out ret))
|
if (!sections.TryGetValue(sectionName, out ret))
|
||||||
@@ -78,7 +78,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
var key = line;
|
var key = line;
|
||||||
var value = "";
|
var value = "";
|
||||||
int eq = line.IndexOf('=');
|
var eq = line.IndexOf('=');
|
||||||
if (eq >= 0)
|
if (eq >= 0)
|
||||||
{
|
{
|
||||||
key = line.Substring(0, eq);
|
key = line.Substring(0, eq);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
Color[] palette = null;
|
Color[] palette = null;
|
||||||
List<byte> data = new List<byte>();
|
var data = new List<byte>();
|
||||||
|
|
||||||
for (; ; )
|
for (; ; )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace OpenRA.FileFormats
|
|||||||
throw new NotSupportedException("Metadata version {0} is not supported".F(version));
|
throw new NotSupportedException("Metadata version {0} is not supported".F(version));
|
||||||
|
|
||||||
// Read game info (max 100K limit as a safeguard against corrupted files)
|
// Read game info (max 100K limit as a safeguard against corrupted files)
|
||||||
string data = fs.ReadString(Encoding.UTF8, 1024 * 100);
|
var data = fs.ReadString(Encoding.UTF8, 1024 * 100);
|
||||||
GameInfo = GameInformation.Deserialize(data);
|
GameInfo = GameInformation.Deserialize(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ namespace OpenRA.FileFormats
|
|||||||
writer.Write(MetaVersion);
|
writer.Write(MetaVersion);
|
||||||
|
|
||||||
// Write data
|
// Write data
|
||||||
int dataLength = 0;
|
var dataLength = 0;
|
||||||
{
|
{
|
||||||
// Write lobby info data
|
// Write lobby info data
|
||||||
writer.Flush();
|
writer.Flush();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.FileFormats
|
|||||||
var indexStart = s.ReadInt32();
|
var indexStart = s.ReadInt32();
|
||||||
|
|
||||||
s.Position = indexStart;
|
s.Position = indexStart;
|
||||||
foreach (byte b in s.ReadBytes(indexEnd - indexStart))
|
foreach (var b in s.ReadBytes(indexEnd - indexStart))
|
||||||
{
|
{
|
||||||
if (b != 255)
|
if (b != 255)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace OpenRA.FileFormats
|
|||||||
var indexStart = s.ReadInt32();
|
var indexStart = s.ReadInt32();
|
||||||
|
|
||||||
s.Position = indexStart;
|
s.Position = indexStart;
|
||||||
foreach (byte b in s.ReadBytes(indexEnd - indexStart))
|
foreach (var b in s.ReadBytes(indexEnd - indexStart))
|
||||||
{
|
{
|
||||||
if (b != 255)
|
if (b != 255)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
// Frame offsets
|
// Frame offsets
|
||||||
offsets = new UInt32[Frames];
|
offsets = new UInt32[Frames];
|
||||||
for (int i = 0; i < Frames; i++)
|
for (var i = 0; i < Frames; i++)
|
||||||
{
|
{
|
||||||
offsets[i] = stream.ReadUInt32();
|
offsets[i] = stream.ReadUInt32();
|
||||||
if (offsets[i] > 0x40000000)
|
if (offsets[i] > 0x40000000)
|
||||||
@@ -125,7 +125,7 @@ namespace OpenRA.FileFormats
|
|||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
var adpcmIndex = 0;
|
var adpcmIndex = 0;
|
||||||
|
|
||||||
bool compressed = false;
|
var compressed = false;
|
||||||
for (var i = 0; i < Frames; i++)
|
for (var i = 0; i < Frames; i++)
|
||||||
{
|
{
|
||||||
stream.Seek(offsets[i], SeekOrigin.Begin);
|
stream.Seek(offsets[i], SeekOrigin.Begin);
|
||||||
@@ -201,7 +201,7 @@ namespace OpenRA.FileFormats
|
|||||||
// Chunks are aligned on even bytes; may be padded with a single null
|
// Chunks are aligned on even bytes; may be padded with a single null
|
||||||
if (s.Peek() == 0) s.ReadByte();
|
if (s.Peek() == 0) s.ReadByte();
|
||||||
var type = s.ReadASCII(4);
|
var type = s.ReadASCII(4);
|
||||||
int subchunkLength = (int)int2.Swap(s.ReadUInt32());
|
var subchunkLength = (int)int2.Swap(s.ReadUInt32());
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
@@ -235,11 +235,11 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
// Palette
|
// Palette
|
||||||
case "CPL0":
|
case "CPL0":
|
||||||
for (int i = 0; i < numColors; i++)
|
for (var i = 0; i < numColors; i++)
|
||||||
{
|
{
|
||||||
byte r = (byte)(s.ReadUInt8() << 2);
|
var r = (byte)(s.ReadUInt8() << 2);
|
||||||
byte g = (byte)(s.ReadUInt8() << 2);
|
var g = (byte)(s.ReadUInt8() << 2);
|
||||||
byte b = (byte)(s.ReadUInt8() << 2);
|
var b = (byte)(s.ReadUInt8() << 2);
|
||||||
palette[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b);
|
palette[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -269,7 +269,7 @@ namespace OpenRA.FileFormats
|
|||||||
for (var i = 0; i < blockWidth; i++)
|
for (var i = 0; i < blockWidth; i++)
|
||||||
{
|
{
|
||||||
var cbfi = (mod*256 + px)*8 + j*blockWidth + i;
|
var cbfi = (mod*256 + px)*8 + j*blockWidth + i;
|
||||||
byte color = (mod == 0x0f) ? px : cbf[cbfi];
|
var color = (mod == 0x0f) ? px : cbf[cbfi];
|
||||||
frameData[y*blockHeight + j, x*blockWidth + i] = palette[color];
|
frameData[y*blockHeight + j, x*blockWidth + i] = palette[color];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
s.Seek(dataStart + colStart[i], SeekOrigin.Begin);
|
s.Seek(dataStart + colStart[i], SeekOrigin.Begin);
|
||||||
|
|
||||||
byte x = (byte)(i % l.Size[0]);
|
var x = (byte)(i % l.Size[0]);
|
||||||
byte y = (byte)(i / l.Size[0]);
|
var y = (byte)(i / l.Size[0]);
|
||||||
byte z = 0;
|
byte z = 0;
|
||||||
l.VoxelMap[x,y] = new Dictionary<byte, VxlElement>();
|
l.VoxelMap[x,y] = new Dictionary<byte, VxlElement>();
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ namespace OpenRA.FileSystem
|
|||||||
s = GlobalFileSystem.Open(filename);
|
s = GlobalFileSystem.Open(filename);
|
||||||
|
|
||||||
// Parse package header
|
// Parse package header
|
||||||
BinaryReader reader = new BinaryReader(s);
|
var reader = new BinaryReader(s);
|
||||||
uint signature = reader.ReadUInt32();
|
var signature = reader.ReadUInt32();
|
||||||
if (signature != 0x8C655D13)
|
if (signature != 0x8C655D13)
|
||||||
throw new InvalidDataException("Not an Installshield package");
|
throw new InvalidDataException("Not an Installshield package");
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ namespace OpenRA.FileSystem
|
|||||||
|
|
||||||
// Parse the directory list
|
// Parse the directory list
|
||||||
s.Seek(TOCAddress, SeekOrigin.Begin);
|
s.Seek(TOCAddress, SeekOrigin.Begin);
|
||||||
BinaryReader TOCreader = new BinaryReader(s);
|
var TOCreader = new BinaryReader(s);
|
||||||
|
|
||||||
var fileCountInDirs = new List<uint>();
|
var fileCountInDirs = new List<uint>();
|
||||||
// Parse directories
|
// Parse directories
|
||||||
|
|||||||
@@ -64,10 +64,10 @@ namespace OpenRA.FileSystem
|
|||||||
if (name.Length % 4 != 0)
|
if (name.Length % 4 != 0)
|
||||||
name = name.PadRight(name.Length + (4 - name.Length % 4), '\0');
|
name = name.PadRight(name.Length + (4 - name.Length % 4), '\0');
|
||||||
|
|
||||||
MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(name));
|
var ms = new MemoryStream(Encoding.ASCII.GetBytes(name));
|
||||||
BinaryReader reader = new BinaryReader(ms);
|
var reader = new BinaryReader(ms);
|
||||||
|
|
||||||
int len = name.Length >> 2;
|
var len = name.Length >> 2;
|
||||||
uint result = 0;
|
uint result = 0;
|
||||||
|
|
||||||
while (len-- != 0)
|
while (len-- != 0)
|
||||||
@@ -80,11 +80,11 @@ namespace OpenRA.FileSystem
|
|||||||
{
|
{
|
||||||
name = name.ToUpperInvariant();
|
name = name.ToUpperInvariant();
|
||||||
var l = name.Length;
|
var l = name.Length;
|
||||||
int a = l >> 2;
|
var a = l >> 2;
|
||||||
if ((l & 3) != 0)
|
if ((l & 3) != 0)
|
||||||
{
|
{
|
||||||
name += (char)(l - (a << 2));
|
name += (char)(l - (a << 2));
|
||||||
int i = 3 - (l & 3);
|
var i = 3 - (l & 3);
|
||||||
while (i-- != 0)
|
while (i-- != 0)
|
||||||
name += name[a << 2];
|
name += name[a << 2];
|
||||||
}
|
}
|
||||||
@@ -99,9 +99,9 @@ namespace OpenRA.FileSystem
|
|||||||
|
|
||||||
public static void AddStandardName(string s)
|
public static void AddStandardName(string s)
|
||||||
{
|
{
|
||||||
uint hash = HashFilename(s, PackageHashType.Classic); // RA1 and TD
|
var hash = HashFilename(s, PackageHashType.Classic); // RA1 and TD
|
||||||
Names.Add(hash, s);
|
Names.Add(hash, s);
|
||||||
uint crcHash = HashFilename(s, PackageHashType.CRC32); // TS
|
var crcHash = HashFilename(s, PackageHashType.CRC32); // TS
|
||||||
Names.Add(crcHash, s);
|
Names.Add(crcHash, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var ret = new List<ITraitInfo>();
|
var ret = new List<ITraitInfo>();
|
||||||
var t = Traits.WithInterface<ITraitInfo>().ToList();
|
var t = Traits.WithInterface<ITraitInfo>().ToList();
|
||||||
int index = 0;
|
var index = 0;
|
||||||
while (t.Count != 0)
|
while (t.Count != 0)
|
||||||
{
|
{
|
||||||
var prereqs = PrerequisitesOf(t[index]);
|
var prereqs = PrerequisitesOf(t[index]);
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ namespace OpenRA.Graphics
|
|||||||
float[] trgb = { h + 1 / 3.0f, h, h - 1 / 3.0f };
|
float[] trgb = { h + 1 / 3.0f, h, h - 1 / 3.0f };
|
||||||
float[] rgb = { 0, 0, 0 };
|
float[] rgb = { 0, 0, 0 };
|
||||||
|
|
||||||
for (int k = 0; k < 3; k++)
|
for (var k = 0; k < 3; k++)
|
||||||
{
|
{
|
||||||
while (trgb[k] < 0) trgb[k] += 1.0f;
|
while (trgb[k] < 0) trgb[k] += 1.0f;
|
||||||
while (trgb[k] > 1) trgb[k] -= 1.0f;
|
while (trgb[k] > 1) trgb[k] -= 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int k = 0; k < 3; k++)
|
for (var k = 0; k < 3; k++)
|
||||||
{
|
{
|
||||||
if (trgb[k] < 1 / 6.0f) { rgb[k] = p + ((q - p) * 6 * trgb[k]); }
|
if (trgb[k] < 1 / 6.0f) { rgb[k] = p + ((q - p) * 6 * trgb[k]); }
|
||||||
else if (trgb[k] >= 1 / 6.0f && trgb[k] < 0.5) { rgb[k] = q; }
|
else if (trgb[k] >= 1 / 6.0f && trgb[k] < 0.5) { rgb[k] = q; }
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int* c = (int*)bitmapData.Scan0;
|
var c = (int*)bitmapData.Scan0;
|
||||||
|
|
||||||
for (var x = 0; x < map.Bounds.Width; x++)
|
for (var x = 0; x < map.Bounds.Width; x++)
|
||||||
for (var y = 0; y < map.Bounds.Height; y++)
|
for (var y = 0; y < map.Bounds.Height; y++)
|
||||||
@@ -56,14 +56,14 @@ namespace OpenRA.Graphics
|
|||||||
// in a world use AddCustomTerrain instead
|
// in a world use AddCustomTerrain instead
|
||||||
static Bitmap AddStaticResources(TileSet tileset, Map map, Ruleset resourceRules, Bitmap terrainBitmap)
|
static Bitmap AddStaticResources(TileSet tileset, Map map, Ruleset resourceRules, Bitmap terrainBitmap)
|
||||||
{
|
{
|
||||||
Bitmap terrain = new Bitmap(terrainBitmap);
|
var terrain = new Bitmap(terrainBitmap);
|
||||||
|
|
||||||
var bitmapData = terrain.LockBits(terrain.Bounds(),
|
var bitmapData = terrain.LockBits(terrain.Bounds(),
|
||||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int* c = (int*)bitmapData.Scan0;
|
var c = (int*)bitmapData.Scan0;
|
||||||
|
|
||||||
for (var x = 0; x < map.Bounds.Width; x++)
|
for (var x = 0; x < map.Bounds.Width; x++)
|
||||||
for (var y = 0; y < map.Bounds.Height; y++)
|
for (var y = 0; y < map.Bounds.Height; y++)
|
||||||
@@ -98,7 +98,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int* c = (int*)bitmapData.Scan0;
|
var c = (int*)bitmapData.Scan0;
|
||||||
|
|
||||||
for (var x = 0; x < map.Bounds.Width; x++)
|
for (var x = 0; x < map.Bounds.Width; x++)
|
||||||
for (var y = 0; y < map.Bounds.Height; y++)
|
for (var y = 0; y < map.Bounds.Height; y++)
|
||||||
@@ -126,7 +126,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int* c = (int*)bitmapData.Scan0;
|
var c = (int*)bitmapData.Scan0;
|
||||||
|
|
||||||
foreach (var t in world.ActorsWithTrait<IRadarSignature>())
|
foreach (var t in world.ActorsWithTrait<IRadarSignature>())
|
||||||
{
|
{
|
||||||
@@ -160,7 +160,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int* c = (int*)bitmapData.Scan0;
|
var c = (int*)bitmapData.Scan0;
|
||||||
|
|
||||||
for (var x = 0; x < map.Bounds.Width; x++)
|
for (var x = 0; x < map.Bounds.Width; x++)
|
||||||
for (var y = 0; y < map.Bounds.Height; y++)
|
for (var y = 0; y < map.Bounds.Height; y++)
|
||||||
@@ -184,7 +184,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public static Bitmap RenderMapPreview(TileSet tileset, Map map, Ruleset resourceRules, bool actualSize)
|
public static Bitmap RenderMapPreview(TileSet tileset, Map map, Ruleset resourceRules, bool actualSize)
|
||||||
{
|
{
|
||||||
Bitmap terrain = TerrainBitmap(tileset, map, actualSize);
|
var terrain = TerrainBitmap(tileset, map, actualSize);
|
||||||
return AddStaticResources(tileset, map, resourceRules, terrain);
|
return AddStaticResources(tileset, map, resourceRules, terrain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public void ApplyRemap(IPaletteRemap r)
|
public void ApplyRemap(IPaletteRemap r)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 256; i++)
|
for (var i = 0; i < 256; i++)
|
||||||
colors[i] = (uint)r.GetRemappedColor(Color.FromArgb((int)colors[i]), i).ToArgb();
|
colors[i] = (uint)r.GetRemappedColor(Color.FromArgb((int)colors[i]), i).ToArgb();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,19 +54,19 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
colors = new uint[256];
|
colors = new uint[256];
|
||||||
|
|
||||||
using (BinaryReader reader = new BinaryReader(s))
|
using (var reader = new BinaryReader(s))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 256; i++)
|
for (var i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
byte r = (byte)(reader.ReadByte() << 2);
|
var r = (byte)(reader.ReadByte() << 2);
|
||||||
byte g = (byte)(reader.ReadByte() << 2);
|
var g = (byte)(reader.ReadByte() << 2);
|
||||||
byte b = (byte)(reader.ReadByte() << 2);
|
var b = (byte)(reader.ReadByte() << 2);
|
||||||
colors[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b);
|
colors[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
colors[0] = 0; // convert black background to transparency
|
colors[0] = 0; // convert black background to transparency
|
||||||
foreach (int i in remapShadow)
|
foreach (var i in remapShadow)
|
||||||
colors[i] = 140u << 24;
|
colors[i] = 140u << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ namespace OpenRA.Graphics
|
|||||||
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
uint* c = (uint*)data.Scan0;
|
var c = (uint*)data.Scan0;
|
||||||
for (var x = 0; x < 256; x++)
|
for (var x = 0; x < 256; x++)
|
||||||
*(c + x) = colors[x];
|
*(c + x) = colors[x];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Graphics
|
|||||||
RgbaSpriteRenderer = new SpriteRenderer(this, device.CreateShader("rgba"));
|
RgbaSpriteRenderer = new SpriteRenderer(this, device.CreateShader("rgba"));
|
||||||
SpriteRenderer = new SpriteRenderer(this, device.CreateShader("shp"));
|
SpriteRenderer = new SpriteRenderer(this, device.CreateShader("shp"));
|
||||||
|
|
||||||
for (int i = 0; i < TempBufferCount; i++)
|
for (var i = 0; i < TempBufferCount; i++)
|
||||||
tempBuffers.Enqueue(device.CreateVertexBuffer(TempBufferSize));
|
tempBuffers.Enqueue(device.CreateVertexBuffer(TempBufferSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
GlyphInfo CreateGlyph(Pair<char, Color> c)
|
GlyphInfo CreateGlyph(Pair<char, Color> c)
|
||||||
{
|
{
|
||||||
uint index = face.GetCharIndex(c.First);
|
var index = face.GetCharIndex(c.First);
|
||||||
face.LoadGlyph(index, LoadFlags.Default, LoadTarget.Normal);
|
face.LoadGlyph(index, LoadFlags.Default, LoadTarget.Normal);
|
||||||
face.Glyph.RenderGlyph(RenderMode.Normal);
|
face.Glyph.RenderGlyph(RenderMode.Normal);
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
var terrainPalette = wr.Palette("terrain").Index;
|
var terrainPalette = wr.Palette("terrain").Index;
|
||||||
var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width];
|
var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width];
|
||||||
int nv = 0;
|
var nv = 0;
|
||||||
|
|
||||||
for (var j = map.Bounds.Top; j < map.Bounds.Bottom; j++)
|
for (var j = map.Bounds.Top; j < map.Bounds.Bottom; j++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Graphics
|
|||||||
var srcOffset = 0;
|
var srcOffset = 0;
|
||||||
for (var j = 0; j < height; j++)
|
for (var j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < srcStride; i++, srcOffset++)
|
for (var i = 0; i < srcStride; i++, srcOffset++)
|
||||||
{
|
{
|
||||||
data[destOffset] = src[srcOffset];
|
data[destOffset] = src[srcOffset];
|
||||||
destOffset += 4;
|
destOffset += 4;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace OpenRA.Graphics
|
|||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite s = sheetBuilder.Allocate(new Size(su, sv));
|
var s = sheetBuilder.Allocate(new Size(su, sv));
|
||||||
Util.FastCopyIntoChannel(s, 0, colors);
|
Util.FastCopyIntoChannel(s, 0, colors);
|
||||||
Util.FastCopyIntoChannel(s, 1, normals);
|
Util.FastCopyIntoChannel(s, 1, normals);
|
||||||
s.sheet.CommitData();
|
s.sheet.CommitData();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA
|
|||||||
if (!GlobalFileSystem.Exists(package)) { onError("Cannot find " + package); return false; }
|
if (!GlobalFileSystem.Exists(package)) { onError("Cannot find " + package); return false; }
|
||||||
GlobalFileSystem.Mount(package);
|
GlobalFileSystem.Mount(package);
|
||||||
|
|
||||||
foreach (string s in files)
|
foreach (var s in files)
|
||||||
{
|
{
|
||||||
var destFile = Path.Combine(destPath, s);
|
var destFile = Path.Combine(destPath, s);
|
||||||
using (var sourceStream = GlobalFileSystem.Open(s))
|
using (var sourceStream = GlobalFileSystem.Open(s))
|
||||||
@@ -90,7 +90,7 @@ namespace OpenRA
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> extracted = new List<string>();
|
var extracted = new List<string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var stream = File.OpenRead(zipFile))
|
using (var stream = File.OpenRead(zipFile))
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ namespace OpenRA
|
|||||||
var tile = tileset.Templates.First();
|
var tile = tileset.Templates.First();
|
||||||
var tileRef = new TileReference<ushort, byte> { Type = tile.Key, Index = (byte)0 };
|
var tileRef = new TileReference<ushort, byte> { Type = tile.Key, Index = (byte)0 };
|
||||||
|
|
||||||
Map map = new Map()
|
var map = new Map()
|
||||||
{
|
{
|
||||||
Title = "Name your map here",
|
Title = "Name your map here",
|
||||||
Description = "Describe your map here",
|
Description = "Describe your map here",
|
||||||
@@ -364,8 +364,8 @@ namespace OpenRA
|
|||||||
// Load tile data
|
// Load tile data
|
||||||
var data = dataStream.ReadBytes(MapSize.X * MapSize.Y * 3);
|
var data = dataStream.ReadBytes(MapSize.X * MapSize.Y * 3);
|
||||||
var d = 0;
|
var d = 0;
|
||||||
for (int i = 0; i < MapSize.X; i++)
|
for (var i = 0; i < MapSize.X; i++)
|
||||||
for (int j = 0; j < MapSize.Y; j++)
|
for (var j = 0; j < MapSize.Y; j++)
|
||||||
{
|
{
|
||||||
var tile = BitConverter.ToUInt16(data, d);
|
var tile = BitConverter.ToUInt16(data, d);
|
||||||
d += 2;
|
d += 2;
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ namespace OpenRA
|
|||||||
var root = new List<MiniYamlNode>();
|
var root = new List<MiniYamlNode>();
|
||||||
foreach (var field in Fields)
|
foreach (var field in Fields)
|
||||||
{
|
{
|
||||||
FieldInfo f = this.GetType().GetField(field);
|
var f = this.GetType().GetField(field);
|
||||||
if (f.GetValue(this) == null)
|
if (f.GetValue(this) == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static List<MiniYamlNode> FromFileInPackage(string path)
|
public static List<MiniYamlNode> FromFileInPackage(string path)
|
||||||
{
|
{
|
||||||
List<string> lines = new List<string>();
|
var lines = new List<string>();
|
||||||
using (var stream = GlobalFileSystem.Open(path))
|
using (var stream = GlobalFileSystem.Open(path))
|
||||||
using (var reader = new StreamReader(stream))
|
using (var reader = new StreamReader(stream))
|
||||||
while (!reader.EndOfStream)
|
while (!reader.EndOfStream)
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace OpenRA.Network
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < packet.Length; i++)
|
for (var i = 0; i < packet.Length; i++)
|
||||||
{
|
{
|
||||||
if (packet[i] != existingSync[i])
|
if (packet[i] != existingSync[i])
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var p = ctor.GetParameters();
|
var p = ctor.GetParameters();
|
||||||
var a = new object[p.Length];
|
var a = new object[p.Length];
|
||||||
for (int i = 0; i < p.Length; i++)
|
for (var i = 0; i < p.Length; i++)
|
||||||
{
|
{
|
||||||
var key = p[i].Name;
|
var key = p[i].Name;
|
||||||
if (!args.ContainsKey(key)) throw new InvalidOperationException("ObjectCreator: key `{0}' not found".F(key));
|
if (!args.ContainsKey(key)) throw new InvalidOperationException("ObjectCreator: key `{0}' not found".F(key));
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ namespace OpenRA.Primitives
|
|||||||
|
|
||||||
public void Add(T item)
|
public void Add(T item)
|
||||||
{
|
{
|
||||||
int addLevel = level;
|
var addLevel = level;
|
||||||
int addIndex = index;
|
var addIndex = index;
|
||||||
|
|
||||||
while (addLevel >= 1 && Above(addLevel, addIndex).CompareTo(item) > 0)
|
while (addLevel >= 1 && Above(addLevel, addIndex).CompareTo(item) > 0)
|
||||||
{
|
{
|
||||||
@@ -53,8 +53,8 @@ namespace OpenRA.Primitives
|
|||||||
|
|
||||||
T Last()
|
T Last()
|
||||||
{
|
{
|
||||||
int lastLevel = level;
|
var lastLevel = level;
|
||||||
int lastIndex = index;
|
var lastIndex = index;
|
||||||
|
|
||||||
if (--lastIndex < 0)
|
if (--lastIndex < 0)
|
||||||
lastIndex = (1 << --lastLevel) - 1;
|
lastIndex = (1 << --lastLevel) - 1;
|
||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Primitives
|
|||||||
if (level == 0 && index == 0)
|
if (level == 0 && index == 0)
|
||||||
throw new InvalidOperationException("Attempting to pop empty PriorityQueue");
|
throw new InvalidOperationException("Attempting to pop empty PriorityQueue");
|
||||||
|
|
||||||
T ret = At(0, 0);
|
var ret = At(0, 0);
|
||||||
BubbleInto(0, 0, Last());
|
BubbleInto(0, 0, Last());
|
||||||
if (--index < 0)
|
if (--index < 0)
|
||||||
index = (1 << --level) - 1;
|
index = (1 << --level) - 1;
|
||||||
@@ -78,8 +78,8 @@ namespace OpenRA.Primitives
|
|||||||
|
|
||||||
void BubbleInto(int intoLevel, int intoIndex, T val)
|
void BubbleInto(int intoLevel, int intoIndex, T val)
|
||||||
{
|
{
|
||||||
int downLevel = intoLevel + 1;
|
var downLevel = intoLevel + 1;
|
||||||
int downIndex = intoIndex << 1;
|
var downIndex = intoIndex << 1;
|
||||||
|
|
||||||
if (downLevel > level || (downLevel == level && downIndex >= index))
|
if (downLevel > level || (downLevel == level && downIndex >= index))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static bool WithinEpsilon(float2 a, float2 b, float e)
|
public static bool WithinEpsilon(float2 a, float2 b, float e)
|
||||||
{
|
{
|
||||||
float2 d = a - b;
|
var d = a - b;
|
||||||
return Math.Abs(d.X) < e && Math.Abs(d.Y) < e;
|
return Math.Abs(d.X) < e && Math.Abs(d.Y) < e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Scripting
|
|||||||
var mi = (MethodInfo)Member;
|
var mi = (MethodInfo)Member;
|
||||||
var pi = mi.GetParameters();
|
var pi = mi.GetParameters();
|
||||||
|
|
||||||
object[] clrArgs = new object[pi.Length];
|
var clrArgs = new object[pi.Length];
|
||||||
var argCount = args.Count;
|
var argCount = args.Count;
|
||||||
for (var i = 0; i < pi.Length; i++)
|
for (var i = 0; i < pi.Length; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ namespace OpenRA.Server
|
|||||||
{
|
{
|
||||||
case "Command":
|
case "Command":
|
||||||
{
|
{
|
||||||
bool handled = false;
|
var handled = false;
|
||||||
foreach (var t in serverTraits.WithInterface<IInterpretCommand>())
|
foreach (var t in serverTraits.WithInterface<IInterpretCommand>())
|
||||||
if (handled = t.InterpretCommand(this, conn, GetClient(conn), so.Data))
|
if (handled = t.InterpretCommand(this, conn, GetClient(conn), so.Data))
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -533,8 +533,8 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> freeSources = new List<int>();
|
var freeSources = new List<int>();
|
||||||
foreach (int key in sourcePool.Keys)
|
foreach (var key in sourcePool.Keys)
|
||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
AL.GetSource(key, ALGetSourcei.SourceState, out state);
|
AL.GetSource(key, ALGetSourcei.SourceState, out state);
|
||||||
@@ -545,7 +545,7 @@ namespace OpenRA
|
|||||||
if (freeSources.Count == 0)
|
if (freeSources.Count == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
foreach (int i in freeSources)
|
foreach (var i in freeSources)
|
||||||
sourcePool[i].IsActive = false;
|
sourcePool[i].IsActive = false;
|
||||||
|
|
||||||
sourcePool[freeSources[0]].IsActive = true;
|
sourcePool[freeSources[0]].IsActive = true;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA
|
|||||||
var regex = new Regex("([^=]+)=(.*)");
|
var regex = new Regex("([^=]+)=(.*)");
|
||||||
foreach (var s in src)
|
foreach (var s in src)
|
||||||
{
|
{
|
||||||
Match m = regex.Match(s);
|
var m = regex.Match(s);
|
||||||
if (!m.Success)
|
if (!m.Success)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace OpenRA.Support
|
|||||||
|
|
||||||
public IEnumerable<double> Samples()
|
public IEnumerable<double> Samples()
|
||||||
{
|
{
|
||||||
int n = head;
|
var n = head;
|
||||||
while (n != tail)
|
while (n != tail)
|
||||||
{
|
{
|
||||||
--n;
|
--n;
|
||||||
@@ -82,8 +82,8 @@ namespace OpenRA.Support
|
|||||||
|
|
||||||
public double Average(int count)
|
public double Average(int count)
|
||||||
{
|
{
|
||||||
int i = 0;
|
var i = 0;
|
||||||
int n = head;
|
var n = head;
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
while (i < count && n != tail)
|
while (i < count && n != tail)
|
||||||
{
|
{
|
||||||
@@ -98,7 +98,7 @@ namespace OpenRA.Support
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int n = head;
|
var n = head;
|
||||||
if (--n < 0) n = samples.Length - 1;
|
if (--n < 0) n = samples.Length - 1;
|
||||||
return samples[n];
|
return samples[n];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static int hash_tdict(TypeDictionary d)
|
public static int hash_tdict(TypeDictionary d)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
var ret = 0;
|
||||||
foreach (var o in d)
|
foreach (var o in d)
|
||||||
ret += CalculateSyncHash(o);
|
ret += CalculateSyncHash(o);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
public static int BinarySearchMany(this List<Actor> list, uint searchFor)
|
public static int BinarySearchMany(this List<Actor> list, uint searchFor)
|
||||||
{
|
{
|
||||||
int start = 0;
|
var start = 0;
|
||||||
int end = list.Count;
|
var end = list.Count;
|
||||||
int mid = 0;
|
var mid = 0;
|
||||||
while (start != end)
|
while (start != end)
|
||||||
{
|
{
|
||||||
mid = (start + end) / 2;
|
mid = (start + end) / 2;
|
||||||
@@ -172,13 +172,13 @@ namespace OpenRA
|
|||||||
public IEnumerable<TraitPair<T>> All()
|
public IEnumerable<TraitPair<T>> All()
|
||||||
{
|
{
|
||||||
++queries;
|
++queries;
|
||||||
for (int i = 0; i < actors.Count; i++)
|
for (var i = 0; i < actors.Count; i++)
|
||||||
yield return new TraitPair<T> { Actor = actors[i], Trait = traits[i] };
|
yield return new TraitPair<T> { Actor = actors[i], Trait = traits[i] };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveActor(uint actor)
|
public void RemoveActor(uint actor)
|
||||||
{
|
{
|
||||||
for (int i = actors.Count - 1; i >= 0; i--)
|
for (var i = actors.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (actors[i].ActorID == actor)
|
if (actors[i].ActorID == actor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
s = s.ToLowerInvariant();
|
s = s.ToLowerInvariant();
|
||||||
var components = s.Split('c');
|
var components = s.Split('c');
|
||||||
int cell = 0;
|
var cell = 0;
|
||||||
int subcell = 0;
|
var subcell = 0;
|
||||||
result = WRange.Zero;
|
result = WRange.Zero;
|
||||||
|
|
||||||
switch (components.Length)
|
switch (components.Length)
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ namespace OpenRA.Widgets
|
|||||||
if (text == null)
|
if (text == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int2 textSize = font.Measure(text);
|
var textSize = font.Measure(text);
|
||||||
int2 position = RenderOrigin;
|
var position = RenderOrigin;
|
||||||
|
|
||||||
if (VAlign == TextVAlign.Middle)
|
if (VAlign == TextVAlign.Middle)
|
||||||
position += new int2(0, (Bounds.Height - textSize.Y)/2);
|
position += new int2(0, (Bounds.Height - textSize.Y)/2);
|
||||||
|
|||||||
@@ -19,16 +19,16 @@ namespace OpenRA.Widgets
|
|||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
var rect = RenderBounds;
|
var rect = RenderBounds;
|
||||||
float2 origin = new float2(rect.Right, rect.Bottom);
|
var origin = new float2(rect.Right, rect.Bottom);
|
||||||
float2 basis = new float2(-rect.Width / 100, -rect.Height / 100);
|
var basis = new float2(-rect.Width / 100, -rect.Height / 100);
|
||||||
|
|
||||||
Game.Renderer.LineRenderer.DrawLine(origin, origin + new float2(100, 0) * basis, Color.White, Color.White);
|
Game.Renderer.LineRenderer.DrawLine(origin, origin + new float2(100, 0) * basis, Color.White, Color.White);
|
||||||
Game.Renderer.LineRenderer.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, Color.White, Color.White);
|
Game.Renderer.LineRenderer.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, Color.White, Color.White);
|
||||||
|
|
||||||
int k = 0;
|
var k = 0;
|
||||||
foreach (var item in PerfHistory.items.Values.ToArray())
|
foreach (var item in PerfHistory.items.Values.ToArray())
|
||||||
{
|
{
|
||||||
int n = 0;
|
var n = 0;
|
||||||
item.Samples().Aggregate((a, b) =>
|
item.Samples().Aggregate((a, b) =>
|
||||||
{
|
{
|
||||||
Game.Renderer.LineRenderer.DrawLine(
|
Game.Renderer.LineRenderer.DrawLine(
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Widgets
|
|||||||
var percentage = GetPercentage();
|
var percentage = GetPercentage();
|
||||||
WidgetUtils.DrawPanel("progressbar-bg", rb);
|
WidgetUtils.DrawPanel("progressbar-bg", rb);
|
||||||
|
|
||||||
Rectangle barRect = wasIndeterminate ?
|
var barRect = wasIndeterminate ?
|
||||||
new Rectangle(rb.X + 2 + (int)(0.75*offset*(rb.Width - 4)), rb.Y + 2, (rb.Width - 4) / 4, rb.Height - 4) :
|
new Rectangle(rb.X + 2 + (int)(0.75*offset*(rb.Width - 4)), rb.Y + 2, (rb.Width - 4) / 4, rb.Height - 4) :
|
||||||
new Rectangle(rb.X + 2, rb.Y + 2, percentage * (rb.Width - 4) / 100, rb.Height - 4);
|
new Rectangle(rb.X + 2, rb.Y + 2, percentage * (rb.Width - 4) / 100, rb.Height - 4);
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
// Tickmarks
|
// Tickmarks
|
||||||
var tick = ChromeProvider.GetImage("slider", "tick");
|
var tick = ChromeProvider.GetImage("slider", "tick");
|
||||||
for (int i = 0; i < Ticks; i++)
|
for (var i = 0; i < Ticks; i++)
|
||||||
{
|
{
|
||||||
var tickPos = new float2(
|
var tickPos = new float2(
|
||||||
trackOrigin + (i * (trackRect.Width - (int)tick.size.X) / (Ticks - 1)) - tick.size.X / 2,
|
trackOrigin + (i * (trackRect.Width - (int)tick.size.X) / (Ticks - 1)) - tick.size.X / 2,
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ namespace OpenRA.Widgets
|
|||||||
if (textSize.X > Bounds.Width - LeftMargin - RightMargin && HasKeyboardFocus)
|
if (textSize.X > Bounds.Width - LeftMargin - RightMargin && HasKeyboardFocus)
|
||||||
start += Bounds.Width - LeftMargin - RightMargin - textSize.X;
|
start += Bounds.Width - LeftMargin - RightMargin - textSize.X;
|
||||||
|
|
||||||
int minIndex = -1;
|
var minIndex = -1;
|
||||||
int minValue = int.MaxValue;
|
var minValue = int.MaxValue;
|
||||||
for (int i = 0; i <= apparentText.Length; i++)
|
for (var i = 0; i <= apparentText.Length; i++)
|
||||||
{
|
{
|
||||||
var dist = Math.Abs(start + font.Measure(apparentText.Substring(0, i)).X - x);
|
var dist = Math.Abs(start + font.Measure(apparentText.Substring(0, i)).X - x);
|
||||||
if (dist > minValue)
|
if (dist > minValue)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Widgets
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
overlay = new uint[2*textureSize, 2*textureSize];
|
overlay = new uint[2*textureSize, 2*textureSize];
|
||||||
uint black = (uint)255 << 24;
|
var black = (uint)255 << 24;
|
||||||
for (var y = 0; y < video.Height; y++)
|
for (var y = 0; y < video.Height; y++)
|
||||||
for (var x = 0; x < video.Width; x++)
|
for (var x = 0; x < video.Width; x++)
|
||||||
overlay[2*y,x] = black;
|
overlay[2*y,x] = black;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Widgets
|
|||||||
if (mi.Event == MouseInputEvent.Move)
|
if (mi.Event == MouseInputEvent.Move)
|
||||||
MouseOverWidget = null;
|
MouseOverWidget = null;
|
||||||
|
|
||||||
bool handled = false;
|
var handled = false;
|
||||||
if (MouseFocusWidget != null && MouseFocusWidget.HandleMouseInputOuter(mi))
|
if (MouseFocusWidget != null && MouseFocusWidget.HandleMouseInputOuter(mi))
|
||||||
handled = true;
|
handled = true;
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ namespace OpenRA.Widgets
|
|||||||
var selectedTypes = World.Selection.Actors.Where(
|
var selectedTypes = World.Selection.Actors.Where(
|
||||||
x => x.Owner == World.RenderPlayer).Select(a => a.Info);
|
x => x.Owner == World.RenderPlayer).Select(a => a.Info);
|
||||||
Func<Actor, bool> cond = a => a.Owner == World.RenderPlayer && selectedTypes.Contains(a.Info);
|
Func<Actor, bool> cond = a => a.Owner == World.RenderPlayer && selectedTypes.Contains(a.Info);
|
||||||
IEnumerable<Actor> newSelection = SelectActorsInBox(
|
var newSelection = SelectActorsInBox(
|
||||||
World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight, cond);
|
World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight, cond);
|
||||||
if (newSelection.Count() > selectedTypes.Count())
|
if (newSelection.Count() > selectedTypes.Count())
|
||||||
Game.Debug("Selected across screen");
|
Game.Debug("Selected across screen");
|
||||||
|
|||||||
@@ -277,8 +277,8 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
//using (new PerfSample("synchash"))
|
//using (new PerfSample("synchash"))
|
||||||
{
|
{
|
||||||
int n = 0;
|
var n = 0;
|
||||||
int ret = 0;
|
var ret = 0;
|
||||||
|
|
||||||
// hash all the actors
|
// hash all the actors
|
||||||
foreach (var a in Actors)
|
foreach (var a in Actors)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
menu.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
|
menu.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
|
||||||
|
|
||||||
bool hideButtons = false;
|
var hideButtons = false;
|
||||||
menu.Get("MENU_BUTTONS").IsVisible = () => !hideButtons;
|
menu.Get("MENU_BUTTONS").IsVisible = () => !hideButtons;
|
||||||
|
|
||||||
// TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions
|
// TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions
|
||||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
// Menu panels - ordered from lowest to highest priority
|
// Menu panels - ordered from lowest to highest priority
|
||||||
var panelParent = Game.OpenWindow(world, "INGAME_MENU_PANEL");
|
var panelParent = Game.OpenWindow(world, "INGAME_MENU_PANEL");
|
||||||
PanelType panelType = PanelType.Objectives;
|
var panelType = PanelType.Objectives;
|
||||||
var visibleButtons = 0;
|
var visibleButtons = 0;
|
||||||
|
|
||||||
// Debug / Cheats panel
|
// Debug / Cheats panel
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
public void Update(IEnumerable<ProductionQueue> allQueues)
|
public void Update(IEnumerable<ProductionQueue> allQueues)
|
||||||
{
|
{
|
||||||
var queues = allQueues.Where(q => q.Info.Group == Group).ToList();
|
var queues = allQueues.Where(q => q.Info.Group == Group).ToList();
|
||||||
List<ProductionTab> tabs = new List<ProductionTab>();
|
var tabs = new List<ProductionTab>();
|
||||||
|
|
||||||
// Remove stale queues
|
// Remove stale queues
|
||||||
foreach (var t in Tabs)
|
foreach (var t in Tabs)
|
||||||
@@ -165,7 +165,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
// Draw tab buttons
|
// Draw tab buttons
|
||||||
Game.Renderer.EnableScissor(new Rectangle(leftButtonRect.Right, rb.Y + 1, rightButtonRect.Left - leftButtonRect.Right - 1, rb.Height));
|
Game.Renderer.EnableScissor(new Rectangle(leftButtonRect.Right, rb.Y + 1, rightButtonRect.Left - leftButtonRect.Right - 1, rb.Height));
|
||||||
var origin = new int2(leftButtonRect.Right - 1 + (int)listOffset, leftButtonRect.Y);
|
var origin = new int2(leftButtonRect.Right - 1 + (int)listOffset, leftButtonRect.Y);
|
||||||
SpriteFont font = Game.Renderer.Fonts["TinyBold"];
|
var font = Game.Renderer.Fonts["TinyBold"];
|
||||||
contentWidth = 0;
|
contentWidth = 0;
|
||||||
|
|
||||||
foreach (var tab in Groups[queueGroup].Tabs)
|
foreach (var tab in Groups[queueGroup].Tabs)
|
||||||
@@ -176,8 +176,8 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
ButtonWidget.DrawBackground(baseName, rect, false, false, hover, false);
|
ButtonWidget.DrawBackground(baseName, rect, false, false, hover, false);
|
||||||
contentWidth += TabWidth - 1;
|
contentWidth += TabWidth - 1;
|
||||||
|
|
||||||
int2 textSize = font.Measure(tab.Name);
|
var textSize = font.Measure(tab.Name);
|
||||||
int2 position = new int2(rect.X + (rect.Width - textSize.X) / 2, rect.Y + (rect.Height - textSize.Y) / 2);
|
var position = new int2(rect.X + (rect.Width - textSize.X) / 2, rect.Y + (rect.Height - textSize.Y) / 2);
|
||||||
font.DrawTextWithContrast(tab.Name, position, tab.Queue.CurrentDone ? Color.Gold : Color.White, Color.Black, 1);
|
font.DrawTextWithContrast(tab.Name, position, tab.Queue.CurrentDone ? Color.Gold : Color.White, Color.Black, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
|
var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
|
||||||
var pos = self.CenterPosition;
|
var pos = self.CenterPosition;
|
||||||
int i = 0;
|
var i = 0;
|
||||||
foreach (var c in cargo.Passengers)
|
foreach (var c in cargo.Passengers)
|
||||||
{
|
{
|
||||||
var cargoFacing = c.TraitOrDefault<IFacing>();
|
var cargoFacing = c.TraitOrDefault<IFacing>();
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
{
|
{
|
||||||
return RelativeValue(own, enemy, 100, SumOfValues<AttackBase>, (Actor a) =>
|
return RelativeValue(own, enemy, 100, SumOfValues<AttackBase>, (Actor a) =>
|
||||||
{
|
{
|
||||||
int sumOfDamage = 0;
|
var sumOfDamage = 0;
|
||||||
var arms = a.TraitsImplementing<Armament>();
|
var arms = a.TraitsImplementing<Armament>();
|
||||||
foreach (var arm in arms)
|
foreach (var arm in arms)
|
||||||
if (arm.Weapon.Warheads[0] != null)
|
if (arm.Weapon.Warheads[0] != null)
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case BuildingType.Defense:
|
case BuildingType.Defense:
|
||||||
Actor enemyBase = FindEnemyBuildingClosestToPos(baseCenter.CenterPosition);
|
var enemyBase = FindEnemyBuildingClosestToPos(baseCenter.CenterPosition);
|
||||||
return enemyBase != null ? findPos(enemyBase.CenterPosition, defenseCenter) : null;
|
return enemyBase != null ? findPos(enemyBase.CenterPosition, defenseCenter) : null;
|
||||||
|
|
||||||
case BuildingType.Refinery:
|
case BuildingType.Refinery:
|
||||||
@@ -783,9 +783,9 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
var x = (world.Map.MapSize.X % radiusOfPower) == 0 ? world.Map.MapSize.X : world.Map.MapSize.X + radiusOfPower;
|
var x = (world.Map.MapSize.X % radiusOfPower) == 0 ? world.Map.MapSize.X : world.Map.MapSize.X + radiusOfPower;
|
||||||
var y = (world.Map.MapSize.Y % radiusOfPower) == 0 ? world.Map.MapSize.Y : world.Map.MapSize.Y + radiusOfPower;
|
var y = (world.Map.MapSize.Y % radiusOfPower) == 0 ? world.Map.MapSize.Y : world.Map.MapSize.Y + radiusOfPower;
|
||||||
|
|
||||||
for (int i = 0; i < x; i += radiusOfPower * 2)
|
for (var i = 0; i < x; i += radiusOfPower * 2)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < y; j += radiusOfPower * 2)
|
for (var j = 0; j < y; j += radiusOfPower * 2)
|
||||||
{
|
{
|
||||||
var pos = new CPos(i, j);
|
var pos = new CPos(i, j);
|
||||||
var targets = world.FindActorsInCircle(pos.CenterPosition, WRange.FromCells(radiusOfPower)).ToList();
|
var targets = world.FindActorsInCircle(pos.CenterPosition, WRange.FromCells(radiusOfPower)).ToList();
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor leader = owner.units.ClosestTo(owner.Target.CenterPosition);
|
var leader = owner.units.ClosestTo(owner.Target.CenterPosition);
|
||||||
if (leader == null)
|
if (leader == null)
|
||||||
return;
|
return;
|
||||||
var ownUnits = owner.world.FindActorsInCircle(leader.CenterPosition, WRange.FromCells(owner.units.Count) / 3)
|
var ownUnits = owner.world.FindActorsInCircle(leader.CenterPosition, WRange.FromCells(owner.units.Count) / 3)
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
// Determine where to search from and how far to search:
|
// Determine where to search from and how far to search:
|
||||||
var searchFromLoc = harv.LastOrderLocation ?? (harv.LastLinkedProc ?? harv.LinkedProc ?? self).Location;
|
var searchFromLoc = harv.LastOrderLocation ?? (harv.LastLinkedProc ?? harv.LinkedProc ?? self).Location;
|
||||||
int searchRadius = harv.LastOrderLocation.HasValue ? harvInfo.SearchFromOrderRadius : harvInfo.SearchFromProcRadius;
|
var searchRadius = harv.LastOrderLocation.HasValue ? harvInfo.SearchFromOrderRadius : harvInfo.SearchFromProcRadius;
|
||||||
int searchRadiusSquared = searchRadius * searchRadius;
|
var searchRadiusSquared = searchRadius * searchRadius;
|
||||||
|
|
||||||
// Find harvestable resources nearby:
|
// Find harvestable resources nearby:
|
||||||
// Avoid enemy territory:
|
// Avoid enemy territory:
|
||||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (avoidCell.HasValue && loc == avoidCell.Value) return 1;
|
if (avoidCell.HasValue && loc == avoidCell.Value) return 1;
|
||||||
|
|
||||||
// Don't harvest out of range:
|
// Don't harvest out of range:
|
||||||
int distSquared = (loc - searchFromLoc).LengthSquared;
|
var distSquared = (loc - searchFromLoc).LengthSquared;
|
||||||
if (distSquared > searchRadiusSquared)
|
if (distSquared > searchRadiusSquared)
|
||||||
return int.MaxValue;
|
return int.MaxValue;
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
// Get out of the way if we are:
|
// Get out of the way if we are:
|
||||||
harv.UnblockRefinery(self);
|
harv.UnblockRefinery(self);
|
||||||
int randFrames = 125 + self.World.SharedRandom.Next(-35, 35);
|
var randFrames = 125 + self.World.SharedRandom.Next(-35, 35);
|
||||||
if (NextActivity != null)
|
if (NextActivity != null)
|
||||||
return Util.SequenceActivities(NextActivity, new Wait(randFrames), new FindResources());
|
return Util.SequenceActivities(NextActivity, new Wait(randFrames), new FindResources());
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
return destination;
|
return destination;
|
||||||
|
|
||||||
var searched = new List<CPos>();
|
var searched = new List<CPos>();
|
||||||
for (int r = 1; r <= maxCellSearchRange || (maximumDistance != null && r <= maximumDistance); r++)
|
for (var r = 1; r <= maxCellSearchRange || (maximumDistance != null && r <= maximumDistance); r++)
|
||||||
{
|
{
|
||||||
foreach (var tile in self.World.Map.FindTilesInCircle(destination, r).Except(searched))
|
foreach (var tile in self.World.Map.FindTilesInCircle(destination, r).Except(searched))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
.Select(h => GetRepulseForce(self, h))
|
.Select(h => GetRepulseForce(self, h))
|
||||||
.Aggregate(WVec.Zero, (a, b) => a + b);
|
.Aggregate(WVec.Zero, (a, b) => a + b);
|
||||||
|
|
||||||
int repulsionFacing = Util.GetFacing(f, -1);
|
var repulsionFacing = Util.GetFacing(f, -1);
|
||||||
if (repulsionFacing != -1)
|
if (repulsionFacing != -1)
|
||||||
SetPosition(self, CenterPosition + FlyStep(repulsionFacing));
|
SetPosition(self, CenterPosition + FlyStep(repulsionFacing));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop through the map looking for templates to overlay
|
// Loop through the map looking for templates to overlay
|
||||||
for (int i = w.Map.Bounds.Left; i < w.Map.Bounds.Right; i++)
|
for (var i = w.Map.Bounds.Left; i < w.Map.Bounds.Right; i++)
|
||||||
for (int j = w.Map.Bounds.Top; j < w.Map.Bounds.Bottom; j++)
|
for (var j = w.Map.Bounds.Top; j < w.Map.Bounds.Bottom; j++)
|
||||||
if (BridgeTypes.Keys.Contains(w.Map.MapTiles.Value[i, j].Type))
|
if (BridgeTypes.Keys.Contains(w.Map.MapTiles.Value[i, j].Type))
|
||||||
ConvertBridgeToActor(w, i, j);
|
ConvertBridgeToActor(w, i, j);
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
{
|
{
|
||||||
if( footprint.Length != dim.X * dim.Y )
|
if( footprint.Length != dim.X * dim.Y )
|
||||||
throw new InvalidOperationException( "Invalid footprint for " + name );
|
throw new InvalidOperationException( "Invalid footprint for " + name );
|
||||||
int index = 0;
|
var index = 0;
|
||||||
|
|
||||||
for( int y = 0 ; y < dim.Y ; y++ )
|
for( var y = 0 ; y < dim.Y ; y++ )
|
||||||
for( int x = 0 ; x < dim.X ; x++ )
|
for( var x = 0 ; x < dim.X ; x++ )
|
||||||
if( cond( footprint[ index++ ] ) )
|
if( cond( footprint[ index++ ] ) )
|
||||||
yield return new CVec(x, y);
|
yield return new CVec(x, y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
// TODO: First make it work, then make it nice
|
// TODO: First make it work, then make it nice
|
||||||
var vecs = new[] { new CVec(1, 0), new CVec(0, 1), new CVec(-1, 0), new CVec(0, -1) };
|
var vecs = new[] { new CVec(1, 0), new CVec(0, 1), new CVec(-1, 0), new CVec(0, -1) };
|
||||||
int[] dirs = { 0, 0, 0, 0 };
|
int[] dirs = { 0, 0, 0, 0 };
|
||||||
for (int d = 0; d < 4; d++)
|
for (var d = 0; d < 4; d++)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < lbi.Range; i++)
|
for (var i = 1; i < lbi.Range; i++)
|
||||||
{
|
{
|
||||||
if (dirs[d] != 0)
|
if (dirs[d] != 0)
|
||||||
continue;
|
continue;
|
||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
|
|
||||||
// Place intermediate-line sections
|
// Place intermediate-line sections
|
||||||
if (dirs[d] > 0)
|
if (dirs[d] > 0)
|
||||||
for (int i = 1; i < dirs[d]; i++)
|
for (var i = 1; i < dirs[d]; i++)
|
||||||
yield return topLeft + i * vecs[d];
|
yield return topLeft + i * vecs[d];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var numPips = Info.PipCount;
|
var numPips = Info.PipCount;
|
||||||
|
|
||||||
for (int i = 0; i < numPips; i++)
|
for (var i = 0; i < numPips; i++)
|
||||||
yield return GetPipAt(i);
|
yield return GetPipAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (!refs.ContainsKey(loc)) return 0;
|
if (!refs.ContainsKey(loc)) return 0;
|
||||||
|
|
||||||
int occupancy = refs[loc].Occupancy;
|
var occupancy = refs[loc].Occupancy;
|
||||||
// 4 harvesters clogs up the refinery's delivery location:
|
// 4 harvesters clogs up the refinery's delivery location:
|
||||||
if (occupancy >= 3) return int.MaxValue;
|
if (occupancy >= 3) return int.MaxValue;
|
||||||
|
|
||||||
@@ -410,9 +410,9 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public IEnumerable<PipType> GetPips(Actor self)
|
public IEnumerable<PipType> GetPips(Actor self)
|
||||||
{
|
{
|
||||||
int numPips = Info.PipCount;
|
var numPips = Info.PipCount;
|
||||||
|
|
||||||
for (int i = 0; i < numPips; i++)
|
for (var i = 0; i < numPips; i++)
|
||||||
yield return GetPipAt(i);
|
yield return GetPipAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
static object LoadSpeeds(MiniYaml y)
|
static object LoadSpeeds(MiniYaml y)
|
||||||
{
|
{
|
||||||
Dictionary<string, TerrainInfo> ret = new Dictionary<string, TerrainInfo>();
|
var ret = new Dictionary<string, TerrainInfo>();
|
||||||
foreach (var t in y.ToDictionary()["TerrainSpeeds"].Nodes)
|
foreach (var t in y.ToDictionary()["TerrainSpeeds"].Nodes)
|
||||||
{
|
{
|
||||||
var speed = FieldLoader.GetValue<decimal>("speed", t.Value.Value);
|
var speed = FieldLoader.GetValue<decimal>("speed", t.Value.Value);
|
||||||
@@ -165,8 +165,8 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
if (checkTransientActors)
|
if (checkTransientActors)
|
||||||
{
|
{
|
||||||
bool canIgnoreMovingAllies = self != null && !blockedByMovers;
|
var canIgnoreMovingAllies = self != null && !blockedByMovers;
|
||||||
bool needsCellExclusively = self == null || Crushes == null;
|
var needsCellExclusively = self == null || Crushes == null;
|
||||||
foreach(var a in world.ActorMap.GetUnitsAt(cell))
|
foreach(var a in world.ActorMap.GetUnitsAt(cell))
|
||||||
{
|
{
|
||||||
if (a == ignoreActor) continue;
|
if (a == ignoreActor) continue;
|
||||||
@@ -323,7 +323,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
var searched = new List<CPos>();
|
var searched = new List<CPos>();
|
||||||
// Limit search to a radius of 10 tiles
|
// Limit search to a radius of 10 tiles
|
||||||
for (int r = minRange; r < maxRange; r++)
|
for (var r = minRange; r < maxRange; r++)
|
||||||
{
|
{
|
||||||
foreach (var tile in self.World.Map.FindTilesInCircle(target, r).Except(searched))
|
foreach (var tile in self.World.Map.FindTilesInCircle(target, r).Except(searched))
|
||||||
{
|
{
|
||||||
@@ -344,7 +344,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
return target;
|
return target;
|
||||||
|
|
||||||
var searched = new List<CPos>();
|
var searched = new List<CPos>();
|
||||||
for (int r = minRange; r < maxRange; r++)
|
for (var r = minRange; r < maxRange; r++)
|
||||||
{
|
{
|
||||||
foreach (var tile in self.World.Map.FindTilesInCircle(target, r).Except(searched))
|
foreach (var tile in self.World.Map.FindTilesInCircle(target, r).Except(searched))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
static int HashList<T>(List<T> xs)
|
static int HashList<T>(List<T> xs)
|
||||||
{
|
{
|
||||||
int hash = 0;
|
var hash = 0;
|
||||||
int n = 0;
|
var n = 0;
|
||||||
foreach (var x in xs)
|
foreach (var x in xs)
|
||||||
hash += n++ * x.GetHashCode();
|
hash += n++ * x.GetHashCode();
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
static List<CPos> MakePath(CellInfo[,] cellInfo, CPos destination)
|
static List<CPos> MakePath(CellInfo[,] cellInfo, CPos destination)
|
||||||
{
|
{
|
||||||
var ret = new List<CPos>();
|
var ret = new List<CPos>();
|
||||||
CPos pathNode = destination;
|
var pathNode = destination;
|
||||||
|
|
||||||
while (cellInfo[pathNode.X, pathNode.Y].Path != pathNode)
|
while (cellInfo[pathNode.X, pathNode.Y].Path != pathNode)
|
||||||
{
|
{
|
||||||
@@ -248,7 +248,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
if (path.Count == 0)
|
if (path.Count == 0)
|
||||||
return;
|
return;
|
||||||
var prev = path[0];
|
var prev = path[0];
|
||||||
for (int i = 0; i < path.Count; i++)
|
for (var i = 0; i < path.Count; i++)
|
||||||
{
|
{
|
||||||
var d = path[i] - prev;
|
var d = path[i] - prev;
|
||||||
if (Math.Abs(d.X) > 1 || Math.Abs(d.Y) > 1)
|
if (Math.Abs(d.X) > 1 || Math.Abs(d.Y) > 1)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
if (customCost != null)
|
if (customCost != null)
|
||||||
{
|
{
|
||||||
int c = customCost(p.Location);
|
var c = customCost(p.Location);
|
||||||
if (c == int.MaxValue)
|
if (c == int.MaxValue)
|
||||||
return p.Location;
|
return p.Location;
|
||||||
}
|
}
|
||||||
@@ -116,12 +116,12 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
// This current cell is ok; check all immediate directions:
|
// This current cell is ok; check all immediate directions:
|
||||||
considered.Add(p.Location);
|
considered.Add(p.Location);
|
||||||
|
|
||||||
for (int i = 0; i < nextDirections.Length; ++i)
|
for (var i = 0; i < nextDirections.Length; ++i)
|
||||||
{
|
{
|
||||||
CVec d = nextDirections[i].First;
|
var d = nextDirections[i].First;
|
||||||
nextDirections[i].Second = int.MaxValue;
|
nextDirections[i].Second = int.MaxValue;
|
||||||
|
|
||||||
CPos newHere = p.Location + d;
|
var newHere = p.Location + d;
|
||||||
|
|
||||||
// Is this direction flat-out unusable or already seen?
|
// Is this direction flat-out unusable or already seen?
|
||||||
if (!world.Map.IsInMap(newHere.X, newHere.Y))
|
if (!world.Map.IsInMap(newHere.X, newHere.Y))
|
||||||
@@ -145,10 +145,10 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
if (est == int.MaxValue)
|
if (est == int.MaxValue)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int cellCost = costHere;
|
var cellCost = costHere;
|
||||||
if (d.X * d.Y != 0) cellCost = (cellCost * 34) / 24;
|
if (d.X * d.Y != 0) cellCost = (cellCost * 34) / 24;
|
||||||
|
|
||||||
int userCost = 0;
|
var userCost = 0;
|
||||||
if (customCost != null)
|
if (customCost != null)
|
||||||
{
|
{
|
||||||
userCost = customCost(newHere);
|
userCost = customCost(newHere);
|
||||||
@@ -167,7 +167,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
else if (uy == 1 && d.X > 0) cellCost += LaneBias;
|
else if (uy == 1 && d.X > 0) cellCost += LaneBias;
|
||||||
}
|
}
|
||||||
|
|
||||||
int newCost = cellInfo[p.Location.X, p.Location.Y].MinCost + cellCost;
|
var newCost = cellInfo[p.Location.X, p.Location.Y].MinCost + cellCost;
|
||||||
|
|
||||||
// Cost is even higher; next direction:
|
// Cost is even higher; next direction:
|
||||||
if (newCost > cellInfo[newHere.X, newHere.Y].MinCost)
|
if (newCost > cellInfo[newHere.X, newHere.Y].MinCost)
|
||||||
@@ -267,8 +267,8 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
if (result == null)
|
if (result == null)
|
||||||
result = new CellInfo[world.Map.MapSize.X, world.Map.MapSize.Y];
|
result = new CellInfo[world.Map.MapSize.X, world.Map.MapSize.Y];
|
||||||
|
|
||||||
for (int x = 0; x < world.Map.MapSize.X; x++)
|
for (var x = 0; x < world.Map.MapSize.X; x++)
|
||||||
for (int y = 0; y < world.Map.MapSize.Y; y++)
|
for (var y = 0; y < world.Map.MapSize.Y; y++)
|
||||||
result[ x, y ] = new CellInfo( int.MaxValue, new CPos( x, y ), false );
|
result[ x, y ] = new CellInfo( int.MaxValue, new CPos( x, y ), false );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -278,9 +278,9 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
{
|
{
|
||||||
return here =>
|
return here =>
|
||||||
{
|
{
|
||||||
int diag = Math.Min(Math.Abs(here.X - destination.X), Math.Abs(here.Y - destination.Y));
|
var diag = Math.Min(Math.Abs(here.X - destination.X), Math.Abs(here.Y - destination.Y));
|
||||||
int straight = (Math.Abs(here.X - destination.X) + Math.Abs(here.Y - destination.Y));
|
var straight = (Math.Abs(here.X - destination.X) + Math.Abs(here.Y - destination.Y));
|
||||||
int h = (3400 * diag / 24) + 100 * (straight - (2 * diag));
|
var h = (3400 * diag / 24) + 100 * (straight - (2 * diag));
|
||||||
h = (int)(h * 1.001);
|
h = (int)(h * 1.001);
|
||||||
return h;
|
return h;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
if (order.OrderString == "LineBuild")
|
if (order.OrderString == "LineBuild")
|
||||||
{
|
{
|
||||||
bool playSounds = true;
|
var playSounds = true;
|
||||||
foreach (var t in BuildingUtils.GetLineBuildCells(w, order.TargetLocation, order.TargetString, buildingInfo))
|
foreach (var t in BuildingUtils.GetLineBuildCells(w, order.TargetLocation, order.TargetString, buildingInfo))
|
||||||
{
|
{
|
||||||
var building = w.CreateActor(order.TargetString, new TypeDictionary
|
var building = w.CreateActor(order.TargetString, new TypeDictionary
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
for (var n = 0; n < amountToBuild; n++) // repeat count
|
for (var n = 0; n < amountToBuild; n++) // repeat count
|
||||||
{
|
{
|
||||||
bool hasPlayedSound = false;
|
var hasPlayedSound = false;
|
||||||
BeginProduction(new ProductionItem(this, order.TargetString, cost, PlayerPower,
|
BeginProduction(new ProductionItem(this, order.TargetString, cost, PlayerPower,
|
||||||
() => self.World.AddFrameEndTask(_ =>
|
() => self.World.AddFrameEndTask(_ =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public IEnumerable<PipType> GetPips(Actor self)
|
public IEnumerable<PipType> GetPips(Actor self)
|
||||||
{
|
{
|
||||||
const int numPips = 2;
|
const int numPips = 2;
|
||||||
for (int i = 0; i < numPips; i++)
|
for (var i = 0; i < numPips; i++)
|
||||||
{
|
{
|
||||||
if ((1 - chargeTick * 1.0f / (25 * Info.ChargeTime)) * numPips < i + 1)
|
if ((1 - chargeTick * 1.0f / (25 * Info.ChargeTime)) * numPips < i + 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
"function will be called as func().")]
|
"function will be called as func().")]
|
||||||
public void OnAllKilled(LuaTable actors, LuaFunction func)
|
public void OnAllKilled(LuaTable actors, LuaFunction func)
|
||||||
{
|
{
|
||||||
List<Actor> group = new List<Actor>();
|
var group = new List<Actor>();
|
||||||
foreach (var kv in actors)
|
foreach (var kv in actors)
|
||||||
{
|
{
|
||||||
Actor actor;
|
Actor actor;
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
// - Players who now lack a slot are made observers
|
// - Players who now lack a slot are made observers
|
||||||
// - Bots who now lack a slot are dropped
|
// - Bots who now lack a slot are dropped
|
||||||
var slots = server.LobbyInfo.Slots.Keys.ToArray();
|
var slots = server.LobbyInfo.Slots.Keys.ToArray();
|
||||||
int i = 0;
|
var i = 0;
|
||||||
foreach (var os in oldSlots)
|
foreach (var os in oldSlots)
|
||||||
{
|
{
|
||||||
var c = server.LobbyInfo.ClientInSlot(os);
|
var c = server.LobbyInfo.ClientInSlot(os);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA
|
|||||||
Actor flare = null;
|
Actor flare = null;
|
||||||
Actor camera = null;
|
Actor camera = null;
|
||||||
Beacon beacon = null;
|
Beacon beacon = null;
|
||||||
Dictionary<Actor, bool> aircraftInRange = new Dictionary<Actor, bool>();
|
var aircraftInRange = new Dictionary<Actor, bool>();
|
||||||
|
|
||||||
Action<Actor> onEnterRange = a =>
|
Action<Actor> onEnterRange = a =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
RefreshGranted();
|
RefreshGranted();
|
||||||
|
|
||||||
foreach (TraitPair<GpsWatcher> i in atek.World.ActorsWithTrait<GpsWatcher>())
|
foreach (var i in atek.World.ActorsWithTrait<GpsWatcher>())
|
||||||
i.Trait.RefreshGranted();
|
i.Trait.RefreshGranted();
|
||||||
|
|
||||||
if ((Granted || GrantedAllies) && atek.Owner.IsAlliedWith(atek.World.RenderPlayer))
|
if ((Granted || GrantedAllies) && atek.Owner.IsAlliedWith(atek.World.RenderPlayer))
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
||||||
{
|
{
|
||||||
int range = ((IronCurtainPowerInfo)Info).Range;
|
var range = ((IronCurtainPowerInfo)Info).Range;
|
||||||
var tiles = self.World.Map.FindTilesInCircle(xy, range);
|
var tiles = self.World.Map.FindTilesInCircle(xy, range);
|
||||||
var units = new List<Actor>();
|
var units = new List<Actor>();
|
||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA
|
|||||||
for (var i = 0; i < n.Length / 3; i++)
|
for (var i = 0; i < n.Length / 3; i++)
|
||||||
{
|
{
|
||||||
data[i] = 0xFF000000;
|
data[i] = 0xFF000000;
|
||||||
for (int j = 0; j < 3; j++)
|
for (var j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
var t = (n[3*i + j] + 1) / 2;
|
var t = (n[3*i + j] + 1) / 2;
|
||||||
data[i] |= (uint)((byte)(t*0xFF + 0.5) << (8*channel[j]));
|
data[i] |= (uint)((byte)(t*0xFF + 0.5) << (8*channel[j]));
|
||||||
|
|||||||
@@ -203,8 +203,8 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
{
|
{
|
||||||
buttons.Clear();
|
buttons.Clear();
|
||||||
|
|
||||||
string paletteCollection = "palette-" + world.LocalPlayer.Country.Race;
|
var paletteCollection = "palette-" + world.LocalPlayer.Country.Race;
|
||||||
float2 origin = new float2(paletteOrigin.X + 9, paletteOrigin.Y + 9);
|
var origin = new float2(paletteOrigin.X + 9, paletteOrigin.Y + 9);
|
||||||
var iconOffset = 0.5f * new float2(IconWidth, IconHeight);
|
var iconOffset = 0.5f * new float2(IconWidth, IconHeight);
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var y = 0;
|
var y = 0;
|
||||||
@@ -296,7 +296,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-top"),
|
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-top"),
|
||||||
new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 23));
|
new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 23));
|
||||||
|
|
||||||
for (int i = 0; i < numActualRows; i++)
|
for (var i = 0; i < numActualRows; i++)
|
||||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-" + (i % 4)),
|
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-" + (i % 4)),
|
||||||
new float2(Game.Renderer.Resolution.Width - 14, origin.Y + IconHeight * i));
|
new float2(Game.Renderer.Resolution.Width - 14, origin.Y + IconHeight * i));
|
||||||
|
|
||||||
@@ -401,7 +401,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
if (producing.Paused || producing.Done || producing.TotalCost == producing.RemainingCost)
|
if (producing.Paused || producing.Done || producing.TotalCost == producing.RemainingCost)
|
||||||
{
|
{
|
||||||
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, world.LocalPlayer.Country.Race);
|
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, world.LocalPlayer.Country.Race);
|
||||||
int numberToCancel = Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1;
|
var numberToCancel = Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1;
|
||||||
|
|
||||||
world.IssueOrder(Order.CancelProduction(CurrentQueue.self, item, numberToCancel));
|
world.IssueOrder(Order.CancelProduction(CurrentQueue.self, item, numberToCancel));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int* c = (int*)bitmapData.Scan0;
|
var c = (int*)bitmapData.Scan0;
|
||||||
for (var h = 0; h < 256; h++)
|
for (var h = 0; h < 256; h++)
|
||||||
*(c + h) = HSLColor.FromHSV(h / 255f, 1, 1).RGB.ToArgb();
|
*(c + h) = HSLColor.FromHSV(h / 255f, 1, 1).RGB.ToArgb();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
template.Bounds.Height += dh;
|
template.Bounds.Height += dh;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool scrolledToBottom = chatScrollPanel.ScrolledToBottom;
|
var scrolledToBottom = chatScrollPanel.ScrolledToBottom;
|
||||||
chatScrollPanel.AddChild(template);
|
chatScrollPanel.AddChild(template);
|
||||||
if (scrolledToBottom)
|
if (scrolledToBottom)
|
||||||
chatScrollPanel.ScrollToBottom();
|
chatScrollPanel.ScrollToBottom();
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
});
|
});
|
||||||
var diplomacyButton = playerWidgets.Get<ButtonWidget>("INGAME_DIPLOMACY_BUTTON");
|
var diplomacyButton = playerWidgets.Get<ButtonWidget>("INGAME_DIPLOMACY_BUTTON");
|
||||||
diplomacyButton.OnClick = () => diplomacy.Visible ^= true;
|
diplomacyButton.OnClick = () => diplomacy.Visible ^= true;
|
||||||
int validPlayers = 0;
|
var validPlayers = 0;
|
||||||
validPlayers = world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count();
|
validPlayers = world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count();
|
||||||
diplomacyButton.IsVisible = () => validPlayers > 0;
|
diplomacyButton.IsVisible = () => validPlayers > 0;
|
||||||
|
|
||||||
@@ -111,8 +111,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
objectivesButton.OnClick += () => objectivesWidget.Visible ^= true;
|
objectivesButton.OnClick += () => objectivesWidget.Visible ^= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool radarActive = false;
|
var radarActive = false;
|
||||||
RadarBinState binState = RadarBinState.Closed;
|
var binState = RadarBinState.Closed;
|
||||||
var radarBin = playerWidgets.Get<SlidingContainerWidget>("INGAME_RADAR_BIN");
|
var radarBin = playerWidgets.Get<SlidingContainerWidget>("INGAME_RADAR_BIN");
|
||||||
radarBin.IsOpen = () => radarActive || binState > RadarBinState.BinAnimating;
|
radarBin.IsOpen = () => radarActive || binState > RadarBinState.BinAnimating;
|
||||||
radarBin.AfterOpen = () => binState = RadarBinState.RadarAnimating;
|
radarBin.AfterOpen = () => binState = RadarBinState.RadarAnimating;
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
if (skirmishMode)
|
if (skirmishMode)
|
||||||
disconnectButton.Text = "Cancel";
|
disconnectButton.Text = "Cancel";
|
||||||
|
|
||||||
bool teamChat = false;
|
var teamChat = false;
|
||||||
var chatLabel = lobby.Get<LabelWidget>("LABEL_CHATTYPE");
|
var chatLabel = lobby.Get<LabelWidget>("LABEL_CHATTYPE");
|
||||||
var chatTextField = lobby.Get<TextFieldWidget>("CHAT_TEXTFIELD");
|
var chatTextField = lobby.Get<TextFieldWidget>("CHAT_TEXTFIELD");
|
||||||
|
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
before();
|
before();
|
||||||
|
|
||||||
int spectatorCount = orderManager.LobbyInfo.Clients.Count(c => c.IsObserver);
|
var spectatorCount = orderManager.LobbyInfo.Clients.Count(c => c.IsObserver);
|
||||||
if (spectatorCount > 0)
|
if (spectatorCount > 0)
|
||||||
{
|
{
|
||||||
Game.LoadWidget(null, "KICK_SPECTATORS_DIALOG", lobby, new WidgetArgs
|
Game.LoadWidget(null, "KICK_SPECTATORS_DIALOG", lobby, new WidgetArgs
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
if (games == null)
|
if (games == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<Widget> rows = new List<Widget>();
|
var rows = new List<Widget>();
|
||||||
|
|
||||||
foreach (var loop in games.OrderByDescending(g => g.CanJoin()).ThenByDescending(g => g.Players))
|
foreach (var loop in games.OrderByDescending(g => g.CanJoin()).ThenByDescending(g => g.Players))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
public Player FindFirstWinningPlayer(World world)
|
public Player FindFirstWinningPlayer(World world)
|
||||||
{
|
{
|
||||||
// loop through all players, see who is 'winning' and get the one with the shortest 'time to win'
|
// loop through all players, see who is 'winning' and get the one with the shortest 'time to win'
|
||||||
int shortest = int.MaxValue;
|
var shortest = int.MaxValue;
|
||||||
Player shortestPlayer = null;
|
Player shortestPlayer = null;
|
||||||
|
|
||||||
foreach (var p in world.Players.Where(p => !p.NonCombatant))
|
foreach (var p in world.Players.Where(p => !p.NonCombatant))
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (!transientConnections.ContainsKey(current))
|
if (!transientConnections.ContainsKey(current))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (int neighbor in transientConnections[current])
|
foreach (var neighbor in transientConnections[current])
|
||||||
{
|
{
|
||||||
if (neighbor == d2)
|
if (neighbor == d2)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ namespace OpenRA.Renderer.Sdl2
|
|||||||
var versionString = GL.GetString(StringName.Version);
|
var versionString = GL.GetString(StringName.Version);
|
||||||
var version = versionString.Contains(" ") ? versionString.Split(' ')[0].Split('.') : versionString.Split('.');
|
var version = versionString.Contains(" ") ? versionString.Split(' ')[0].Split('.') : versionString.Split('.');
|
||||||
|
|
||||||
int major = 0;
|
var major = 0;
|
||||||
if (version.Length > 0)
|
if (version.Length > 0)
|
||||||
int.TryParse(version[0], out major);
|
int.TryParse(version[0], out major);
|
||||||
|
|
||||||
int minor = 0;
|
var minor = 0;
|
||||||
if (version.Length > 1)
|
if (version.Length > 1)
|
||||||
int.TryParse(version[1], out minor);
|
int.TryParse(version[1], out minor);
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Renderer.Sdl2
|
|||||||
GL.GetProgram(program, ProgramParameter.ActiveUniforms, out numUniforms);
|
GL.GetProgram(program, ProgramParameter.ActiveUniforms, out numUniforms);
|
||||||
ErrorHandler.CheckGlError();
|
ErrorHandler.CheckGlError();
|
||||||
|
|
||||||
int nextTexUnit = 0;
|
var nextTexUnit = 0;
|
||||||
for (var i = 0; i < numUniforms; i++)
|
for (var i = 0; i < numUniforms; i++)
|
||||||
{
|
{
|
||||||
int length, size;
|
int length, size;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace OpenRA.Renderer.Sdl2
|
|||||||
{
|
{
|
||||||
fixed (byte* ptr = &colors[0])
|
fixed (byte* ptr = &colors[0])
|
||||||
{
|
{
|
||||||
IntPtr intPtr = new IntPtr((void*)ptr);
|
var intPtr = new IntPtr((void*)ptr);
|
||||||
PrepareTexture();
|
PrepareTexture();
|
||||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, width, height,
|
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, width, height,
|
||||||
0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, intPtr);
|
0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, intPtr);
|
||||||
@@ -83,8 +83,8 @@ namespace OpenRA.Renderer.Sdl2
|
|||||||
// An array of RGBA
|
// An array of RGBA
|
||||||
public void SetData(uint[,] colors)
|
public void SetData(uint[,] colors)
|
||||||
{
|
{
|
||||||
int width = colors.GetUpperBound(1) + 1;
|
var width = colors.GetUpperBound(1) + 1;
|
||||||
int height = colors.GetUpperBound(0) + 1;
|
var height = colors.GetUpperBound(0) + 1;
|
||||||
|
|
||||||
if (!Exts.IsPowerOf2(width) || !Exts.IsPowerOf2(height))
|
if (!Exts.IsPowerOf2(width) || !Exts.IsPowerOf2(height))
|
||||||
throw new InvalidDataException("Non-power-of-two array {0}x{1}".F(width, height));
|
throw new InvalidDataException("Non-power-of-two array {0}x{1}".F(width, height));
|
||||||
@@ -94,7 +94,7 @@ namespace OpenRA.Renderer.Sdl2
|
|||||||
{
|
{
|
||||||
fixed (uint* ptr = &colors[0, 0])
|
fixed (uint* ptr = &colors[0, 0])
|
||||||
{
|
{
|
||||||
IntPtr intPtr = new IntPtr((void*)ptr);
|
var intPtr = new IntPtr((void*)ptr);
|
||||||
PrepareTexture();
|
PrepareTexture();
|
||||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, width, height,
|
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, width, height,
|
||||||
0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, intPtr);
|
0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, intPtr);
|
||||||
@@ -105,7 +105,7 @@ namespace OpenRA.Renderer.Sdl2
|
|||||||
|
|
||||||
public void SetData(Bitmap bitmap)
|
public void SetData(Bitmap bitmap)
|
||||||
{
|
{
|
||||||
bool allocatedBitmap = false;
|
var allocatedBitmap = false;
|
||||||
if (!Exts.IsPowerOf2(bitmap.Width) || !Exts.IsPowerOf2(bitmap.Height))
|
if (!Exts.IsPowerOf2(bitmap.Width) || !Exts.IsPowerOf2(bitmap.Height))
|
||||||
{
|
{
|
||||||
bitmap = new Bitmap(bitmap, bitmap.Size.NextPowerOf2());
|
bitmap = new Bitmap(bitmap, bitmap.Size.NextPowerOf2());
|
||||||
@@ -140,7 +140,7 @@ namespace OpenRA.Renderer.Sdl2
|
|||||||
{
|
{
|
||||||
fixed (byte* ptr = &data[0])
|
fixed (byte* ptr = &data[0])
|
||||||
{
|
{
|
||||||
IntPtr intPtr = new IntPtr((void*)ptr);
|
var intPtr = new IntPtr((void*)ptr);
|
||||||
GL.GetTexImage(TextureTarget.Texture2D, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, intPtr);
|
GL.GetTexImage(TextureTarget.Texture2D, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, intPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,13 +78,13 @@ namespace OpenRA.TilesetBuilder
|
|||||||
public FormBuilder(string src, string tsize, bool autoExport, string outputDir)
|
public FormBuilder(string src, string tsize, bool autoExport, string outputDir)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Dictionary<string, TerrainTypeInfo> terrainDefinition = new Dictionary<string, TerrainTypeInfo>();
|
var terrainDefinition = new Dictionary<string, TerrainTypeInfo>();
|
||||||
|
|
||||||
int size = int.Parse(tsize);
|
var size = int.Parse(tsize);
|
||||||
|
|
||||||
var yaml = MiniYaml.DictFromFile("OpenRA.TilesetBuilder/defaults.yaml");
|
var yaml = MiniYaml.DictFromFile("OpenRA.TilesetBuilder/defaults.yaml");
|
||||||
terrainDefinition = yaml["Terrain"].ToDictionary().Values.Select(y => new TerrainTypeInfo(y)).ToDictionary(t => t.Type);
|
terrainDefinition = yaml["Terrain"].ToDictionary().Values.Select(y => new TerrainTypeInfo(y)).ToDictionary(t => t.Type);
|
||||||
int i = 0;
|
var i = 0;
|
||||||
surface1.Icon = new Bitmap[terrainDefinition.Keys.Count];
|
surface1.Icon = new Bitmap[terrainDefinition.Keys.Count];
|
||||||
TerrainType = new TerrainTypeInfo[terrainDefinition.Keys.Count];
|
TerrainType = new TerrainTypeInfo[terrainDefinition.Keys.Count];
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ namespace OpenRA.TilesetBuilder
|
|||||||
{
|
{
|
||||||
for (var y = 0; y < icon.Height; y++)
|
for (var y = 0; y < icon.Height; y++)
|
||||||
{
|
{
|
||||||
Color newColor = deftype.Value.Color;
|
var newColor = deftype.Value.Color;
|
||||||
icon.SetPixel(x, y, newColor);
|
icon.SetPixel(x, y, newColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -277,7 +277,7 @@ namespace OpenRA.TilesetBuilder
|
|||||||
bw.Write((uint)0); // walk start
|
bw.Write((uint)0); // walk start
|
||||||
bw.Write((uint)0); // index start
|
bw.Write((uint)0); // index start
|
||||||
|
|
||||||
Bitmap src = surface1.Image.Clone(new Rectangle(0, 0, surface1.Image.Width, surface1.Image.Height),
|
var src = surface1.Image.Clone(new Rectangle(0, 0, surface1.Image.Width, surface1.Image.Height),
|
||||||
surface1.Image.PixelFormat);
|
surface1.Image.PixelFormat);
|
||||||
|
|
||||||
var data = src.LockBits(new Rectangle(0, 0, src.Width, src.Height),
|
var data = src.LockBits(new Rectangle(0, 0, src.Width, src.Height),
|
||||||
@@ -285,14 +285,14 @@ namespace OpenRA.TilesetBuilder
|
|||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
byte* p = (byte*)data.Scan0;
|
var p = (byte*)data.Scan0;
|
||||||
|
|
||||||
for (var v = 0; v < t.Height; v++)
|
for (var v = 0; v < t.Height; v++)
|
||||||
for (var u = 0; u < t.Width; u++)
|
for (var u = 0; u < t.Width; u++)
|
||||||
{
|
{
|
||||||
if (t.Cells.ContainsKey(new int2(u + t.Left, v + t.Top)))
|
if (t.Cells.ContainsKey(new int2(u + t.Left, v + t.Top)))
|
||||||
{
|
{
|
||||||
byte* q = p + data.Stride * tileSize * (v + t.Top) + tileSize * (u + t.Left);
|
var q = p + data.Stride * tileSize * (v + t.Top) + tileSize * (u + t.Left);
|
||||||
for (var j = 0; j < tileSize; j++)
|
for (var j = 0; j < tileSize; j++)
|
||||||
for (var i = 0; i < tileSize; i++)
|
for (var i = 0; i < tileSize; i++)
|
||||||
{
|
{
|
||||||
@@ -372,7 +372,7 @@ namespace OpenRA.TilesetBuilder
|
|||||||
);
|
);
|
||||||
|
|
||||||
// List of files to add to the mix file
|
// List of files to add to the mix file
|
||||||
List<string> fileList = new List<string>();
|
var fileList = new List<string>();
|
||||||
|
|
||||||
// Export palette (use the embedded palette)
|
// Export palette (use the embedded palette)
|
||||||
var p = surface1.Image.Palette.Entries.ToList();
|
var p = surface1.Image.Palette.Entries.ToList();
|
||||||
@@ -389,7 +389,7 @@ namespace OpenRA.TilesetBuilder
|
|||||||
var tiles = new int[tp.Width * tp.Height];
|
var tiles = new int[tp.Width * tp.Height];
|
||||||
foreach (var t in tp.Cells)
|
foreach (var t in tp.Cells)
|
||||||
{
|
{
|
||||||
string ttype = TerrainType[surface1.TerrainTypes[t.Key.X, t.Key.Y]].Type;
|
var ttype = TerrainType[surface1.TerrainTypes[t.Key.X, t.Key.Y]].Type;
|
||||||
var idx = (t.Key.X - tp.Left) + tp.Width * (t.Key.Y - tp.Top);
|
var idx = (t.Key.X - tp.Left) + tp.Width * (t.Key.Y - tp.Top);
|
||||||
tiles[idx] = tileset.GetTerrainIndex(ttype);
|
tiles[idx] = tileset.GetTerrainIndex(ttype);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace OpenRA.TilesetBuilder
|
|||||||
/* draw template outlines */
|
/* draw template outlines */
|
||||||
foreach (var t in Templates)
|
foreach (var t in Templates)
|
||||||
{
|
{
|
||||||
System.Drawing.Pen pen = Pens.White;
|
var pen = Pens.White;
|
||||||
|
|
||||||
foreach (var c in t.Cells.Keys)
|
foreach (var c in t.Cells.Keys)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ namespace OpenRA.Utility
|
|||||||
GlobalFileSystem.LoadFromManifest(Game.modData.Manifest);
|
GlobalFileSystem.LoadFromManifest(Game.modData.Manifest);
|
||||||
var srcRules = Game.modData.RulesetCache.LoadDefaultRules();
|
var srcRules = Game.modData.RulesetCache.LoadDefaultRules();
|
||||||
var srcPaletteInfo = srcRules.Actors["player"].Traits.Get<PlayerColorPaletteInfo>();
|
var srcPaletteInfo = srcRules.Actors["player"].Traits.Get<PlayerColorPaletteInfo>();
|
||||||
int[] srcRemapIndex = srcPaletteInfo.RemapIndex;
|
var srcRemapIndex = srcPaletteInfo.RemapIndex;
|
||||||
|
|
||||||
var destMod = args[2].Split(':')[0];
|
var destMod = args[2].Split(':')[0];
|
||||||
Game.modData = new ModData(destMod);
|
Game.modData = new ModData(destMod);
|
||||||
@@ -400,7 +400,7 @@ namespace OpenRA.Utility
|
|||||||
Console.WriteLine("<table align=\"center\" width=\"1024\"><tr><th colspan=\"2\" width=\"1024\">{0}</th></tr>", name);
|
Console.WriteLine("<table align=\"center\" width=\"1024\"><tr><th colspan=\"2\" width=\"1024\">{0}</th></tr>", name);
|
||||||
foreach (var m in members.OrderBy(m => m.Name))
|
foreach (var m in members.OrderBy(m => m.Name))
|
||||||
{
|
{
|
||||||
string desc = m.HasAttribute<DescAttribute>() ? m.GetCustomAttributes<DescAttribute>(true).First().Lines.JoinWith("\n") : "";
|
var desc = m.HasAttribute<DescAttribute>() ? m.GetCustomAttributes<DescAttribute>(true).First().Lines.JoinWith("\n") : "";
|
||||||
Console.WriteLine("<tr><td align=\"right\" width=\"50%\"><strong>{0}</strong></td><td>{1}</td></tr>".F(m.LuaDocString(), desc));
|
Console.WriteLine("<tr><td align=\"right\" width=\"50%\"><strong>{0}</strong></td><td>{1}</td></tr>".F(m.LuaDocString(), desc));
|
||||||
}
|
}
|
||||||
Console.WriteLine("</table>");
|
Console.WriteLine("</table>");
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ namespace OpenRA.Utility
|
|||||||
static MemoryStream ReadPackedSection(IniSection mapPackSection)
|
static MemoryStream ReadPackedSection(IniSection mapPackSection)
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
for (int i = 1;; i++)
|
for (var i = 1;; i++)
|
||||||
{
|
{
|
||||||
var line = mapPackSection.GetValue(i.ToString(), null);
|
var line = mapPackSection.GetValue(i.ToString(), null);
|
||||||
if (line == null)
|
if (line == null)
|
||||||
@@ -250,27 +250,27 @@ namespace OpenRA.Utility
|
|||||||
|
|
||||||
void UnpackRATileData(MemoryStream ms)
|
void UnpackRATileData(MemoryStream ms)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (var i = 0; i < mapSize; i++)
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (var j = 0; j < mapSize; j++)
|
||||||
map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
|
map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
|
||||||
|
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (var j = 0; j < mapSize; j++)
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (var i = 0; i < mapSize; i++)
|
||||||
{
|
{
|
||||||
var tileID = ms.ReadUInt16();
|
var tileID = ms.ReadUInt16();
|
||||||
map.MapTiles.Value[i, j].Type = tileID == (ushort)0 ? (ushort)255 : tileID; // RAED weirdness
|
map.MapTiles.Value[i, j].Type = tileID == (ushort)0 ? (ushort)255 : tileID; // RAED weirdness
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (var j = 0; j < mapSize; j++)
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (var i = 0; i < mapSize; i++)
|
||||||
map.MapTiles.Value[i, j].Index = ms.ReadUInt8();
|
map.MapTiles.Value[i, j].Index = ms.ReadUInt8();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnpackRAOverlayData(MemoryStream ms)
|
void UnpackRAOverlayData(MemoryStream ms)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (var j = 0; j < mapSize; j++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (var i = 0; i < mapSize; i++)
|
||||||
{
|
{
|
||||||
var o = ms.ReadUInt8();
|
var o = ms.ReadUInt8();
|
||||||
var res = Pair.New((byte)0, (byte)0);
|
var res = Pair.New((byte)0, (byte)0);
|
||||||
@@ -299,7 +299,7 @@ namespace OpenRA.Utility
|
|||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> kv in terrain)
|
foreach (var kv in terrain)
|
||||||
{
|
{
|
||||||
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
||||||
map.Actors.Value.Add("Actor" + actorCount++,
|
map.Actors.Value.Add("Actor" + actorCount++,
|
||||||
@@ -313,13 +313,13 @@ namespace OpenRA.Utility
|
|||||||
|
|
||||||
void UnpackCncTileData(Stream ms)
|
void UnpackCncTileData(Stream ms)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (var i = 0; i < mapSize; i++)
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (var j = 0; j < mapSize; j++)
|
||||||
map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
|
map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
|
||||||
|
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (var j = 0; j < mapSize; j++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (var i = 0; i < mapSize; i++)
|
||||||
{
|
{
|
||||||
map.MapTiles.Value[i, j].Type = ms.ReadUInt8();
|
map.MapTiles.Value[i, j].Type = ms.ReadUInt8();
|
||||||
map.MapTiles.Value[i, j].Index = ms.ReadUInt8();
|
map.MapTiles.Value[i, j].Index = ms.ReadUInt8();
|
||||||
@@ -333,7 +333,7 @@ namespace OpenRA.Utility
|
|||||||
if (overlay == null)
|
if (overlay == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> kv in overlay)
|
foreach (var kv in overlay)
|
||||||
{
|
{
|
||||||
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
||||||
var cell = new CPos(loc % mapSize, loc / mapSize);
|
var cell = new CPos(loc % mapSize, loc / mapSize);
|
||||||
@@ -360,7 +360,7 @@ namespace OpenRA.Utility
|
|||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> kv in terrain)
|
foreach (var kv in terrain)
|
||||||
{
|
{
|
||||||
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
||||||
map.Actors.Value.Add("Actor" + actorCount++,
|
map.Actors.Value.Add("Actor" + actorCount++,
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ namespace OpenRA.Utility
|
|||||||
static void UpgradeTileset(int engineVersion, ref List<MiniYamlNode> nodes, MiniYamlNode parent, int depth)
|
static void UpgradeTileset(int engineVersion, ref List<MiniYamlNode> nodes, MiniYamlNode parent, int depth)
|
||||||
{
|
{
|
||||||
var parentKey = parent != null ? parent.Key.Split('@').First() : null;
|
var parentKey = parent != null ? parent.Key.Split('@').First() : null;
|
||||||
List<MiniYamlNode> addNodes = new List<MiniYamlNode>();
|
var addNodes = new List<MiniYamlNode>();
|
||||||
|
|
||||||
foreach (var node in nodes)
|
foreach (var node in nodes)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user