summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/HashRandom.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/HashRandom.cs')
-rw-r--r--Client/Assembly-CSharp/HashRandom.cs36
1 files changed, 36 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/HashRandom.cs b/Client/Assembly-CSharp/HashRandom.cs
new file mode 100644
index 0000000..7d226b1
--- /dev/null
+++ b/Client/Assembly-CSharp/HashRandom.cs
@@ -0,0 +1,36 @@
+using System;
+
+public static class HashRandom
+{
+ private static XXHash src = new XXHash((int)DateTime.UtcNow.Ticks);
+
+ private static int cnt = 0;
+
+ public static uint Next()
+ {
+ return HashRandom.src.GetHash(HashRandom.cnt++);
+ }
+
+ public static int FastNext(int maxInt)
+ {
+ return (int)((ulong)HashRandom.Next() % (ulong)((long)maxInt));
+ }
+
+ public static int Next(int maxInt)
+ {
+ uint num = (uint)(-1 / maxInt);
+ uint num2 = num * (uint)maxInt;
+ uint num3;
+ do
+ {
+ num3 = HashRandom.Next();
+ }
+ while (num3 > num2);
+ return (int)(num3 / num);
+ }
+
+ public static int Next(int minInt, int maxInt)
+ {
+ return HashRandom.Next(maxInt - minInt) + minInt;
+ }
+}