summaryrefslogtreecommitdiffhomepage
path: root/Opcode/OpcodeLib/Ice/IceRandom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Opcode/OpcodeLib/Ice/IceRandom.cpp')
-rw-r--r--Opcode/OpcodeLib/Ice/IceRandom.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/Opcode/OpcodeLib/Ice/IceRandom.cpp b/Opcode/OpcodeLib/Ice/IceRandom.cpp
new file mode 100644
index 0000000..0139be6
--- /dev/null
+++ b/Opcode/OpcodeLib/Ice/IceRandom.cpp
@@ -0,0 +1,35 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Contains code for random generators.
+ * \file IceRandom.cpp
+ * \author Pierre Terdiman
+ * \date August, 9, 2001
+ */
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Precompiled Header
+#include "Stdafx.h"
+
+using namespace IceCore;
+
+void IceCore:: SRand(udword seed)
+{
+ srand(seed);
+}
+
+udword IceCore::Rand()
+{
+ return rand();
+}
+
+
+static BasicRandom gRandomGenerator(42);
+
+udword IceCore::GetRandomIndex(udword max_index)
+{
+ // We don't use rand() since it's limited to RAND_MAX
+ udword Index = gRandomGenerator.Randomize();
+ return Index % max_index;
+}
+