Formatted all files.
Automatically formatted all files via VS. This generally corrects indentation, removes trailing whitespace and corrects misplaced tabs or spaces. Manually tweaked a few files where required.
This commit is contained in:
@@ -91,7 +91,7 @@ namespace OpenRA
|
||||
{
|
||||
return (k & mod) == mod;
|
||||
}
|
||||
|
||||
|
||||
public static V GetOrAdd<K, V>(this Dictionary<K, V> d, K k)
|
||||
where V : new()
|
||||
{
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace OpenRA
|
||||
else if (fieldType == typeof(decimal))
|
||||
{
|
||||
decimal res;
|
||||
if (decimal.TryParse(value.Replace("%", ""), NumberStyles.Float, NumberFormatInfo.InvariantInfo, out res))
|
||||
if (decimal.TryParse(value.Replace("%", ""), NumberStyles.Float, NumberFormatInfo.InvariantInfo, out res))
|
||||
return res * (value.Contains('%') ? 0.01m : 1m);
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ namespace OpenRA
|
||||
if (Exts.TryParseIntegerInvariant(value, out rr)
|
||||
&& Exts.TryParseIntegerInvariant(value, out rp)
|
||||
&& Exts.TryParseIntegerInvariant(value, out ry))
|
||||
return new WRot(new WAngle(rr), new WAngle(rp), new WAngle(ry));
|
||||
return new WRot(new WAngle(rr), new WAngle(rp), new WAngle(ry));
|
||||
}
|
||||
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
|
||||
@@ -390,7 +390,8 @@ namespace OpenRA.FileFormats
|
||||
MulBignumWord(esi, globOne, tmp, 2 * len);
|
||||
if ((*edi & 0x8000) == 0)
|
||||
{
|
||||
if (0 != SubBigNum((uint*)esi, (uint*)esi, g1, 0, (int)len))(*edi)--;
|
||||
if (0 != SubBigNum((uint*)esi, (uint*)esi, g1, 0, (int)len))
|
||||
(*edi)--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,17 +33,17 @@ namespace OpenRA.FileFormats
|
||||
Transforms = new float[16 * FrameCount * LimbCount];
|
||||
for (var j = 0; j < FrameCount; j++)
|
||||
for (var i = 0; i < LimbCount; i++)
|
||||
{
|
||||
// Convert to column-major matrices and add the final matrix row
|
||||
var c = 16 * (LimbCount * j + i);
|
||||
Transforms[c + 3] = 0;
|
||||
Transforms[c + 7] = 0;
|
||||
Transforms[c + 11] = 0;
|
||||
Transforms[c + 15] = 1;
|
||||
{
|
||||
// Convert to column-major matrices and add the final matrix row
|
||||
var c = 16 * (LimbCount * j + i);
|
||||
Transforms[c + 3] = 0;
|
||||
Transforms[c + 7] = 0;
|
||||
Transforms[c + 11] = 0;
|
||||
Transforms[c + 15] = 1;
|
||||
|
||||
for (var k = 0; k < 12; k++)
|
||||
Transforms[c + ids[k]] = s.ReadFloat();
|
||||
}
|
||||
for (var k = 0; k < 12; k++)
|
||||
Transforms[c + ids[k]] = s.ReadFloat();
|
||||
}
|
||||
}
|
||||
|
||||
public static HvaReader Load(string filename)
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace OpenRA.FileFormats
|
||||
|
||||
switch (line[0])
|
||||
{
|
||||
case ';': break;
|
||||
case '[': currentSection = ProcessSection(line); break;
|
||||
default: ProcessEntry(line, currentSection); break;
|
||||
case ';': break;
|
||||
case '[': currentSection = ProcessSection(line); break;
|
||||
default: ProcessEntry(line, currentSection); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,8 +175,8 @@ namespace OpenRA.FileFormats
|
||||
var jmp = int2.Swap(stream.ReadUInt32());
|
||||
stream.Seek(jmp, SeekOrigin.Current);
|
||||
type = stream.ReadASCII(4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var length = int2.Swap(stream.ReadUInt32());
|
||||
|
||||
switch (type)
|
||||
@@ -197,10 +197,10 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
|
||||
compressed = type == "SND2";
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
stream.ReadBytes((int)length);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
// Chunks are aligned on even bytes; advance by a byte if the next one is null
|
||||
@@ -230,7 +230,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
audioData = new byte[rightData.Length + leftData.Length];
|
||||
var rightIndex = 0;
|
||||
var leftIndex = 0;
|
||||
var leftIndex = 0;
|
||||
for (var i = 0; i < audioData.Length;)
|
||||
{
|
||||
audioData[i++] = leftData[leftIndex++];
|
||||
@@ -273,28 +273,28 @@ namespace OpenRA.FileFormats
|
||||
stream.Seek(length, SeekOrigin.Current);
|
||||
type = stream.ReadASCII(4);
|
||||
}
|
||||
else
|
||||
else
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
length = int2.Swap(stream.ReadUInt32());
|
||||
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case "VQFR":
|
||||
DecodeVQFR(stream);
|
||||
break;
|
||||
break;
|
||||
case "\0VQF":
|
||||
stream.ReadByte();
|
||||
DecodeVQFR(stream);
|
||||
break;
|
||||
case "VQFL":
|
||||
break;
|
||||
case "VQFL":
|
||||
DecodeVQFR(stream, "VQFL");
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
// Don't parse sound here.
|
||||
stream.ReadBytes((int)length);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
// Chunks are aligned on even bytes; advance by a byte if the next one is null
|
||||
@@ -343,10 +343,10 @@ namespace OpenRA.FileFormats
|
||||
|
||||
if (parentType == "VQFL")
|
||||
return;
|
||||
break;
|
||||
break;
|
||||
case "CBF0":
|
||||
cbf = s.ReadBytes(subchunkLength);
|
||||
break;
|
||||
break;
|
||||
|
||||
// frame-modifier chunk
|
||||
case "CBP0":
|
||||
@@ -366,7 +366,7 @@ namespace OpenRA.FileFormats
|
||||
bytes.CopyTo(cbp, chunkBufferOffset);
|
||||
chunkBufferOffset += subchunkLength;
|
||||
currentChunkBuffer++;
|
||||
break;
|
||||
break;
|
||||
|
||||
// Palette
|
||||
case "CPL0":
|
||||
@@ -378,7 +378,7 @@ namespace OpenRA.FileFormats
|
||||
palette[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
// Frame data
|
||||
case "VPTZ":
|
||||
@@ -390,9 +390,9 @@ namespace OpenRA.FileFormats
|
||||
Array.Clear(origData, 0, origData.Length);
|
||||
s.Read(fileBuffer, 0, subchunkLength);
|
||||
if (fileBuffer[0] != 0)
|
||||
vtprSize = Format80.DecodeInto(fileBuffer, origData);
|
||||
vtprSize = Format80.DecodeInto(fileBuffer, origData);
|
||||
else
|
||||
Format80.DecodeInto(fileBuffer, origData, 1, true);
|
||||
Format80.DecodeInto(fileBuffer, origData, 1, true);
|
||||
return;
|
||||
case "VPTR":
|
||||
Array.Clear(origData, 0, origData.Length);
|
||||
@@ -434,21 +434,21 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
case 0:
|
||||
x += para_A;
|
||||
break;
|
||||
break;
|
||||
case 1:
|
||||
WriteBlock(para_B1, para_B2, ref x, ref y);
|
||||
break;
|
||||
break;
|
||||
case 2:
|
||||
WriteBlock(para_B1, 1, ref x, ref y);
|
||||
for (var i = 0; i < para_B2; i++)
|
||||
WriteBlock(origData[p++], 1, ref x, ref y);
|
||||
break;
|
||||
for (var i = 0; i < para_B2; i++)
|
||||
WriteBlock(origData[p++], 1, ref x, ref y);
|
||||
break;
|
||||
case 3:
|
||||
WriteBlock(para_A, 1, ref x, ref y);
|
||||
break;
|
||||
break;
|
||||
case 5:
|
||||
WriteBlock(para_A, origData[p++], ref x, ref y);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public enum WaveType { Pcm = 0x1, ImaAdpcm = 0x11 }
|
||||
public static WaveType Type { get; private set; }
|
||||
|
||||
|
||||
public WavLoader(Stream s)
|
||||
{
|
||||
while (s.Position < s.Length)
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.FileFormats
|
||||
BitsPerSample = 16;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static float WaveLength(Stream s)
|
||||
{
|
||||
s.Position = 12;
|
||||
|
||||
@@ -75,8 +75,8 @@ namespace OpenRA.FileSystem
|
||||
|
||||
foreach (var file in contents)
|
||||
using (var dataStream = File.Create(Path.Combine(path, file.Key)))
|
||||
using (var writer = new BinaryWriter(dataStream))
|
||||
writer.Write(file.Value);
|
||||
using (var writer = new BinaryWriter(dataStream))
|
||||
writer.Write(file.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace OpenRA.FileSystem
|
||||
|
||||
public int Priority { get { return 1000 + priority; } }
|
||||
public string Name { get { return filename; } }
|
||||
|
||||
|
||||
public void Write(Dictionary<string, byte[]> contents)
|
||||
{
|
||||
// Cannot modify existing mixfile - rename existing file and
|
||||
|
||||
@@ -59,41 +59,41 @@ namespace OpenRA.FileSystem
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case PackageHashType.Classic:
|
||||
{
|
||||
name = name.ToUpperInvariant();
|
||||
if (name.Length % 4 != 0)
|
||||
name = name.PadRight(name.Length + (4 - name.Length % 4), '\0');
|
||||
|
||||
var ms = new MemoryStream(Encoding.ASCII.GetBytes(name));
|
||||
var reader = new BinaryReader(ms);
|
||||
|
||||
var len = name.Length >> 2;
|
||||
uint result = 0;
|
||||
|
||||
while (len-- != 0)
|
||||
result = ((result << 1) | (result >> 31)) + reader.ReadUInt32();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
case PackageHashType.CRC32:
|
||||
{
|
||||
name = name.ToUpperInvariant();
|
||||
var l = name.Length;
|
||||
var a = l >> 2;
|
||||
if ((l & 3) != 0)
|
||||
case PackageHashType.Classic:
|
||||
{
|
||||
name += (char)(l - (a << 2));
|
||||
var i = 3 - (l & 3);
|
||||
while (i-- != 0)
|
||||
name += name[a << 2];
|
||||
name = name.ToUpperInvariant();
|
||||
if (name.Length % 4 != 0)
|
||||
name = name.PadRight(name.Length + (4 - name.Length % 4), '\0');
|
||||
|
||||
var ms = new MemoryStream(Encoding.ASCII.GetBytes(name));
|
||||
var reader = new BinaryReader(ms);
|
||||
|
||||
var len = name.Length >> 2;
|
||||
uint result = 0;
|
||||
|
||||
while (len-- != 0)
|
||||
result = ((result << 1) | (result >> 31)) + reader.ReadUInt32();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return CRC32.Calculate(Encoding.ASCII.GetBytes(name));
|
||||
}
|
||||
case PackageHashType.CRC32:
|
||||
{
|
||||
name = name.ToUpperInvariant();
|
||||
var l = name.Length;
|
||||
var a = l >> 2;
|
||||
if ((l & 3) != 0)
|
||||
{
|
||||
name += (char)(l - (a << 2));
|
||||
var i = 3 - (l & 3);
|
||||
while (i-- != 0)
|
||||
name += name[a << 2];
|
||||
}
|
||||
|
||||
default: throw new NotImplementedException("Unknown hash type `{0}`".F(type));
|
||||
return CRC32.Calculate(Encoding.ASCII.GetBytes(name));
|
||||
}
|
||||
|
||||
default: throw new NotImplementedException("Unknown hash type `{0}`".F(type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace OpenRA
|
||||
if (worldRenderer != null)
|
||||
worldRenderer.Dispose();
|
||||
worldRenderer = new WorldRenderer(OrderManager.World);
|
||||
|
||||
|
||||
using (new PerfTimer("LoadComplete"))
|
||||
OrderManager.World.LoadComplete(worldRenderer);
|
||||
|
||||
|
||||
@@ -92,7 +92,8 @@ namespace OpenRA
|
||||
if (constructOrderCache != null)
|
||||
return constructOrderCache;
|
||||
|
||||
var source = Traits.WithInterface<ITraitInfo>().Select(i => new {
|
||||
var source = Traits.WithInterface<ITraitInfo>().Select(i => new
|
||||
{
|
||||
Trait = i,
|
||||
Type = i.GetType(),
|
||||
Dependencies = PrerequisitesOf(i).ToList()
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace OpenRA.GameRules
|
||||
|
||||
[Desc("What types of targets are unaffected.", "Overrules ValidTargets.")]
|
||||
public readonly string[] InvalidTargets = { };
|
||||
|
||||
|
||||
[Desc("What diplomatic stances are affected.")]
|
||||
public readonly Stance ValidStances = Stance.Ally | Stance.Neutral | Stance.Enemy;
|
||||
|
||||
|
||||
[Desc("Can this warhead affect the actor that fired it.")]
|
||||
public readonly bool AffectsParent = false;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
public enum TextureScaleFilter { Nearest, Linear }
|
||||
|
||||
|
||||
public interface ITexture : IDisposable
|
||||
{
|
||||
void SetData(Bitmap bitmap);
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace OpenRA.Graphics
|
||||
var isAlly = actor.Owner.IsAlliedWith(actor.World.LocalPlayer)
|
||||
|| (actor.EffectiveOwner != null && actor.EffectiveOwner.Disguised
|
||||
&& actor.World.LocalPlayer.IsAlliedWith(actor.EffectiveOwner.Owner));
|
||||
return isAlly ? Color.LimeGreen : actor.Owner.NonCombatant ? Color.Tan : Color.Red;
|
||||
return isAlly ? Color.LimeGreen : actor.Owner.NonCombatant ? Color.Tan : Color.Red;
|
||||
}
|
||||
else
|
||||
return health.DamageState == DamageState.Critical ? Color.Red :
|
||||
|
||||
@@ -106,12 +106,12 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var mtx = new float[16];
|
||||
for (var i = 0; i < 4; i++)
|
||||
for (var j = 0; j < 4; j++)
|
||||
{
|
||||
mtx[4 * i + j] = 0;
|
||||
for (var k = 0; k < 4; k++)
|
||||
mtx[4 * i + j] += lhs[4 * k + j] * rhs[4 * i + k];
|
||||
}
|
||||
for (var j = 0; j < 4; j++)
|
||||
{
|
||||
mtx[4 * i + j] = 0;
|
||||
for (var k = 0; k < 4; k++)
|
||||
mtx[4 * i + j] += lhs[4 * k + j] * rhs[4 * i + k];
|
||||
}
|
||||
|
||||
return mtx;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ namespace OpenRA.Graphics
|
||||
return null;
|
||||
|
||||
for (var i = 0; i < 16; i++)
|
||||
mtx[i] *= 1 / det;
|
||||
mtx[i] *= 1 / det;
|
||||
|
||||
return mtx;
|
||||
}
|
||||
|
||||
@@ -77,9 +77,10 @@ namespace OpenRA.Graphics
|
||||
shader.SetMatrix("View", view);
|
||||
}
|
||||
|
||||
public VoxelRenderProxy RenderAsync(WorldRenderer wr, IEnumerable<VoxelAnimation> voxels, WRot camera, float scale,
|
||||
float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
||||
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
|
||||
public VoxelRenderProxy RenderAsync(
|
||||
WorldRenderer wr, IEnumerable<VoxelAnimation> voxels, WRot camera, float scale,
|
||||
float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
||||
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
|
||||
{
|
||||
// Correct for inverted y-axis
|
||||
var scaleTransform = Util.ScaleMatrix(scale, scale, scale);
|
||||
@@ -202,7 +203,7 @@ namespace OpenRA.Graphics
|
||||
var lightDirection = ExtractRotationVector(Util.MatrixMultiply(Util.MatrixInverse(t), lightTransform));
|
||||
|
||||
Render(rd, Util.MatrixMultiply(transform, t), lightDirection,
|
||||
lightAmbientColor, lightDiffuseColor, color.Index, normals.Index);
|
||||
lightAmbientColor, lightDiffuseColor, color.Index, normals.Index);
|
||||
|
||||
// Disable shadow normals by forcing zero diffuse and identity ambient light
|
||||
Render(rd, Util.MatrixMultiply(shadow, t), lightDirection,
|
||||
@@ -249,14 +250,16 @@ namespace OpenRA.Graphics
|
||||
return tVec;
|
||||
}
|
||||
|
||||
void Render(VoxelRenderData renderData,
|
||||
float[] t, float[] lightDirection,
|
||||
float[] ambientLight, float[] diffuseLight,
|
||||
int colorPalette, int normalsPalette)
|
||||
void Render(
|
||||
VoxelRenderData renderData,
|
||||
float[] t, float[] lightDirection,
|
||||
float[] ambientLight, float[] diffuseLight,
|
||||
int colorPalette, int normalsPalette)
|
||||
{
|
||||
shader.SetTexture("DiffuseTexture", renderData.Sheet.GetTexture());
|
||||
shader.SetVec("PaletteRows", (colorPalette + 0.5f) / HardwarePalette.MaxPalettes,
|
||||
(normalsPalette + 0.5f) / HardwarePalette.MaxPalettes);
|
||||
shader.SetVec("PaletteRows",
|
||||
(colorPalette + 0.5f) / HardwarePalette.MaxPalettes,
|
||||
(normalsPalette + 0.5f) / HardwarePalette.MaxPalettes);
|
||||
shader.SetMatrix("TransformMatrix", t);
|
||||
shader.SetVec("LightDirection", lightDirection, 4);
|
||||
shader.SetVec("AmbientLight", ambientLight, 3);
|
||||
|
||||
@@ -270,8 +270,7 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
if (throwErrors)
|
||||
if (noInherit.ContainsValue(false))
|
||||
if (throwErrors && noInherit.ContainsValue(false))
|
||||
throw new YamlException("Bogus yaml removals: {0}".F(
|
||||
noInherit.Where(x => !x.Value).JoinWith(", ")));
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ namespace OpenRA.Network
|
||||
{
|
||||
case "Handshake":
|
||||
FieldLoader.Load(handshake, y.Value);
|
||||
break;
|
||||
break;
|
||||
case "Client":
|
||||
FieldLoader.Load(handshake.Client, y.Value);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Network
|
||||
}
|
||||
|
||||
case "Message": // Server message
|
||||
Game.AddChatLine(Color.White, "Server", order.TargetString);
|
||||
Game.AddChatLine(Color.White, "Server", order.TargetString);
|
||||
break;
|
||||
|
||||
case "Disconnected": /* reports that the target player disconnected */
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace OpenRA
|
||||
var it = typeof(T);
|
||||
return GetTypes().Where(t => t != it && it.IsAssignableFrom(t));
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<Type> GetTypes()
|
||||
{
|
||||
return assemblies.Select(ma => ma.First).Distinct()
|
||||
|
||||
@@ -26,24 +26,24 @@ namespace OpenRA
|
||||
|
||||
static PlatformType GetCurrentPlatform()
|
||||
{
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
return PlatformType.Windows;
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
return PlatformType.Windows;
|
||||
|
||||
try
|
||||
{
|
||||
var psi = new ProcessStartInfo("uname", "-s");
|
||||
psi.UseShellExecute = false;
|
||||
psi.RedirectStandardOutput = true;
|
||||
var p = Process.Start(psi);
|
||||
var kernelName = p.StandardOutput.ReadToEnd();
|
||||
if (kernelName.Contains("Linux") || kernelName.Contains("BSD"))
|
||||
return PlatformType.Linux;
|
||||
if (kernelName.Contains("Darwin"))
|
||||
return PlatformType.OSX;
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
var psi = new ProcessStartInfo("uname", "-s");
|
||||
psi.UseShellExecute = false;
|
||||
psi.RedirectStandardOutput = true;
|
||||
var p = Process.Start(psi);
|
||||
var kernelName = p.StandardOutput.ReadToEnd();
|
||||
if (kernelName.Contains("Linux") || kernelName.Contains("BSD"))
|
||||
return PlatformType.Linux;
|
||||
if (kernelName.Contains("Darwin"))
|
||||
return PlatformType.OSX;
|
||||
}
|
||||
catch { }
|
||||
|
||||
return PlatformType.Unknown;
|
||||
return PlatformType.Unknown;
|
||||
}
|
||||
|
||||
public static string RuntimeVersion
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA
|
||||
if (version == null)
|
||||
return "Mono (unknown version) CLR {0}".F(Environment.Version);
|
||||
|
||||
return "Mono {0} CLR {1}".F(version.Invoke(null, null), Environment.Version);
|
||||
return "Mono {0} CLR {1}".F(version.Invoke(null, null), Environment.Version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,16 +75,16 @@ namespace OpenRA
|
||||
|
||||
switch (CurrentPlatform)
|
||||
{
|
||||
case PlatformType.Windows:
|
||||
dir += Path.DirectorySeparatorChar + "OpenRA";
|
||||
break;
|
||||
case PlatformType.OSX:
|
||||
dir += "/Library/Application Support/OpenRA";
|
||||
break;
|
||||
case PlatformType.Linux:
|
||||
default:
|
||||
dir += "/.openra";
|
||||
break;
|
||||
case PlatformType.Windows:
|
||||
dir += Path.DirectorySeparatorChar + "OpenRA";
|
||||
break;
|
||||
case PlatformType.OSX:
|
||||
dir += "/Library/Application Support/OpenRA";
|
||||
break;
|
||||
case PlatformType.Linux:
|
||||
default:
|
||||
dir += "/.openra";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(dir))
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace OpenRA.Server
|
||||
LobbyInfo.ClientPings.Add(clientPing);
|
||||
|
||||
Log.Write("server", "Client {0}: Accepted connection from {1}.",
|
||||
newConn.PlayerIndex, newConn.Socket.RemoteEndPoint);
|
||||
newConn.PlayerIndex, newConn.Socket.RemoteEndPoint);
|
||||
|
||||
foreach (var t in serverTraits.WithInterface<IClientJoined>())
|
||||
t.ClientJoined(this, newConn);
|
||||
@@ -451,20 +451,20 @@ namespace OpenRA.Server
|
||||
switch (so.Name)
|
||||
{
|
||||
case "Command":
|
||||
{
|
||||
var handled = false;
|
||||
foreach (var t in serverTraits.WithInterface<IInterpretCommand>())
|
||||
if (handled = t.InterpretCommand(this, conn, GetClient(conn), so.Data))
|
||||
break;
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
Log.Write("server", "Unknown server command: {0}", so.Data);
|
||||
SendOrderTo(conn, "Message", "Unknown server command: {0}".F(so.Data));
|
||||
}
|
||||
var handled = false;
|
||||
foreach (var t in serverTraits.WithInterface<IInterpretCommand>())
|
||||
if (handled = t.InterpretCommand(this, conn, GetClient(conn), so.Data))
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
Log.Write("server", "Unknown server command: {0}", so.Data);
|
||||
SendOrderTo(conn, "Message", "Unknown server command: {0}".F(so.Data));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "HandshakeResponse":
|
||||
ValidateClient(conn, so.Data);
|
||||
@@ -475,33 +475,33 @@ namespace OpenRA.Server
|
||||
DispatchOrdersToClients(conn, 0, so.Serialize());
|
||||
break;
|
||||
case "Pong":
|
||||
{
|
||||
int pingSent;
|
||||
if (!OpenRA.Exts.TryParseIntegerInvariant(so.Data, out pingSent))
|
||||
{
|
||||
Log.Write("server", "Invalid order pong payload: {0}", so.Data);
|
||||
int pingSent;
|
||||
if (!OpenRA.Exts.TryParseIntegerInvariant(so.Data, out pingSent))
|
||||
{
|
||||
Log.Write("server", "Invalid order pong payload: {0}", so.Data);
|
||||
break;
|
||||
}
|
||||
|
||||
var pingFromClient = LobbyInfo.PingFromClient(GetClient(conn));
|
||||
if (pingFromClient == null)
|
||||
return;
|
||||
|
||||
var history = pingFromClient.LatencyHistory.ToList();
|
||||
history.Add(Game.RunTime - pingSent);
|
||||
|
||||
// Cap ping history at 5 values (25 seconds)
|
||||
if (history.Count > 5)
|
||||
history.RemoveRange(0, history.Count - 5);
|
||||
|
||||
pingFromClient.Latency = history.Sum() / history.Count;
|
||||
pingFromClient.LatencyJitter = (history.Max() - history.Min()) / 2;
|
||||
pingFromClient.LatencyHistory = history.ToArray();
|
||||
|
||||
SyncClientPing();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
var pingFromClient = LobbyInfo.PingFromClient(GetClient(conn));
|
||||
if (pingFromClient == null)
|
||||
return;
|
||||
|
||||
var history = pingFromClient.LatencyHistory.ToList();
|
||||
history.Add(Game.RunTime - pingSent);
|
||||
|
||||
// Cap ping history at 5 values (25 seconds)
|
||||
if (history.Count > 5)
|
||||
history.RemoveRange(0, history.Count - 5);
|
||||
|
||||
pingFromClient.Latency = history.Sum() / history.Count;
|
||||
pingFromClient.LatencyJitter = (history.Max() - history.Min()) / 2;
|
||||
pingFromClient.LatencyHistory = history.ToArray();
|
||||
|
||||
SyncClientPing();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,11 +61,11 @@ namespace OpenRA
|
||||
engine = Game.Settings.Server.Dedicated ? "Null" : engine;
|
||||
switch (engine)
|
||||
{
|
||||
case "AL": return new OpenAlSoundEngine();
|
||||
case "Null": return new NullSoundEngine();
|
||||
case "AL": return new OpenAlSoundEngine();
|
||||
case "Null": return new NullSoundEngine();
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException("Unsupported sound engine: {0}".F(engine));
|
||||
default:
|
||||
throw new InvalidOperationException("Unsupported sound engine: {0}".F(engine));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ namespace OpenRA
|
||||
var type = mi.Voice.ToLowerInvariant();
|
||||
return PlayPredefined(voicedUnit.World.Map.Rules, null, voicedUnit, type, phrase, variant, true, WPos.Zero, 1f, true);
|
||||
}
|
||||
|
||||
|
||||
public static bool PlayVoiceLocal(string phrase, Actor voicedUnit, string variant, WPos pos, float volume)
|
||||
{
|
||||
if (voicedUnit == null || phrase == null)
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace OpenRA
|
||||
{
|
||||
var path = Platform.SupportDir + "Logs";
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
|
||||
for (var i = 0;; i++)
|
||||
yield return Path.Combine(path, i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename);
|
||||
yield return Path.Combine(path, i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename);
|
||||
}
|
||||
|
||||
public static void AddChannel(string channelName, string baseFilename)
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Traits
|
||||
};
|
||||
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDamage>()
|
||||
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyDamage>()))
|
||||
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyDamage>()))
|
||||
nd.Damaged(self, ai);
|
||||
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDamageStateChanged>())
|
||||
@@ -100,7 +100,7 @@ namespace OpenRA.Traits
|
||||
|
||||
if (Info.NotifyAppliedDamage && repairer != null && repairer.IsInWorld && !repairer.IsDead)
|
||||
foreach (var nd in repairer.TraitsImplementing<INotifyAppliedDamage>()
|
||||
.Concat(repairer.Owner.PlayerActor.TraitsImplementing<INotifyAppliedDamage>()))
|
||||
.Concat(repairer.Owner.PlayerActor.TraitsImplementing<INotifyAppliedDamage>()))
|
||||
nd.AppliedDamage(repairer, self, ai);
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace OpenRA.Traits
|
||||
if (Info.NotifyAppliedDamage && attacker != null && attacker.IsInWorld && !attacker.IsDead)
|
||||
foreach (var nd in attacker.TraitsImplementing<INotifyAppliedDamage>()
|
||||
.Concat(attacker.Owner.PlayerActor.TraitsImplementing<INotifyAppliedDamage>()))
|
||||
nd.AppliedDamage(attacker, self, ai);
|
||||
nd.AppliedDamage(attacker, self, ai);
|
||||
|
||||
if (hp == 0)
|
||||
{
|
||||
|
||||
@@ -101,15 +101,15 @@ namespace OpenRA.Traits
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case TargetType.Actor:
|
||||
return actor.CenterPosition;
|
||||
case TargetType.FrozenActor:
|
||||
return frozen.CenterPosition;
|
||||
case TargetType.Terrain:
|
||||
return pos;
|
||||
default:
|
||||
case TargetType.Invalid:
|
||||
throw new InvalidOperationException("Attempting to query the position of an invalid Target");
|
||||
case TargetType.Actor:
|
||||
return actor.CenterPosition;
|
||||
case TargetType.FrozenActor:
|
||||
return frozen.CenterPosition;
|
||||
case TargetType.Terrain:
|
||||
return pos;
|
||||
default:
|
||||
case TargetType.Invalid:
|
||||
throw new InvalidOperationException("Attempting to query the position of an invalid Target");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,20 +122,20 @@ namespace OpenRA.Traits
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case TargetType.Actor:
|
||||
var targetable = actor.TraitOrDefault<ITargetable>();
|
||||
if (targetable == null)
|
||||
return new[] { actor.CenterPosition };
|
||||
case TargetType.Actor:
|
||||
var targetable = actor.TraitOrDefault<ITargetable>();
|
||||
if (targetable == null)
|
||||
return new[] { actor.CenterPosition };
|
||||
|
||||
var positions = targetable.TargetablePositions(actor);
|
||||
return positions.Any() ? positions : new[] { actor.CenterPosition };
|
||||
case TargetType.FrozenActor:
|
||||
return new[] { frozen.CenterPosition };
|
||||
case TargetType.Terrain:
|
||||
return new[] { pos };
|
||||
default:
|
||||
case TargetType.Invalid:
|
||||
return NoPositions;
|
||||
var positions = targetable.TargetablePositions(actor);
|
||||
return positions.Any() ? positions : new[] { actor.CenterPosition };
|
||||
case TargetType.FrozenActor:
|
||||
return new[] { frozen.CenterPosition };
|
||||
case TargetType.Terrain:
|
||||
return new[] { pos };
|
||||
default:
|
||||
case TargetType.Invalid:
|
||||
return NoPositions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Traits
|
||||
// depends on the order of pips in WorldRenderer.cs!
|
||||
public enum PipType { Transparent, Green, Yellow, Red, Gray, Blue, Ammo, AmmoEmpty }
|
||||
public enum TagType { None, Fake, Primary }
|
||||
|
||||
|
||||
[Flags]
|
||||
public enum Stance
|
||||
{
|
||||
@@ -259,7 +259,7 @@ namespace OpenRA.Traits
|
||||
}
|
||||
|
||||
public interface IRenderOverlay { void Render(WorldRenderer wr); }
|
||||
public interface INotifyBecomingIdle { void OnBecomingIdle(Actor self); }
|
||||
public interface INotifyBecomingIdle { void OnBecomingIdle(Actor self); }
|
||||
public interface INotifyIdle { void TickIdle(Actor self); }
|
||||
|
||||
public interface IBlocksBullets { }
|
||||
|
||||
@@ -63,16 +63,16 @@ namespace OpenRA
|
||||
|
||||
switch (components.Length)
|
||||
{
|
||||
case 2:
|
||||
if (!Exts.TryParseIntegerInvariant(components[0], out cell) ||
|
||||
!Exts.TryParseIntegerInvariant(components[1], out subcell))
|
||||
case 2:
|
||||
if (!Exts.TryParseIntegerInvariant(components[0], out cell) ||
|
||||
!Exts.TryParseIntegerInvariant(components[1], out subcell))
|
||||
return false;
|
||||
break;
|
||||
case 1:
|
||||
if (!Exts.TryParseIntegerInvariant(components[0], out subcell))
|
||||
return false;
|
||||
break;
|
||||
default: return false;
|
||||
break;
|
||||
case 1:
|
||||
if (!Exts.TryParseIntegerInvariant(components[0], out subcell))
|
||||
return false;
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
// Propagate sign to fractional part
|
||||
|
||||
@@ -28,8 +28,10 @@ namespace OpenRA
|
||||
public static WRot operator -(WRot a, WRot b) { return new WRot(a.Roll - b.Roll, a.Pitch - b.Pitch, a.Yaw - b.Yaw); }
|
||||
public static WRot operator -(WRot a) { return new WRot(-a.Roll, -a.Pitch, -a.Yaw); }
|
||||
|
||||
public static bool operator ==(WRot me, WRot other) { return me.Roll == other.Roll &&
|
||||
me.Pitch == other.Pitch && me.Yaw == other.Yaw; }
|
||||
public static bool operator ==(WRot me, WRot other)
|
||||
{
|
||||
return me.Roll == other.Roll && me.Pitch == other.Pitch && me.Yaw == other.Yaw;
|
||||
}
|
||||
|
||||
public static bool operator !=(WRot me, WRot other) { return !(me == other); }
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
// Equivalent to OnMouseUp, but without an input arg
|
||||
public Action OnClick = () => { };
|
||||
public Action OnDoubleClick = () => { };
|
||||
public Action OnDoubleClick = () => { };
|
||||
public Action<KeyInput> OnKeyPress = _ => { };
|
||||
|
||||
protected readonly Ruleset ModRules;
|
||||
@@ -149,7 +149,7 @@ namespace OpenRA.Widgets
|
||||
OnDoubleClick();
|
||||
return YieldMouseFocus(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (HasMouseFocus && mi.Event == MouseInputEvent.Up)
|
||||
{
|
||||
// Only fire the onMouseUp event if we successfully lost focus, and were pressed
|
||||
@@ -197,8 +197,14 @@ namespace OpenRA.Widgets
|
||||
tooltipContainer.Value.RemoveTooltip();
|
||||
}
|
||||
|
||||
public override int2 ChildOrigin { get { return RenderOrigin +
|
||||
(Depressed ? new int2(VisualHeight, VisualHeight) : new int2(0, 0)); } }
|
||||
public override int2 ChildOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
return RenderOrigin +
|
||||
(Depressed ? new int2(VisualHeight, VisualHeight) : new int2(0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
|
||||
@@ -101,8 +101,7 @@ namespace OpenRA.Widgets
|
||||
public void ShowDropDown<T>(string panelTemplate, int maxHeight, IEnumerable<T> options, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem)
|
||||
{
|
||||
var substitutions = new Dictionary<string, int>() { { "DROPDOWN_WIDTH", Bounds.Width } };
|
||||
var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs()
|
||||
{ { "substitutions", substitutions } });
|
||||
var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs() { { "substitutions", substitutions } });
|
||||
|
||||
var itemTemplate = panel.Get<ScrollItemWidget>("TEMPLATE");
|
||||
panel.RemoveChildren();
|
||||
@@ -124,8 +123,7 @@ namespace OpenRA.Widgets
|
||||
public void ShowDropDown<T>(string panelTemplate, int height, Dictionary<string, IEnumerable<T>> groups, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem)
|
||||
{
|
||||
var substitutions = new Dictionary<string, int>() { { "DROPDOWN_WIDTH", Bounds.Width } };
|
||||
var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs()
|
||||
{ { "substitutions", substitutions } });
|
||||
var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs() { { "substitutions", substitutions } });
|
||||
|
||||
var headerTemplate = panel.GetOrNull<ScrollItemWidget>("HEADER");
|
||||
var itemTemplate = panel.Get<ScrollItemWidget>("TEMPLATE");
|
||||
|
||||
@@ -61,22 +61,22 @@ namespace OpenRA.Widgets
|
||||
|
||||
switch (mi.Event)
|
||||
{
|
||||
case MouseInputEvent.Up:
|
||||
isMoving = false;
|
||||
YieldMouseFocus(mi);
|
||||
break;
|
||||
case MouseInputEvent.Up:
|
||||
isMoving = false;
|
||||
YieldMouseFocus(mi);
|
||||
break;
|
||||
|
||||
case MouseInputEvent.Down:
|
||||
isMoving = true;
|
||||
/* TODO: handle snapping to ticks properly again */
|
||||
/* TODO: handle nudge via clicking outside the thumb */
|
||||
UpdateValue(ValueFromPx(mi.Location.X - RenderBounds.Left));
|
||||
break;
|
||||
|
||||
case MouseInputEvent.Move:
|
||||
if (isMoving)
|
||||
case MouseInputEvent.Down:
|
||||
isMoving = true;
|
||||
/* TODO: handle snapping to ticks properly again */
|
||||
/* TODO: handle nudge via clicking outside the thumb */
|
||||
UpdateValue(ValueFromPx(mi.Location.X - RenderBounds.Left));
|
||||
break;
|
||||
break;
|
||||
|
||||
case MouseInputEvent.Move:
|
||||
if (isMoving)
|
||||
UpdateValue(ValueFromPx(mi.Location.X - RenderBounds.Left));
|
||||
break;
|
||||
}
|
||||
|
||||
return ThumbRect.Contains(mi.Location);
|
||||
|
||||
@@ -268,9 +268,10 @@ namespace OpenRA.Widgets
|
||||
Bounds.Width - LeftMargin - RightMargin, Bounds.Bottom));
|
||||
}
|
||||
|
||||
var color = disabled ? TextColorDisabled
|
||||
: IsValid() ? TextColor
|
||||
: TextColorInvalid;
|
||||
var color =
|
||||
disabled ? TextColorDisabled
|
||||
: IsValid() ? TextColor
|
||||
: TextColorInvalid;
|
||||
font.DrawText(apparentText, textPos, color);
|
||||
|
||||
if (showCursor && HasKeyboardFocus)
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Widgets
|
||||
0,
|
||||
0,
|
||||
video.Width,
|
||||
video.Height),
|
||||
video.Height),
|
||||
TextureChannel.Alpha);
|
||||
|
||||
var scale = Math.Min((float)RenderBounds.Width / video.Width, (float)RenderBounds.Height / video.Height * AspectRatio);
|
||||
@@ -121,15 +121,15 @@ namespace OpenRA.Widgets
|
||||
skippedFrames++;
|
||||
}
|
||||
|
||||
if (skippedFrames > 1)
|
||||
Log.Write("perf", "VqaPlayer : {0} skipped {1} frames at position {2}", cachedVideo, skippedFrames, video.CurrentFrame);
|
||||
if (skippedFrames > 1)
|
||||
Log.Write("perf", "VqaPlayer : {0} skipped {1} frames at position {2}", cachedVideo, skippedFrames, video.CurrentFrame);
|
||||
}
|
||||
|
||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(
|
||||
videoSprite,
|
||||
videoOrigin,
|
||||
videoSize);
|
||||
|
||||
|
||||
if (DrawOverlay)
|
||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(overlaySprite, videoOrigin, videoSize);
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ namespace OpenRA.Widgets
|
||||
public override string GetCursor(int2 pos) { return null; }
|
||||
public override Widget Clone() { return new ContainerWidget(this); }
|
||||
public Func<KeyInput, bool> OnKeyPress = _ => false;
|
||||
public override bool HandleKeyPress(KeyInput e) { return OnKeyPress(e); }
|
||||
public override bool HandleKeyPress(KeyInput e) { return OnKeyPress(e); }
|
||||
}
|
||||
|
||||
public class WidgetArgs : Dictionary<string, object>
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA
|
||||
{
|
||||
if (!args.ContainsKey("modRules"))
|
||||
args = new WidgetArgs(args) { { "modRules", modData.DefaultRules } };
|
||||
|
||||
|
||||
var widget = NewWidget(node.Key, args);
|
||||
|
||||
if (parent != null)
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace OpenRA.Widgets
|
||||
// Background
|
||||
if (ps.HasFlags(PanelSides.Center) && ss[8] != null)
|
||||
FillRectWithSprite(new Rectangle(bounds.Left + marginLeft, bounds.Top + marginTop,
|
||||
bounds.Width - marginWidth, bounds.Height - marginHeight),
|
||||
bounds.Width - marginWidth, bounds.Height - marginHeight),
|
||||
ss[8]);
|
||||
|
||||
// Left border
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Widgets
|
||||
var unit = World.ScreenMap.ActorsAt(xy)
|
||||
.WithHighestSelectionPriority();
|
||||
|
||||
var newSelection2 = SelectActorsInBox(World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight,
|
||||
var newSelection2 = SelectActorsInBox(World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight,
|
||||
a => unit != null && a.Info.Name == unit.Info.Name && a.Owner == unit.Owner);
|
||||
|
||||
World.Selection.Combine(World, newSelection2, true, false);
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
|
||||
// don't issue orders while selecting
|
||||
if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down && !hasBox)
|
||||
if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down && !hasBox)
|
||||
ApplyOrders(World, xy, mi);
|
||||
|
||||
lastMousePosition = xy;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA
|
||||
public bool ShroudObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(a); }
|
||||
public bool ShroudObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(p); }
|
||||
public bool ShroudObscures(int u, int v) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(u, v); }
|
||||
|
||||
|
||||
public Func<int, int, bool> FogObscuresTest(CellRegion region)
|
||||
{
|
||||
var rp = RenderPlayer;
|
||||
|
||||
Reference in New Issue
Block a user