basic dedicated server support

This commit is contained in:
Igor Popov
2012-06-07 18:08:22 +04:00
committed by Chris Forbes
parent 03229eca0c
commit bf73cdbd01
4 changed files with 28 additions and 3 deletions

View File

@@ -302,9 +302,28 @@ namespace OpenRA
JoinLocal();
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
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()
{

View File

@@ -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;
}
}

View File

@@ -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 );
}

View File

@@ -500,6 +500,7 @@ namespace OpenRA.Server
{
GameStarted = true;
listener.Stop();
Console.WriteLine("Game started");
foreach( var c in conns )