server loads the map (part 1)

This commit is contained in:
Chris Forbes
2010-08-23 18:09:37 +12:00
parent 3f11c32c4a
commit fd9a31168d
2 changed files with 19 additions and 4 deletions

View File

@@ -43,9 +43,11 @@ namespace OpenRA.Server
static bool isInternetServer; static bool isInternetServer;
static string masterServerUrl; static string masterServerUrl;
static bool isInitialPing; static bool isInitialPing;
static ModData ModData;
static Map Map;
public static void ServerMain(bool internetServer, string masterServerUrl, string name, int port, int extport, public static void ServerMain(bool internetServer, string masterServerUrl, string name, int port, int extport,
string[] mods, string map, bool cheats) string[] mods, string map, bool cheats, ModData modData)
{ {
Log.AddChannel("server", "server.log"); Log.AddChannel("server", "server.log");
@@ -56,6 +58,7 @@ namespace OpenRA.Server
Name = name; Name = name;
ExternalPort = extport; ExternalPort = extport;
randomSeed = (int)DateTime.Now.ToBinary(); randomSeed = (int)DateTime.Now.ToBinary();
ModData = modData;
lobbyInfo = new Session(); lobbyInfo = new Session();
lobbyInfo.GlobalSettings.Mods = mods; lobbyInfo.GlobalSettings.Mods = mods;
@@ -63,12 +66,16 @@ namespace OpenRA.Server
lobbyInfo.GlobalSettings.Map = map; lobbyInfo.GlobalSettings.Map = map;
lobbyInfo.GlobalSettings.AllowCheats = cheats; lobbyInfo.GlobalSettings.AllowCheats = cheats;
LoadMap(); // populates the Session's slots, too.
Log.Write("server", "Initial mods: "); Log.Write("server", "Initial mods: ");
foreach( var m in lobbyInfo.GlobalSettings.Mods ) foreach( var m in lobbyInfo.GlobalSettings.Mods )
Log.Write("server","- {0}", m); Log.Write("server","- {0}", m);
Log.Write("server", "Initial map: {0}",lobbyInfo.GlobalSettings.Map); Log.Write("server", "Initial map: {0}",lobbyInfo.GlobalSettings.Map);
try try
{ {
listener.Start(); listener.Start();
@@ -109,6 +116,11 @@ namespace OpenRA.Server
} ) { IsBackground = true }.Start(); } ) { IsBackground = true }.Start();
} }
static void LoadMap()
{
Map = new Map(ModData.AvailableMaps[lobbyInfo.GlobalSettings.Map].Package);
}
static int ChooseFreePlayerIndex() static int ChooseFreePlayerIndex()
{ {
for (var i = 0; i < 8; i++) for (var i = 0; i < 8; i++)
@@ -338,6 +350,8 @@ namespace OpenRA.Server
return true; return true;
} }
lobbyInfo.GlobalSettings.Map = s; lobbyInfo.GlobalSettings.Map = s;
LoadMap();
foreach(var client in lobbyInfo.Clients) foreach(var client in lobbyInfo.Clients)
{ {
client.SpawnPoint = 0; client.SpawnPoint = 0;

View File

@@ -44,7 +44,8 @@ namespace OpenRA.Widgets.Delegates
Game.Settings.Save(); Game.Settings.Save();
Server.Server.ServerMain(Game.Settings.AdvertiseOnline, Game.Settings.MasterServer, Game.Settings.LastServerTitle, Server.Server.ServerMain(Game.Settings.AdvertiseOnline, Game.Settings.MasterServer, Game.Settings.LastServerTitle,
Game.Settings.ListenPort, Game.Settings.ExternalPort, mods, map, Game.Settings.AllowCheats); Game.Settings.ListenPort, Game.Settings.ExternalPort, mods, map, Game.Settings.AllowCheats,
Game.modData);
Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort); Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort);
return true; return true;