basic dedicated server support
This commit is contained in:
@@ -302,8 +302,27 @@ namespace OpenRA
|
||||
JoinLocal();
|
||||
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
|
||||
|
||||
modData.LoadScreen.StartGame();
|
||||
Settings.Save();
|
||||
if (Game.Settings.Server.Dedicated)
|
||||
{
|
||||
Game.CreateServer(new ServerSettings(Game.Settings.Server));
|
||||
while(true)
|
||||
{
|
||||
System.Threading.Thread.Sleep(100);
|
||||
|
||||
//Accessing public field and List::Count is thread safe
|
||||
if((server.GameStarted)&&(server.conns.Count<=1))
|
||||
{
|
||||
Console.WriteLine("No one is playing, shutting down...");
|
||||
server.Shutdown();
|
||||
System.Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
modData.LoadScreen.StartGame();
|
||||
Settings.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadShellMap()
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace OpenRA.GameRules
|
||||
public string Map = null;
|
||||
public string[] Ban = null;
|
||||
public int TimeOut = 0;
|
||||
public bool Dedicated = false;
|
||||
|
||||
public ServerSettings() { }
|
||||
|
||||
@@ -49,6 +50,7 @@ namespace OpenRA.GameRules
|
||||
Map = other.Map;
|
||||
Ban = other.Ban;
|
||||
TimeOut = other.TimeOut;
|
||||
Dedicated = other.Dedicated;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,10 @@ namespace OpenRA.Graphics
|
||||
FixOSX();
|
||||
|
||||
var resolution = GetResolution( windowMode );
|
||||
var rendererPath = Path.GetFullPath( "OpenRA.Renderer.{0}.dll".F(Game.Settings.Graphics.Renderer) );
|
||||
|
||||
string renderer = Game.Settings.Server.Dedicated?"Null":Game.Settings.Graphics.Renderer;
|
||||
var rendererPath = Path.GetFullPath( "OpenRA.Renderer.{0}.dll".F(renderer) );
|
||||
|
||||
device = CreateDevice( Assembly.LoadFile( rendererPath ), resolution.Width, resolution.Height, windowMode );
|
||||
}
|
||||
|
||||
|
||||
@@ -500,6 +500,7 @@ namespace OpenRA.Server
|
||||
{
|
||||
GameStarted = true;
|
||||
listener.Stop();
|
||||
|
||||
Console.WriteLine("Game started");
|
||||
|
||||
foreach( var c in conns )
|
||||
|
||||
Reference in New Issue
Block a user