1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-18 08:06:33 +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> /// <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 seed ^= (int)(Stopwatch.GetTimestamp());
{ seed ^= (int)(Environment.WorkingSet); // will return 0 on mono
// 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
}
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>