sync SharedRandom

This commit is contained in:
Paul Chote
2010-09-18 21:33:12 +12:00
parent 966e3bb71a
commit 410daecab6
4 changed files with 10 additions and 2 deletions

View File

@@ -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); }

View File

@@ -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(

View File

@@ -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; } }

View File

@@ -182,6 +182,9 @@ namespace OpenRA
foreach (var x in traitDict.ActorsWithTraitMultiple<object>(this))
ret += n++ * (int)x.Actor.ActorID * Sync.CalculateSyncHash(x.Trait);
// Hash the shared rng
ret += SharedRandom.Last;
return ret;
}
}