sync SharedRandom
This commit is contained in:
5
OpenRA.FileFormats/Thirdparty/Random.cs
vendored
5
OpenRA.FileFormats/Thirdparty/Random.cs
vendored
@@ -18,6 +18,8 @@ namespace OpenRA.Thirdparty
|
|||||||
{
|
{
|
||||||
uint[] mt = new uint[624];
|
uint[] mt = new uint[624];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
|
public int Last;
|
||||||
|
|
||||||
public Random() : this(Environment.TickCount) { }
|
public Random() : this(Environment.TickCount) { }
|
||||||
|
|
||||||
@@ -39,7 +41,8 @@ namespace OpenRA.Thirdparty
|
|||||||
y ^= y >> 18;
|
y ^= y >> 18;
|
||||||
|
|
||||||
index = (index + 1) % 624;
|
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); }
|
public int Next(int low, int high) { return low + Next() % (high - low); }
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ namespace OpenRA.Network
|
|||||||
string GenerateSyncReport()
|
string GenerateSyncReport()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("SharedRandom: "+Game.world.SharedRandom.Last);
|
||||||
|
|
||||||
sb.AppendLine("Actors:");
|
sb.AppendLine("Actors:");
|
||||||
foreach (var a in Game.world.Actors)
|
foreach (var a in Game.world.Actors)
|
||||||
sb.AppendLine("\t {0} {1} {2} ({3})".F(
|
sb.AppendLine("\t {0} {1} {2} ({3})".F(
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Traits
|
|||||||
public int Facing { get; set; }
|
public int Facing { get; set; }
|
||||||
[Sync]
|
[Sync]
|
||||||
public int Altitude { get; set; }
|
public int Altitude { get; set; }
|
||||||
[Sync]
|
|
||||||
public int ROT { get { return Info.ROT; } }
|
public int ROT { get { return Info.ROT; } }
|
||||||
public int InitialFacing { get { return Info.InitialFacing; } }
|
public int InitialFacing { get { return Info.InitialFacing; } }
|
||||||
|
|
||||||
|
|||||||
@@ -182,6 +182,9 @@ namespace OpenRA
|
|||||||
foreach (var x in traitDict.ActorsWithTraitMultiple<object>(this))
|
foreach (var x in traitDict.ActorsWithTraitMultiple<object>(this))
|
||||||
ret += n++ * (int)x.Actor.ActorID * Sync.CalculateSyncHash(x.Trait);
|
ret += n++ * (int)x.Actor.ActorID * Sync.CalculateSyncHash(x.Trait);
|
||||||
|
|
||||||
|
// Hash the shared rng
|
||||||
|
ret += SharedRandom.Last;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user