From 410daecab6bb96724a4e31f16a68db64531ee304 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 18 Sep 2010 21:33:12 +1200 Subject: [PATCH] sync SharedRandom --- OpenRA.FileFormats/Thirdparty/Random.cs | 5 ++++- OpenRA.Game/Network/SyncReport.cs | 2 ++ OpenRA.Game/Traits/Mobile.cs | 2 +- OpenRA.Game/World.cs | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/OpenRA.FileFormats/Thirdparty/Random.cs b/OpenRA.FileFormats/Thirdparty/Random.cs index 2321d3babe..152892b6dd 100644 --- a/OpenRA.FileFormats/Thirdparty/Random.cs +++ b/OpenRA.FileFormats/Thirdparty/Random.cs @@ -18,6 +18,8 @@ namespace OpenRA.Thirdparty { uint[] mt = new uint[624]; int index = 0; + + public int Last; public Random() : this(Environment.TickCount) { } @@ -39,7 +41,8 @@ namespace OpenRA.Thirdparty y ^= y >> 18; index = (index + 1) % 624; - return (int)(y % int.MaxValue); + Last = (int)(y % int.MaxValue); + return Last; } public int Next(int low, int high) { return low + Next() % (high - low); } diff --git a/OpenRA.Game/Network/SyncReport.cs b/OpenRA.Game/Network/SyncReport.cs index 2a748831df..efcfad5955 100755 --- a/OpenRA.Game/Network/SyncReport.cs +++ b/OpenRA.Game/Network/SyncReport.cs @@ -23,6 +23,8 @@ namespace OpenRA.Network string GenerateSyncReport() { var sb = new StringBuilder(); + sb.AppendLine("SharedRandom: "+Game.world.SharedRandom.Last); + sb.AppendLine("Actors:"); foreach (var a in Game.world.Actors) sb.AppendLine("\t {0} {1} {2} ({3})".F( diff --git a/OpenRA.Game/Traits/Mobile.cs b/OpenRA.Game/Traits/Mobile.cs index 7bd72d6fcd..622a9a1936 100644 --- a/OpenRA.Game/Traits/Mobile.cs +++ b/OpenRA.Game/Traits/Mobile.cs @@ -61,7 +61,7 @@ namespace OpenRA.Traits public int Facing { get; set; } [Sync] public int Altitude { get; set; } - [Sync] + public int ROT { get { return Info.ROT; } } public int InitialFacing { get { return Info.InitialFacing; } } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index b9afd3a9f5..0af671db81 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -182,6 +182,9 @@ namespace OpenRA foreach (var x in traitDict.ActorsWithTraitMultiple(this)) ret += n++ * (int)x.Actor.ActorID * Sync.CalculateSyncHash(x.Trait); + // Hash the shared rng + ret += SharedRandom.Last; + return ret; } }