Nit: use ServerSettings to pass info to the server
This commit is contained in:
@@ -372,20 +372,23 @@ namespace OpenRA
|
||||
return modData.ObjectCreator.CreateObject<T>( name );
|
||||
}
|
||||
|
||||
public static void CreateServer(string name, string map, int port, bool advertiseOnline, int externalPort)
|
||||
public static void CreateServer(ServerSettings settings)
|
||||
{
|
||||
server = new Server.Server(IPAddress.Any, port, name, Settings.Game.Mods, map, advertiseOnline, externalPort, modData);
|
||||
server = new Server.Server(IPAddress.Any, settings.ListenPort, Game.Settings.Game.Mods, settings, modData);
|
||||
}
|
||||
|
||||
public static void CreateLocalServer(string map)
|
||||
{
|
||||
var settings = new ServerSettings()
|
||||
{
|
||||
Name = "Skirmish Game",
|
||||
AdvertiseOnline = false,
|
||||
Map = map
|
||||
};
|
||||
server = new Server.Server(IPAddress.Loopback,
|
||||
Game.Settings.Server.LoopbackPort,
|
||||
"Skirmish Game",
|
||||
Game.Settings.Game.Mods,
|
||||
map,
|
||||
false,
|
||||
0,
|
||||
settings,
|
||||
modData);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,20 @@ namespace OpenRA.GameRules
|
||||
public bool AdvertiseOnline = true;
|
||||
public string MasterServer = "http://master.open-ra.org/";
|
||||
public bool AllowCheats = false;
|
||||
public string LastMap = null;
|
||||
public string Map = null;
|
||||
|
||||
public ServerSettings() { }
|
||||
public ServerSettings(ServerSettings other)
|
||||
{
|
||||
Name = other.Name;
|
||||
LoopbackPort = other.LoopbackPort;
|
||||
ListenPort = other.ListenPort;
|
||||
ExternalPort = other.ExternalPort;
|
||||
AdvertiseOnline = other.AdvertiseOnline;
|
||||
MasterServer = other.MasterServer;
|
||||
AllowCheats = other.AllowCheats;
|
||||
Map = other.Map;
|
||||
}
|
||||
}
|
||||
|
||||
public class DebugSettings
|
||||
|
||||
@@ -37,13 +37,11 @@ namespace OpenRA.Server
|
||||
TypeDictionary ServerTraits = new TypeDictionary();
|
||||
public Session lobbyInfo;
|
||||
public bool GameStarted = false;
|
||||
public string Name;
|
||||
public IPAddress Ip {get; private set;}
|
||||
public int Port {get; private set;}
|
||||
public int ExternalPort {get; private set;}
|
||||
public bool AdvertiseOnline {get; private set;}
|
||||
public readonly IPAddress Ip;
|
||||
public readonly int Port;
|
||||
int randomSeed;
|
||||
|
||||
public ServerSettings Settings;
|
||||
public ModData ModData;
|
||||
public Map Map;
|
||||
|
||||
@@ -53,25 +51,23 @@ namespace OpenRA.Server
|
||||
shutdown = true;
|
||||
}
|
||||
|
||||
public Server(IPAddress ip, int port, string serverName, string[] mods, string map, bool advertiseOnline, int externalPort, ModData modData)
|
||||
public Server(IPAddress ip, int port, string[] mods, ServerSettings settings, ModData modData)
|
||||
{
|
||||
Log.AddChannel("server", "server.log");
|
||||
Settings = settings;
|
||||
Ip = ip;
|
||||
Port = port;
|
||||
ExternalPort = externalPort;
|
||||
listener = new TcpListener(ip, port);
|
||||
Name = serverName;
|
||||
randomSeed = (int)DateTime.Now.ToBinary();
|
||||
ModData = modData;
|
||||
AdvertiseOnline = advertiseOnline;
|
||||
|
||||
foreach (var trait in modData.Manifest.ServerTraits)
|
||||
ServerTraits.Add( modData.ObjectCreator.CreateObject<ServerTrait>(trait) );
|
||||
|
||||
lobbyInfo = new Session( mods );
|
||||
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
|
||||
lobbyInfo.GlobalSettings.Map = map;
|
||||
lobbyInfo.GlobalSettings.ServerName = serverName;
|
||||
lobbyInfo.GlobalSettings.Map = settings.Map;
|
||||
lobbyInfo.GlobalSettings.ServerName = settings.Name;
|
||||
|
||||
foreach (var t in ServerTraits.WithInterface<INotifyServerStart>())
|
||||
t.ServerStarted(this);
|
||||
|
||||
Reference in New Issue
Block a user