Merge pull request #4129 from ScottNZ/refactor

Refactor
This commit is contained in:
Chris Forbes
2013-11-12 00:06:01 -08:00
319 changed files with 157 additions and 639 deletions

View File

@@ -19,7 +19,6 @@
#endregion #endregion
using System; using System;
using System.IO;
namespace GeoIP namespace GeoIP
{ {

View File

@@ -19,7 +19,6 @@
#endregion #endregion
using System; using System;
using System.IO;
namespace GeoIP namespace GeoIP
{ {

View File

@@ -19,7 +19,6 @@
#endregion #endregion
using System; using System;
using System.IO;
namespace GeoIP namespace GeoIP
{ {

View File

@@ -19,7 +19,6 @@
#endregion #endregion
using System; using System;
using System.IO;
public class Region public class Region
{ {

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System.Drawing; using System.Drawing;
using OpenRA.GameRules;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Editor namespace OpenRA.Editor

View File

@@ -700,7 +700,7 @@ namespace OpenRA.Editor
{ {
int imageLength = 0; int imageLength = 0;
int type = surface1.Map.MapResources.Value[x, y].Type; int type = surface1.Map.MapResources.Value[x, y].Type;
var template = surface1.ResourceTemplates.Where(a => a.Value.Info.ResourceType == type).FirstOrDefault().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)

View File

@@ -79,7 +79,7 @@ namespace OpenRA.Editor
} }
catch (Exception ed) catch (Exception ed)
{ {
Console.WriteLine("No map preview image found: {0}", ed.ToString()); Console.WriteLine("No map preview image found: {0}", ed);
} }
} }
} }

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using OpenRA.FileFormats; using OpenRA.FileFormats;

View File

@@ -107,7 +107,6 @@ namespace OpenRA.Editor
public Dictionary<int2, Bitmap> Chunks = new Dictionary<int2, Bitmap>(); public Dictionary<int2, Bitmap> Chunks = new Dictionary<int2, Bitmap>();
public Surface() public Surface()
: base()
{ {
BackColor = Color.Black; BackColor = Color.Black;

View File

@@ -11,7 +11,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;

View File

@@ -314,7 +314,7 @@ namespace OpenRA.FileFormats
return null; return null;
} }
static object ParseYesNo(string p, System.Type fieldType, string field) static object ParseYesNo(string p, Type fieldType, string field)
{ {
p = p.ToLowerInvariant(); p = p.ToLowerInvariant();
if (p == "yes") return true; if (p == "yes") return true;

View File

@@ -48,7 +48,7 @@ namespace OpenRA.FileFormats
public static MiniYamlNode SaveField(object o, string field) public static MiniYamlNode SaveField(object o, string field)
{ {
return new MiniYamlNode(field, FieldSaver.FormatValue(o, o.GetType().GetField(field))); return new MiniYamlNode(field, FormatValue(o, o.GetType().GetField(field)));
} }
public static string FormatValue(object v, Type t) public static string FormatValue(object v, Type t)

View File

@@ -92,7 +92,7 @@ namespace OpenRA.FileFormats
/// A fast (native) CRC32 implementation that can be used on a regular byte arrays. /// A fast (native) CRC32 implementation that can be used on a regular byte arrays.
/// </summary> /// </summary>
/// <param name="data">The data from which to calculate the checksum.</param> /// <param name="data">The data from which to calculate the checksum.</param>
/// <param name="polynomal">The polynomal.</param> /// <param name="polynomial">The polynomial.</param>
/// <returns> /// <returns>
/// The calculated checksum. /// The calculated checksum.
/// </returns> /// </returns>
@@ -115,7 +115,7 @@ namespace OpenRA.FileFormats
/// </summary> /// </summary>
/// <param name="data"> [in,out] If non-null, the.</param> /// <param name="data"> [in,out] If non-null, the.</param>
/// <param name="len"> The length of the data data.</param> /// <param name="len"> The length of the data data.</param>
/// <param name="polynomal">The polynomal to xor with.</param> /// <param name="polynomial">The polynomal to xor with.</param>
/// <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)
{ {

View File

@@ -56,7 +56,7 @@ namespace OpenRA.FileFormats
IniSection ProcessSection(string line) IniSection ProcessSection(string line)
{ {
Match m = sectionPattern.Match(line); Match m = sectionPattern.Match(line);
if (m == null || !m.Success) if (!m.Success)
return null; return null;
string sectionName = m.Groups[1].Value.ToLowerInvariant(); string sectionName = m.Groups[1].Value.ToLowerInvariant();

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Text;
namespace OpenRA.FileFormats namespace OpenRA.FileFormats
{ {

View File

@@ -9,11 +9,8 @@
#endregion #endregion
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq;
namespace OpenRA.FileFormats namespace OpenRA.FileFormats
{ {

View File

@@ -97,7 +97,7 @@ namespace OpenRA.FileFormats
name = Platform.SupportDir + name.Substring(1); name = Platform.SupportDir + name.Substring(1);
FolderPaths.Add(name); FolderPaths.Add(name);
Action a = () => FileSystem.MountInner(OpenPackage(name, annotation, order++)); Action a = () => MountInner(OpenPackage(name, annotation, order++));
if (optional) if (optional)
try { a(); } try { a(); }
@@ -197,8 +197,8 @@ namespace OpenRA.FileFormats
if (assemblyCache.TryGetValue(filename, out a)) if (assemblyCache.TryGetValue(filename, out a))
return a; return a;
if (FileSystem.Exists(filename)) if (Exists(filename))
using (var s = FileSystem.Open(filename)) using (var s = Open(filename))
{ {
var buf = new byte[s.Length]; var buf = new byte[s.Length];
s.Read(buf, 0, buf.Length); s.Read(buf, 0, buf.Length);

View File

@@ -10,7 +10,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System;
namespace OpenRA.FileFormats namespace OpenRA.FileFormats
{ {

View File

@@ -11,7 +11,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
namespace OpenRA.FileFormats namespace OpenRA.FileFormats
{ {

View File

@@ -9,9 +9,7 @@
#endregion #endregion
using System;
using System.IO; using System.IO;
using System.Linq;
namespace OpenRA.FileFormats namespace OpenRA.FileFormats
{ {

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO;
namespace OpenRA.FileFormats.Graphics namespace OpenRA.FileFormats.Graphics
{ {

View File

@@ -9,8 +9,6 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenRA namespace OpenRA
{ {

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;

View File

@@ -11,9 +11,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
namespace OpenRA.FileFormats namespace OpenRA.FileFormats
{ {

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@@ -8,11 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
namespace OpenRA namespace OpenRA
{ {
public struct Hotkey public struct Hotkey

View File

@@ -8,9 +8,7 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace OpenRA namespace OpenRA
{ {

View File

@@ -8,9 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Drawing;
namespace OpenRA.FileFormats namespace OpenRA.FileFormats
{ {
public class PlayerReference public class PlayerReference

View File

@@ -10,8 +10,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO; using System.IO;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.FileFormats.Primitives
public event Action<object, object> OnSet = (o, n) => { }; public event Action<object, object> OnSet = (o, n) => { };
public event Action OnRefresh = () => { }; public event Action OnRefresh = () => { };
public ObservableCollection() : base() { } public ObservableCollection() { }
public ObservableCollection(IList<T> list) : base(list) { } public ObservableCollection(IList<T> list) : base(list) { }
protected override void SetItem(int index, T item) protected override void SetItem(int index, T item)
@@ -53,7 +53,7 @@ namespace OpenRA.FileFormats.Primitives
public IEnumerable ObservedItems public IEnumerable ObservedItems
{ {
get { return base.Items; } get { return Items; }
} }
} }
} }

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System;
using System.Drawing; using System.Drawing;
namespace OpenRA.FileFormats namespace OpenRA.FileFormats

View File

@@ -11,9 +11,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
namespace OpenRA namespace OpenRA
{ {

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System; using System;
using System.Drawing;
namespace OpenRA namespace OpenRA
{ {

View File

@@ -8,10 +8,8 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Drawing;
namespace OpenRA namespace OpenRA
{ {

View File

@@ -8,8 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Drawing;
using System.Linq; using System.Linq;
namespace OpenRA namespace OpenRA

View File

@@ -8,9 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Drawing;
namespace OpenRA namespace OpenRA
{ {
/// <summary> /// <summary>

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System; using System;
using System.Drawing;
namespace OpenRA namespace OpenRA
{ {

View File

@@ -21,7 +21,7 @@ namespace OpenRA
public static string FormatErrorMessage(Exception e) public static string FormatErrorMessage(Exception e)
{ {
var ex = e as System.Net.WebException; var ex = e as WebException;
if (ex == null) if (ex == null)
return e.Message; return e.Message;
@@ -46,15 +46,15 @@ namespace OpenRA
wc.DownloadProgressChanged += (_, a) => onProgress(a); wc.DownloadProgressChanged += (_, a) => onProgress(a);
wc.DownloadFileCompleted += (_, a) => onComplete(a, cancelled); wc.DownloadFileCompleted += (_, a) => onComplete(a, cancelled);
Game.OnQuit += () => Cancel(); Game.OnQuit += Cancel;
wc.DownloadFileCompleted += (_, a) => { Game.OnQuit -= () => Cancel(); }; wc.DownloadFileCompleted += (_, a) => { Game.OnQuit -= Cancel; };
wc.DownloadFileAsync(new Uri(url), path); wc.DownloadFileAsync(new Uri(url), path);
} }
public void Cancel() public void Cancel()
{ {
Game.OnQuit -= () => Cancel(); Game.OnQuit -= Cancel;
wc.CancelAsync(); wc.CancelAsync();
cancelled = true; cancelled = true;
} }

View File

@@ -11,7 +11,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects namespace OpenRA.Effects
{ {

View File

@@ -10,7 +10,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects namespace OpenRA.Effects
{ {

View File

@@ -9,10 +9,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects namespace OpenRA.Effects
{ {

View File

@@ -103,7 +103,7 @@ namespace OpenRA
// Load a widget with world, orderManager, worldRenderer args, without adding it to the widget tree // Load a widget with world, orderManager, worldRenderer args, without adding it to the widget tree
public static Widget LoadWidget(World world, string id, Widget parent, WidgetArgs args) public static Widget LoadWidget(World world, string id, Widget parent, WidgetArgs args)
{ {
return Game.modData.WidgetLoader.LoadWidget(new WidgetArgs(args) return modData.WidgetLoader.LoadWidget(new WidgetArgs(args)
{ {
{ "world", world }, { "world", world },
{ "orderManager", orderManager }, { "orderManager", orderManager },
@@ -135,23 +135,23 @@ namespace OpenRA
// worldRenderer is null during the initial install/download screen // worldRenderer is null during the initial install/download screen
if (worldRenderer != null) if (worldRenderer != null)
{ {
Game.Renderer.BeginFrame(worldRenderer.Viewport.TopLeft.ToFloat2(), worldRenderer.Viewport.Zoom); Renderer.BeginFrame(worldRenderer.Viewport.TopLeft.ToFloat2(), worldRenderer.Viewport.Zoom);
Sound.SetListenerPosition(worldRenderer.Position(worldRenderer.Viewport.CenterLocation)); Sound.SetListenerPosition(worldRenderer.Position(worldRenderer.Viewport.CenterLocation));
worldRenderer.Draw(); worldRenderer.Draw();
} }
else else
Game.Renderer.BeginFrame(float2.Zero, 1f); Renderer.BeginFrame(float2.Zero, 1f);
using (new PerfSample("render_widgets")) using (new PerfSample("render_widgets"))
{ {
Ui.Draw(); Ui.Draw();
var cursorName = Ui.Root.GetCursorOuter(Viewport.LastMousePos) ?? "default"; var cursorName = Ui.Root.GetCursorOuter(Viewport.LastMousePos) ?? "default";
CursorProvider.DrawCursor(Game.Renderer, cursorName, Viewport.LastMousePos, (int)cursorFrame); CursorProvider.DrawCursor(Renderer, cursorName, Viewport.LastMousePos, (int)cursorFrame);
} }
using (new PerfSample("render_flip")) using (new PerfSample("render_flip"))
{ {
Game.Renderer.EndFrame(new DefaultInputHandler(orderManager.world)); Renderer.EndFrame(new DefaultInputHandler(orderManager.world));
} }
} }
@@ -374,13 +374,13 @@ namespace OpenRA
JoinLocal(); JoinLocal();
if (Game.Settings.Server.Dedicated) if (Settings.Server.Dedicated)
{ {
while (true) while (true)
{ {
Game.Settings.Server.Map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map); Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
Game.Settings.Save(); Settings.Save();
Game.CreateServer(new ServerSettings(Game.Settings.Server)); CreateServer(new ServerSettings(Settings.Server));
while (true) while (true)
{ {
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
@@ -393,15 +393,14 @@ namespace OpenRA
break; break;
} }
} }
if (Game.Settings.Server.DedicatedLoop) if (Settings.Server.DedicatedLoop)
{ {
Console.WriteLine("Starting a new server instance..."); Console.WriteLine("Starting a new server instance...");
continue; continue;
} }
else
break; break;
} }
System.Environment.Exit(0); Environment.Exit(0);
} }
else else
{ {
@@ -420,7 +419,7 @@ namespace OpenRA
var shellmaps = modData.AvailableMaps var shellmaps = modData.AvailableMaps
.Where(m => m.Value.UseAsShellmap); .Where(m => m.Value.UseAsShellmap);
if (shellmaps.Count() == 0) if (!shellmaps.Any())
throw new InvalidDataException("No valid shellmaps available"); throw new InvalidDataException("No valid shellmaps available");
return shellmaps.Random(CosmeticRandom).Key; return shellmaps.Random(CosmeticRandom).Key;
@@ -482,7 +481,7 @@ namespace OpenRA
public static void CreateServer(ServerSettings settings) public static void CreateServer(ServerSettings settings)
{ {
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort),
Game.Settings.Game.Mods, settings, modData); Settings.Game.Mods, settings, modData);
} }
public static int CreateLocalServer(string map) public static int CreateLocalServer(string map)
@@ -496,7 +495,7 @@ namespace OpenRA
}; };
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0), server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0),
Game.Settings.Game.Mods, settings, modData); Settings.Game.Mods, settings, modData);
return server.Port; return server.Port;
} }
@@ -510,7 +509,7 @@ namespace OpenRA
{ {
try try
{ {
var mod = Game.CurrentMods.FirstOrDefault().Value.Id; var mod = CurrentMods.First().Value.Id;
var dirPath = "{1}maps{0}{2}".F(Path.DirectorySeparatorChar, Platform.SupportDir, mod); var dirPath = "{1}maps{0}{2}".F(Path.DirectorySeparatorChar, Platform.SupportDir, mod);
if(!Directory.Exists(dirPath)) if(!Directory.Exists(dirPath))
Directory.CreateDirectory(dirPath); Directory.CreateDirectory(dirPath);

View File

@@ -10,12 +10,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics; using OpenRA.FileFormats.Graphics;
using OpenRA.Server;
namespace OpenRA.GameRules namespace OpenRA.GameRules
{ {

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
namespace OpenRA.Graphics namespace OpenRA.Graphics

View File

@@ -8,8 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;

View File

@@ -10,11 +10,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Xml;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Traits;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System.Xml;
using OpenRA.FileFormats; using OpenRA.FileFormats;
namespace OpenRA.Graphics namespace OpenRA.Graphics

View File

@@ -9,8 +9,6 @@
#endregion #endregion
using System.Drawing; using System.Drawing;
using System.IO;
using System.Xml;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -13,7 +13,6 @@ using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Graphics namespace OpenRA.Graphics

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics; using OpenRA.FileFormats.Graphics;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Graphics
public static Sheet AllocateSheet() public static Sheet AllocateSheet()
{ {
return new Sheet(new Size(Renderer.SheetSize, Renderer.SheetSize));; return new Sheet(new Size(Renderer.SheetSize, Renderer.SheetSize));
} }
internal SheetBuilder(SheetType t) internal SheetBuilder(SheetType t)

View File

@@ -11,7 +11,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using SharpFont; using SharpFont;

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;

View File

@@ -8,9 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics; using OpenRA.FileFormats.Graphics;
using OpenRA.Traits; using OpenRA.Traits;

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
namespace OpenRA.Graphics namespace OpenRA.Graphics

View File

@@ -11,11 +11,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;
using OpenRA.Traits;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {

View File

@@ -258,7 +258,7 @@ namespace OpenRA.Graphics
for (var i = 0; i < 8; i++) for (var i = 0; i < 8; i++)
{ {
var vec = new float[] {bounds[ix[i]], bounds[iy[i]], bounds[iz[i]], 1}; var vec = new float[] {bounds[ix[i]], bounds[iy[i]], bounds[iz[i]], 1};
var tvec = Util.MatrixVectorMultiply(mtx, vec); var tvec = MatrixVectorMultiply(mtx, vec);
ret[0] = Math.Min(ret[0], tvec[0]/tvec[3]); ret[0] = Math.Min(ret[0], tvec[0]/tvec[3]);
ret[1] = Math.Min(ret[1], tvec[1]/tvec[3]); ret[1] = Math.Min(ret[1], tvec[1]/tvec[3]);

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Support;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {

View File

@@ -9,11 +9,8 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;

View File

@@ -14,7 +14,6 @@ using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
namespace OpenRA namespace OpenRA
@@ -163,7 +162,7 @@ namespace OpenRA
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine("Failed to load map: {0}", path); Console.WriteLine("Failed to load map: {0}", path);
Console.WriteLine("Details: {0}", e.ToString()); Console.WriteLine("Details: {0}", e);
} }
} }

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@@ -10,8 +10,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.NetworkInformation;
using System.Threading;
namespace OpenRA.Network namespace OpenRA.Network
{ {

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System; using System;
using OpenRA.Network;
namespace OpenRA.Network namespace OpenRA.Network
{ {

View File

@@ -11,8 +11,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
namespace OpenRA.Network namespace OpenRA.Network
{ {

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using OpenRA.Widgets; using OpenRA.Widgets;
namespace OpenRA.Network namespace OpenRA.Network

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
@@ -43,11 +42,11 @@ namespace OpenRA.Network
break; break;
case "Client": case "Client":
session.Clients.Add(FieldLoader.Load<Session.Client>(y.Value)); session.Clients.Add(FieldLoader.Load<Client>(y.Value));
break; break;
case "Slot": case "Slot":
var s = FieldLoader.Load<Session.Slot>(y.Value); var s = FieldLoader.Load<Slot>(y.Value);
session.Slots.Add(s.PlayerReference, s); session.Slots.Add(s.PlayerReference, s);
break; break;
} }
@@ -144,7 +143,7 @@ namespace OpenRA.Network
public Session(string[] mods) public Session(string[] mods)
{ {
this.GlobalSettings.Mods = mods.ToArray(); this.GlobalSettings.Mods = mods.ToArray();
this.GlobalSettings.GameUid = System.Guid.NewGuid().ToString(); this.GlobalSettings.GameUid = Guid.NewGuid().ToString();
} }
public string Serialize() public string Serialize()

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Network
{ {
this.orderManager = orderManager; this.orderManager = orderManager;
for (var i = 0; i < NumSyncReports; i++) for (var i = 0; i < NumSyncReports; i++)
syncReports[i] = new SyncReport.Report(); syncReports[i] = new Report();
} }
internal void UpdateSyncReport() internal void UpdateSyncReport()

View File

@@ -11,8 +11,6 @@
using System; using System;
using Mono.Nat; using Mono.Nat;
using Mono.Nat.Pmp;
using Mono.Nat.Upnp;
namespace OpenRA.Network namespace OpenRA.Network
{ {

View File

@@ -9,9 +9,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Orders namespace OpenRA.Orders
{ {

View File

@@ -12,8 +12,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Net.NetworkInformation;
using System.Threading;
namespace OpenRA.Server namespace OpenRA.Server
{ {

View File

@@ -11,7 +11,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System;
namespace OpenRA.Server namespace OpenRA.Server
{ {

View File

@@ -340,7 +340,7 @@ namespace OpenRA.Server
if (File.Exists("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0]))) if (File.Exists("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0])))
{ {
var motd = System.IO.File.ReadAllText("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0])); var motd = File.ReadAllText("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0]));
SendOrderTo(newConn, "Message", motd); SendOrderTo(newConn, "Message", motd);
} }

View File

@@ -272,7 +272,7 @@ namespace OpenRA
} }
// Returns true if played successfully // Returns true if played successfully
public static bool PlayPredefined(Player p, Actor voicedUnit, string type, string definition, string variant, bool attentuateVolume) public static bool PlayPredefined(Player p, Actor voicedUnit, string type, string definition, string variant, bool attenuateVolume)
{ {
if (definition == null) return false; if (definition == null) return false;
@@ -323,7 +323,7 @@ namespace OpenRA
if (!String.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer)) if (!String.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer))
soundEngine.Play2D(sounds[name], soundEngine.Play2D(sounds[name],
false, true, WPos.Zero, false, true, WPos.Zero,
InternalSoundVolume, attentuateVolume); InternalSoundVolume, attenuateVolume);
return true; return true;
} }
@@ -604,8 +604,8 @@ namespace OpenRA
int state; int state;
Al.alGetSourcei(b, Al.AL_SOURCE_STATE, out state); Al.alGetSourcei(b, Al.AL_SOURCE_STATE, out state);
return ((state == Al.AL_PLAYING || state == Al.AL_PAUSED) && return ((state == Al.AL_PLAYING || state == Al.AL_PAUSED) &&
((music != null) ? b != ((OpenAlSound)music).source : true) && ((music == null) || b != ((OpenAlSound)music).source) &&
((video != null) ? b != ((OpenAlSound)video).source : true)); ((video == null) || b != ((OpenAlSound)video).source));
}).ToList(); }).ToList();
foreach (var s in sounds) foreach (var s in sounds)
{ {

View File

@@ -21,11 +21,11 @@ namespace OpenRA
public Arguments(params string[] src) public Arguments(params string[] src)
{ {
Regex regex = new Regex("([^=]+)=(.*)"); var regex = new Regex("([^=]+)=(.*)");
foreach (string s in src) foreach (var s in src)
{ {
Match m = regex.Match(s); Match m = regex.Match(s);
if (m == null || !m.Success) if (!m.Success)
continue; continue;
args[m.Groups[1].Value] = m.Groups[2].Value; args[m.Groups[1].Value] = m.Groups[2].Value;

View File

@@ -8,10 +8,8 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

@@ -8,10 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.FileFormats; using OpenRA.FileFormats;
namespace OpenRA.Traits namespace OpenRA.Traits

View File

@@ -8,9 +8,6 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using OpenRA.Network;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
public class DebugPauseStateInfo : ITraitInfo public class DebugPauseStateInfo : ITraitInfo

View File

@@ -10,7 +10,6 @@
using System.Drawing; using System.Drawing;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Effects;
using System.Collections.Generic; using System.Collections.Generic;
namespace OpenRA.Traits namespace OpenRA.Traits

View File

@@ -8,8 +8,6 @@
*/ */
#endregion #endregion
using System;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
public class DeveloperModeInfo : ITraitInfo public class DeveloperModeInfo : ITraitInfo

View File

@@ -8,13 +8,10 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System.Drawing;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Linq; using System.Linq;
using OpenRA.GameRules;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System.Linq; using System.Linq;
using OpenRA.Network;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.FileFormats;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.FileFormats; using OpenRA.FileFormats;

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
@@ -65,7 +64,7 @@ namespace OpenRA.Traits
return; return;
var pipSources = self.TraitsImplementing<IPips>(); var pipSources = self.TraitsImplementing<IPips>();
if (pipSources.Count() == 0) if (!pipSources.Any())
return; return;
var pipImages = new Animation("pips"); var pipImages = new Animation("pips");

View File

@@ -32,14 +32,14 @@ namespace OpenRA.Traits
public static Target FromOrder(Order o) public static Target FromOrder(Order o)
{ {
return o.TargetActor != null return o.TargetActor != null
? Target.FromActor(o.TargetActor) ? FromActor(o.TargetActor)
: Target.FromCell(o.TargetLocation); : FromCell(o.TargetLocation);
} }
public static Target FromActor(Actor a) public static Target FromActor(Actor a)
{ {
if (a == null) if (a == null)
return Target.Invalid; return Invalid;
return new Target return new Target
{ {

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Support; using OpenRA.Support;
@@ -135,7 +134,7 @@ namespace OpenRA.Traits
public static IEnumerable<CPos> AdjacentCells(Target target) public static IEnumerable<CPos> AdjacentCells(Target target)
{ {
var cells = target.Positions.Select(p => p.ToCPos()).Distinct(); var cells = target.Positions.Select(p => p.ToCPos()).Distinct();
return Util.ExpandFootprint(cells, true); return ExpandFootprint(cells, true);
} }
} }
} }

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Traits;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;

View File

@@ -14,7 +14,6 @@ using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Graphics;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Widgets
WidgetUtils.DrawPanel(Background, RenderBounds); WidgetUtils.DrawPanel(Background, RenderBounds);
} }
public BackgroundWidget() : base() { } public BackgroundWidget() { }
bool moving; bool moving;
int2? prevMouseLocation; int2? prevMouseLocation;

Some files were not shown because too many files have changed in this diff Show More