1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-15 14:46:29 +09:00

CommandLine removed from NetRandom seed generation

This commit is contained in:
lidgren
2010-07-04 09:42:57 +00:00
parent deb1a3b00e
commit adc06a1ae1

View File

@@ -60,22 +60,13 @@ namespace Lidgren.Network
/// <summary>
/// Returns a random seed based on time and working set
/// </summary>
public static int GetRandomSeed()
public static int GetRandomSeed(object forObject)
{
// mix some semi-random properties
int seed = (int)Environment.TickCount;
try
{
// tickcount + gettimestamp + workingset should be random enough
if (!string.IsNullOrEmpty(Environment.CommandLine))
seed ^= Environment.CommandLine.GetHashCode();
seed ^= (int)(Stopwatch.GetTimestamp());
seed ^= (int)(Environment.WorkingSet); // will return 0 on mono
}
catch
{
// maybe commandline etc is not available, TickCount will have to do
}
seed ^= forObject.GetHashCode();
seed ^= (int)(Stopwatch.GetTimestamp());
seed ^= (int)(Environment.WorkingSet); // will return 0 on mono
int extraSeed = Interlocked.Increment(ref m_extraSeed);
@@ -88,7 +79,7 @@ namespace Lidgren.Network
public NetRandom()
{
// Initialise using the system tick count
Reinitialise(GetRandomSeed());
Reinitialise(GetRandomSeed(this));
}
/// <summary>