Move dedicated server code to OpenRA.Server.exe
This commit is contained in:
@@ -279,7 +279,7 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
Sound = new Sound(Settings.Server.Dedicated ? "Null" : Settings.Sound.Engine);
|
||||
Sound = new Sound(Settings.Sound.Engine);
|
||||
|
||||
GlobalChat = new GlobalChat();
|
||||
|
||||
@@ -341,17 +341,11 @@ namespace OpenRA
|
||||
|
||||
Sound.StopVideo();
|
||||
|
||||
ModData = new ModData(mod, !Settings.Server.Dedicated);
|
||||
ModData = new ModData(mod, true);
|
||||
|
||||
using (new PerfTimer("LoadMaps"))
|
||||
ModData.MapCache.LoadMaps();
|
||||
|
||||
if (Settings.Server.Dedicated)
|
||||
{
|
||||
RunDedicatedServer();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
var installData = ModData.Manifest.Get<ContentInstaller>();
|
||||
var isModContentInstalled = installData.TestFiles.All(f => File.Exists(Platform.ResolvePath(f)));
|
||||
|
||||
@@ -398,37 +392,6 @@ namespace OpenRA
|
||||
ModData.LoadScreen.StartGame(args);
|
||||
}
|
||||
|
||||
public static void RunDedicatedServer()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Settings.Server.Map = ModData.MapCache.ChooseInitialMap(Settings.Server.Map, CosmeticRandom);
|
||||
Settings.Save();
|
||||
CreateServer(Settings.Server.Clone());
|
||||
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
|
||||
if (server.State == Server.ServerState.GameStarted && server.Conns.Count < 1)
|
||||
{
|
||||
Console.WriteLine("No one is playing, shutting down...");
|
||||
server.Shutdown();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.Server.DedicatedLoop)
|
||||
{
|
||||
Console.WriteLine("Starting a new server instance...");
|
||||
ModData.MapCache.LoadMaps();
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadEditor(string mapUid)
|
||||
{
|
||||
StartGame(mapUid, WorldType.Editor);
|
||||
@@ -811,7 +774,7 @@ namespace OpenRA
|
||||
|
||||
public static void CreateServer(ServerSettings settings)
|
||||
{
|
||||
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, ModData);
|
||||
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, ModData, false);
|
||||
}
|
||||
|
||||
public static int CreateLocalServer(string map)
|
||||
@@ -824,7 +787,7 @@ namespace OpenRA
|
||||
AllowPortForward = false
|
||||
};
|
||||
|
||||
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0), settings, ModData);
|
||||
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0), settings, ModData, false);
|
||||
|
||||
return server.Port;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user