basic dedicated server support
This commit is contained in:
@@ -302,8 +302,27 @@ namespace OpenRA
|
|||||||
JoinLocal();
|
JoinLocal();
|
||||||
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
|
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
|
||||||
|
|
||||||
modData.LoadScreen.StartGame();
|
if (Game.Settings.Server.Dedicated)
|
||||||
Settings.Save();
|
{
|
||||||
|
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()
|
public static void LoadShellMap()
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace OpenRA.GameRules
|
|||||||
public string Map = null;
|
public string Map = null;
|
||||||
public string[] Ban = null;
|
public string[] Ban = null;
|
||||||
public int TimeOut = 0;
|
public int TimeOut = 0;
|
||||||
|
public bool Dedicated = false;
|
||||||
|
|
||||||
public ServerSettings() { }
|
public ServerSettings() { }
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ namespace OpenRA.GameRules
|
|||||||
Map = other.Map;
|
Map = other.Map;
|
||||||
Ban = other.Ban;
|
Ban = other.Ban;
|
||||||
TimeOut = other.TimeOut;
|
TimeOut = other.TimeOut;
|
||||||
|
Dedicated = other.Dedicated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,10 @@ namespace OpenRA.Graphics
|
|||||||
FixOSX();
|
FixOSX();
|
||||||
|
|
||||||
var resolution = GetResolution( windowMode );
|
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 );
|
device = CreateDevice( Assembly.LoadFile( rendererPath ), resolution.Width, resolution.Height, windowMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -500,6 +500,7 @@ namespace OpenRA.Server
|
|||||||
{
|
{
|
||||||
GameStarted = true;
|
GameStarted = true;
|
||||||
listener.Stop();
|
listener.Stop();
|
||||||
|
|
||||||
Console.WriteLine("Game started");
|
Console.WriteLine("Game started");
|
||||||
|
|
||||||
foreach( var c in conns )
|
foreach( var c in conns )
|
||||||
|
|||||||
Reference in New Issue
Block a user