Remove legacy sound code and simplify platform init.

This commit is contained in:
Paul Chote
2016-08-01 17:39:06 +01:00
parent de85a76c90
commit 9437a86e7e
9 changed files with 38 additions and 92 deletions

View File

@@ -17,6 +17,7 @@ using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using OpenRA.Chat;
@@ -252,16 +253,26 @@ namespace OpenRA
Log.AddChannel("irc", "irc.log");
Log.AddChannel("nat", "nat.log");
var renderers = new[] { Settings.Graphics.Renderer, "Default", null };
foreach (var r in renderers)
var platforms = new[] { Settings.Game.Platform, "Default", null };
foreach (var p in platforms)
{
if (r == null)
throw new InvalidOperationException("No suitable renderers were found. Check graphics.log for details.");
if (p == null)
throw new InvalidOperationException("Failed to initialize platform-integration library. Check graphics.log for details.");
Settings.Graphics.Renderer = r;
Settings.Game.Platform = p;
try
{
Renderer = new Renderer(Settings.Graphics, Settings.Server);
var rendererPath = Platform.ResolvePath(Path.Combine(".", "OpenRA.Platforms." + p + ".dll"));
var assembly = Assembly.LoadFile(rendererPath);
var platformType = assembly.GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t));
if (platformType == null)
throw new InvalidOperationException("Platform dll must include exactly one IPlatform implementation.");
var platform = (IPlatform)platformType.GetConstructor(Type.EmptyTypes).Invoke(null);
Renderer = new Renderer(platform, Settings.Graphics);
Sound = new Sound(platform, Settings.Sound);
break;
}
catch (Exception e)
@@ -281,8 +292,6 @@ namespace OpenRA
Game.Settings.Server.AllowPortForward = true;
}
Sound = new Sound(Settings.Sound.Engine);
GlobalChat = new GlobalChat();
Console.WriteLine("Available mods:");