Support loopback servers for solo play
This commit is contained in:
@@ -364,16 +364,20 @@ namespace OpenRA
|
||||
{
|
||||
return modData.ObjectCreator.CreateObject<T>( name );
|
||||
}
|
||||
|
||||
public static void CreateServer(Settings settings, string map)
|
||||
|
||||
public static void CreateServer(int port, string name, string map)
|
||||
{
|
||||
server = new Server.Server(modData, settings, map);
|
||||
server = new Server.Server(IPAddress.Any, port, name, Settings.Game.Mods, map, modData);
|
||||
}
|
||||
|
||||
public static void CreateAndJoinServer(Settings settings, string map)
|
||||
|
||||
public static void CreateLocalServer(string map)
|
||||
{
|
||||
CreateServer(settings, map);
|
||||
JoinServer(IPAddress.Loopback.ToString(), settings.Server.ListenPort);
|
||||
server = new Server.Server(IPAddress.Loopback,
|
||||
Game.Settings.Server.LoopbackPort,
|
||||
"Skirmish Game",
|
||||
Game.Settings.Game.Mods,
|
||||
map,
|
||||
modData);
|
||||
}
|
||||
|
||||
public static bool IsCurrentWorld(World world)
|
||||
|
||||
@@ -22,8 +22,9 @@ namespace OpenRA.GameRules
|
||||
public class ServerSettings
|
||||
{
|
||||
public string Name = "OpenRA Game";
|
||||
public int ListenPort = 1234;
|
||||
public int ExternalPort = 1234;
|
||||
public int LoopbackPort = 1234; // Port used for soloplay servers
|
||||
public int ListenPort = 1234; // Port that we listen on
|
||||
public int ExternalPort = 1234; // Router port that the master server forwards people to
|
||||
public bool AdvertiseOnline = true;
|
||||
public string MasterServer = "http://master.open-ra.org/";
|
||||
public bool AllowCheats = false;
|
||||
|
||||
@@ -49,22 +49,21 @@ namespace OpenRA.Server
|
||||
shutdown = true;
|
||||
}
|
||||
|
||||
public Server(ModData modData, Settings settings, string map)
|
||||
public Server(IPAddress ip, int port, string serverName, string[] mods, string map, ModData modData)
|
||||
{
|
||||
Log.AddChannel("server", "server.log");
|
||||
|
||||
listener = new TcpListener(IPAddress.Any, settings.Server.ListenPort);
|
||||
Name = settings.Server.Name;
|
||||
listener = new TcpListener(ip, port);
|
||||
Name = serverName;
|
||||
randomSeed = (int)DateTime.Now.ToBinary();
|
||||
ModData = modData;
|
||||
|
||||
foreach (var trait in modData.Manifest.ServerTraits)
|
||||
ServerTraits.Add( modData.ObjectCreator.CreateObject<ServerTrait>(trait) );
|
||||
|
||||
lobbyInfo = new Session( settings.Game.Mods );
|
||||
lobbyInfo = new Session( mods );
|
||||
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
|
||||
lobbyInfo.GlobalSettings.Map = map;
|
||||
lobbyInfo.GlobalSettings.ServerName = settings.Server.Name;
|
||||
lobbyInfo.GlobalSettings.ServerName = serverName;
|
||||
|
||||
foreach (var t in ServerTraits.WithInterface<INotifyServerStart>())
|
||||
t.ServerStarted(this);
|
||||
|
||||
Reference in New Issue
Block a user