diff --git a/OpenRA.FileFormats/Session.cs b/OpenRA.FileFormats/Session.cs index 180848eb97..a661477e0e 100644 --- a/OpenRA.FileFormats/Session.cs +++ b/OpenRA.FileFormats/Session.cs @@ -52,6 +52,7 @@ namespace OpenRA.FileFormats public string[] Packages = {}; // filename:sha1 pairs. public string[] Mods = { "ra" }; // mod names public int OrderLatency = 3; + public int RandomSeed = 0; } } diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 3f4f86588b..1a91310ffa 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -234,6 +234,9 @@ namespace OpenRA LobbyInfo = session; + if (!IsStarted) + world.SharedRandom = new OpenRA.Thirdparty.Random(LobbyInfo.GlobalSettings.RandomSeed); + if (Game.orderManager.Connection.ConnectionState == ConnectionState.Connected) world.SetLocalPlayer(Game.orderManager.Connection.LocalClientId); diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index c9879ff5b9..81e76518d7 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -43,6 +43,7 @@ namespace OpenRA.Server static string Name; static WebClient wc = new WebClient(); static int ExternalPort; + static int randomSeed; const int DownloadChunkInterval = 20000; const int DownloadChunkSize = 16384; @@ -61,9 +62,11 @@ namespace OpenRA.Server initialMods = mods; Name = name; ExternalPort = extport; + randomSeed = (int)DateTime.Now.ToBinary(); lobbyInfo = new Session(); lobbyInfo.GlobalSettings.Mods = mods; + lobbyInfo.GlobalSettings.RandomSeed = randomSeed; Console.WriteLine("Initial mods: "); foreach( var m in lobbyInfo.GlobalSettings.Mods ) @@ -548,6 +551,7 @@ namespace OpenRA.Server inFlightFrames.Clear(); lobbyInfo = new Session(); lobbyInfo.GlobalSettings.Mods = initialMods; + lobbyInfo.GlobalSettings.RandomSeed = randomSeed; GameStarted = false; }