You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-19 00:26:30 +09:00
CommandLine removed from NetRandom seed generation
This commit is contained in:
@@ -60,22 +60,13 @@ namespace Lidgren.Network
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a random seed based on time and working set
|
/// Returns a random seed based on time and working set
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int GetRandomSeed()
|
public static int GetRandomSeed(object forObject)
|
||||||
{
|
{
|
||||||
|
// mix some semi-random properties
|
||||||
int seed = (int)Environment.TickCount;
|
int seed = (int)Environment.TickCount;
|
||||||
|
seed ^= forObject.GetHashCode();
|
||||||
try
|
|
||||||
{
|
|
||||||
// tickcount + gettimestamp + workingset should be random enough
|
|
||||||
if (!string.IsNullOrEmpty(Environment.CommandLine))
|
|
||||||
seed ^= Environment.CommandLine.GetHashCode();
|
|
||||||
seed ^= (int)(Stopwatch.GetTimestamp());
|
seed ^= (int)(Stopwatch.GetTimestamp());
|
||||||
seed ^= (int)(Environment.WorkingSet); // will return 0 on mono
|
seed ^= (int)(Environment.WorkingSet); // will return 0 on mono
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// maybe commandline etc is not available, TickCount will have to do
|
|
||||||
}
|
|
||||||
|
|
||||||
int extraSeed = Interlocked.Increment(ref m_extraSeed);
|
int extraSeed = Interlocked.Increment(ref m_extraSeed);
|
||||||
|
|
||||||
@@ -88,7 +79,7 @@ namespace Lidgren.Network
|
|||||||
public NetRandom()
|
public NetRandom()
|
||||||
{
|
{
|
||||||
// Initialise using the system tick count
|
// Initialise using the system tick count
|
||||||
Reinitialise(GetRandomSeed());
|
Reinitialise(GetRandomSeed(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user