server picks random seed for world.SharedRandom

This commit is contained in:
Chris Forbes
2010-03-19 20:52:03 +13:00
parent 4dac5c0755
commit 47822a9612
3 changed files with 8 additions and 0 deletions

View File

@@ -52,6 +52,7 @@ namespace OpenRA.FileFormats
public string[] Packages = {}; // filename:sha1 pairs. public string[] Packages = {}; // filename:sha1 pairs.
public string[] Mods = { "ra" }; // mod names public string[] Mods = { "ra" }; // mod names
public int OrderLatency = 3; public int OrderLatency = 3;
public int RandomSeed = 0;
} }
} }

View File

@@ -234,6 +234,9 @@ namespace OpenRA
LobbyInfo = session; LobbyInfo = session;
if (!IsStarted)
world.SharedRandom = new OpenRA.Thirdparty.Random(LobbyInfo.GlobalSettings.RandomSeed);
if (Game.orderManager.Connection.ConnectionState == ConnectionState.Connected) if (Game.orderManager.Connection.ConnectionState == ConnectionState.Connected)
world.SetLocalPlayer(Game.orderManager.Connection.LocalClientId); world.SetLocalPlayer(Game.orderManager.Connection.LocalClientId);

View File

@@ -43,6 +43,7 @@ namespace OpenRA.Server
static string Name; static string Name;
static WebClient wc = new WebClient(); static WebClient wc = new WebClient();
static int ExternalPort; static int ExternalPort;
static int randomSeed;
const int DownloadChunkInterval = 20000; const int DownloadChunkInterval = 20000;
const int DownloadChunkSize = 16384; const int DownloadChunkSize = 16384;
@@ -61,9 +62,11 @@ namespace OpenRA.Server
initialMods = mods; initialMods = mods;
Name = name; Name = name;
ExternalPort = extport; ExternalPort = extport;
randomSeed = (int)DateTime.Now.ToBinary();
lobbyInfo = new Session(); lobbyInfo = new Session();
lobbyInfo.GlobalSettings.Mods = mods; lobbyInfo.GlobalSettings.Mods = mods;
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
Console.WriteLine("Initial mods: "); Console.WriteLine("Initial mods: ");
foreach( var m in lobbyInfo.GlobalSettings.Mods ) foreach( var m in lobbyInfo.GlobalSettings.Mods )
@@ -548,6 +551,7 @@ namespace OpenRA.Server
inFlightFrames.Clear(); inFlightFrames.Clear();
lobbyInfo = new Session(); lobbyInfo = new Session();
lobbyInfo.GlobalSettings.Mods = initialMods; lobbyInfo.GlobalSettings.Mods = initialMods;
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
GameStarted = false; GameStarted = false;
} }