sync SharedRandom
This commit is contained in:
5
OpenRA.FileFormats/Thirdparty/Random.cs
vendored
5
OpenRA.FileFormats/Thirdparty/Random.cs
vendored
@@ -19,6 +19,8 @@ namespace OpenRA.Thirdparty
|
||||
uint[] mt = new uint[624];
|
||||
int index = 0;
|
||||
|
||||
public int Last;
|
||||
|
||||
public Random() : this(Environment.TickCount) { }
|
||||
|
||||
public Random(int seed)
|
||||
@@ -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); }
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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; } }
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user