Remove some misc redundancies
This commit is contained in:
@@ -103,7 +103,7 @@ namespace OpenRA
|
||||
// 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)
|
||||
{
|
||||
return Game.modData.WidgetLoader.LoadWidget(new WidgetArgs(args)
|
||||
return modData.WidgetLoader.LoadWidget(new WidgetArgs(args)
|
||||
{
|
||||
{ "world", world },
|
||||
{ "orderManager", orderManager },
|
||||
@@ -135,23 +135,23 @@ namespace OpenRA
|
||||
// worldRenderer is null during the initial install/download screen
|
||||
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));
|
||||
worldRenderer.Draw();
|
||||
}
|
||||
else
|
||||
Game.Renderer.BeginFrame(float2.Zero, 1f);
|
||||
Renderer.BeginFrame(float2.Zero, 1f);
|
||||
|
||||
using (new PerfSample("render_widgets"))
|
||||
{
|
||||
Ui.Draw();
|
||||
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"))
|
||||
{
|
||||
Game.Renderer.EndFrame(new DefaultInputHandler(orderManager.world));
|
||||
Renderer.EndFrame(new DefaultInputHandler(orderManager.world));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,13 +374,13 @@ namespace OpenRA
|
||||
|
||||
JoinLocal();
|
||||
|
||||
if (Game.Settings.Server.Dedicated)
|
||||
if (Settings.Server.Dedicated)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Game.Settings.Server.Map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
|
||||
Game.Settings.Save();
|
||||
Game.CreateServer(new ServerSettings(Game.Settings.Server));
|
||||
Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
|
||||
Settings.Save();
|
||||
CreateServer(new ServerSettings(Settings.Server));
|
||||
while (true)
|
||||
{
|
||||
System.Threading.Thread.Sleep(100);
|
||||
@@ -393,15 +393,14 @@ namespace OpenRA
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Game.Settings.Server.DedicatedLoop)
|
||||
if (Settings.Server.DedicatedLoop)
|
||||
{
|
||||
Console.WriteLine("Starting a new server instance...");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
break;
|
||||
break;
|
||||
}
|
||||
System.Environment.Exit(0);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -420,7 +419,7 @@ namespace OpenRA
|
||||
var shellmaps = modData.AvailableMaps
|
||||
.Where(m => m.Value.UseAsShellmap);
|
||||
|
||||
if (shellmaps.Count() == 0)
|
||||
if (!shellmaps.Any())
|
||||
throw new InvalidDataException("No valid shellmaps available");
|
||||
|
||||
return shellmaps.Random(CosmeticRandom).Key;
|
||||
@@ -482,7 +481,7 @@ namespace OpenRA
|
||||
public static void CreateServer(ServerSettings settings)
|
||||
{
|
||||
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)
|
||||
@@ -496,7 +495,7 @@ namespace OpenRA
|
||||
};
|
||||
|
||||
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0),
|
||||
Game.Settings.Game.Mods, settings, modData);
|
||||
Settings.Game.Mods, settings, modData);
|
||||
|
||||
return server.Port;
|
||||
}
|
||||
@@ -510,7 +509,7 @@ namespace OpenRA
|
||||
{
|
||||
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);
|
||||
if(!Directory.Exists(dirPath))
|
||||
Directory.CreateDirectory(dirPath);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
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)
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace OpenRA.Graphics
|
||||
for (var i = 0; i < 8; i++)
|
||||
{
|
||||
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[1] = Math.Min(ret[1], tvec[1]/tvec[3]);
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace OpenRA
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Failed to load map: {0}", path);
|
||||
Console.WriteLine("Details: {0}", e.ToString());
|
||||
Console.WriteLine("Details: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ namespace OpenRA.Network
|
||||
break;
|
||||
|
||||
case "Client":
|
||||
session.Clients.Add(FieldLoader.Load<Session.Client>(y.Value));
|
||||
session.Clients.Add(FieldLoader.Load<Client>(y.Value));
|
||||
break;
|
||||
|
||||
case "Slot":
|
||||
var s = FieldLoader.Load<Session.Slot>(y.Value);
|
||||
var s = FieldLoader.Load<Slot>(y.Value);
|
||||
session.Slots.Add(s.PlayerReference, s);
|
||||
break;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace OpenRA.Network
|
||||
public Session(string[] mods)
|
||||
{
|
||||
this.GlobalSettings.Mods = mods.ToArray();
|
||||
this.GlobalSettings.GameUid = System.Guid.NewGuid().ToString();
|
||||
this.GlobalSettings.GameUid = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
public string Serialize()
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Network
|
||||
{
|
||||
this.orderManager = orderManager;
|
||||
for (var i = 0; i < NumSyncReports; i++)
|
||||
syncReports[i] = new SyncReport.Report();
|
||||
syncReports[i] = new Report();
|
||||
}
|
||||
|
||||
internal void UpdateSyncReport()
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
@@ -338,7 +340,7 @@ namespace OpenRA.Server
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -604,8 +604,8 @@ namespace OpenRA
|
||||
int state;
|
||||
Al.alGetSourcei(b, Al.AL_SOURCE_STATE, out state);
|
||||
return ((state == Al.AL_PLAYING || state == Al.AL_PAUSED) &&
|
||||
((music != null) ? b != ((OpenAlSound)music).source : true) &&
|
||||
((video != null) ? b != ((OpenAlSound)video).source : true));
|
||||
((music == null) || b != ((OpenAlSound)music).source) &&
|
||||
((video == null) || b != ((OpenAlSound)video).source));
|
||||
}).ToList();
|
||||
foreach (var s in sounds)
|
||||
{
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace OpenRA
|
||||
|
||||
public Arguments(params string[] src)
|
||||
{
|
||||
Regex regex = new Regex("([^=]+)=(.*)");
|
||||
foreach (string s in src)
|
||||
var regex = new Regex("([^=]+)=(.*)");
|
||||
foreach (var s in src)
|
||||
{
|
||||
Match m = regex.Match(s);
|
||||
if (m == null || !m.Success)
|
||||
if (!m.Success)
|
||||
continue;
|
||||
|
||||
args[m.Groups[1].Value] = m.Groups[2].Value;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Traits
|
||||
return;
|
||||
|
||||
var pipSources = self.TraitsImplementing<IPips>();
|
||||
if (pipSources.Count() == 0)
|
||||
if (!pipSources.Any())
|
||||
return;
|
||||
|
||||
var pipImages = new Animation("pips");
|
||||
|
||||
@@ -32,14 +32,14 @@ namespace OpenRA.Traits
|
||||
public static Target FromOrder(Order o)
|
||||
{
|
||||
return o.TargetActor != null
|
||||
? Target.FromActor(o.TargetActor)
|
||||
: Target.FromCell(o.TargetLocation);
|
||||
? FromActor(o.TargetActor)
|
||||
: FromCell(o.TargetLocation);
|
||||
}
|
||||
|
||||
public static Target FromActor(Actor a)
|
||||
{
|
||||
if (a == null)
|
||||
return Target.Invalid;
|
||||
return Invalid;
|
||||
|
||||
return new Target
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace OpenRA.Traits
|
||||
public static IEnumerable<CPos> AdjacentCells(Target target)
|
||||
{
|
||||
var cells = target.Positions.Select(p => p.ToCPos()).Distinct();
|
||||
return Util.ExpandFootprint(cells, true);
|
||||
return ExpandFootprint(cells, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public virtual void DrawBackground(Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted)
|
||||
{
|
||||
ButtonWidget.DrawBackground("button", rect, disabled, pressed, hover, highlighted);
|
||||
DrawBackground("button", rect, disabled, pressed, hover, highlighted);
|
||||
}
|
||||
|
||||
public static void DrawBackground(string baseName, Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted)
|
||||
|
||||
@@ -57,8 +57,8 @@ namespace OpenRA.Widgets
|
||||
|
||||
var useClassicMouseStyle = Game.Settings.Game.UseClassicMouseStyle;
|
||||
|
||||
var hasBox = (SelectionBox != null) ? true : false;
|
||||
var multiClick = (mi.MultiTapCount >= 2) ? true : false;
|
||||
var hasBox = SelectionBox != null;
|
||||
var multiClick = mi.MultiTapCount >= 2;
|
||||
|
||||
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Widgets
|
||||
dragStart = dragEnd = xy;
|
||||
|
||||
// place buildings
|
||||
if (!useClassicMouseStyle || (useClassicMouseStyle && !World.Selection.Actors.Any()))
|
||||
if (!useClassicMouseStyle || !World.Selection.Actors.Any())
|
||||
ApplyOrders(World, xy, mi);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace OpenRA
|
||||
public static string GetTerrainType(this World world, CPos cell)
|
||||
{
|
||||
var custom = world.Map.CustomTerrain[cell.X, cell.Y];
|
||||
return custom != null ? custom : world.TileSet.GetTerrainType(world.Map.MapTiles.Value[cell.X, cell.Y]);
|
||||
return custom ?? world.TileSet.GetTerrainType(world.Map.MapTiles.Value[cell.X, cell.Y]);
|
||||
}
|
||||
|
||||
public static TerrainTypeInfo GetTerrainInfo(this World world, CPos cell)
|
||||
|
||||
Reference in New Issue
Block a user