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 string masterServerUrl;
static bool isInitialPing;
static ModData ModData;
static Map Map;
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");
@@ -56,18 +58,23 @@ namespace OpenRA.Server
Name = name;
ExternalPort = extport;
randomSeed = (int)DateTime.Now.ToBinary();
ModData = modData;
lobbyInfo = new Session();
lobbyInfo.GlobalSettings.Mods = mods;
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
lobbyInfo.GlobalSettings.Map = map;
lobbyInfo.GlobalSettings.AllowCheats = cheats;
LoadMap(); // populates the Session's slots, too.
Log.Write("server", "Initial mods: ");
foreach( var m in lobbyInfo.GlobalSettings.Mods )
Log.Write("server","- {0}", m);
Log.Write("server", "Initial map: {0}",lobbyInfo.GlobalSettings.Map);
try
{
@@ -109,6 +116,11 @@ namespace OpenRA.Server
} ) { IsBackground = true }.Start();
}
static void LoadMap()
{
Map = new Map(ModData.AvailableMaps[lobbyInfo.GlobalSettings.Map].Package);
}
static int ChooseFreePlayerIndex()
{
for (var i = 0; i < 8; i++)
@@ -337,7 +349,9 @@ namespace OpenRA.Server
SendChatTo( conn, "Only the host can change the map" );
return true;
}
lobbyInfo.GlobalSettings.Map = s;
lobbyInfo.GlobalSettings.Map = s;
LoadMap();
foreach(var client in lobbyInfo.Clients)
{
client.SpawnPoint = 0;