Nit: use ServerSettings to pass info to the server

This commit is contained in:
Paul Chote
2011-05-13 10:20:03 +12:00
parent f4ea4c5daa
commit 529ed51034
7 changed files with 47 additions and 30 deletions

View File

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