summaryrefslogtreecommitdiff
path: root/src/common/mt_rand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/mt_rand.cpp')
-rw-r--r--src/common/mt_rand.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/common/mt_rand.cpp b/src/common/mt_rand.cpp
index 676eca1..91ae2e4 100644
--- a/src/common/mt_rand.cpp
+++ b/src/common/mt_rand.cpp
@@ -61,7 +61,7 @@ static uint32_t state[N+1]; // state vector the +1 is needed due to the coding
static uint32_t *next; // next random value is computed from here
static int left = -1; // can *next++ this many times before reloading
-void mt_seed (uint32_t seed)
+void mt_seed(uint32_t seed)
{
uint32_t x = seed | 1U;
uint32_t *s = state;
@@ -71,11 +71,11 @@ void mt_seed (uint32_t seed)
}
static
-void mt_reload (void)
+void mt_reload(void)
{
// if mt_seed has never been called
if (left < -1)
- mt_seed (time (NULL));
+ mt_seed(time(NULL));
// conceptually, these are indices into the state that wrap
uint32_t *p0 = state;
@@ -87,27 +87,27 @@ void mt_reload (void)
// regenerate the lower N-M elements of the state
for (int j = N-M+1; --j != 0; s0 = s1, s1 = *p2++)
- *p0++ = *pM++ ^ (mixBits (s0, s1) >> 1) ^ (loBit (s1) ? K : 0U);
+ *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
pM = state;
// regenerate the next M-1 elements of the state
// note that s1 is set to state[N] at the end, but discarded
for (int j = M; --j != 0; s0 = s1, s1 = *p2++)
- *p0++ = *pM++ ^ (mixBits (s0, s1) >> 1) ^ (loBit (s1) ? K : 0U);
+ *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
// regenerate the last 1 element of the state
s1 = state[0];
- *p0 = *pM ^ (mixBits (s0, s1) >> 1) ^ (loBit (s1) ? K : 0U);
+ *p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
// ready for the normal mt_random algorithm
left = N;
next = state;
}
-uint32_t mt_random (void)
+uint32_t mt_random(void)
{
if (--left < 0)
- mt_reload ();
+ mt_reload();
uint32_t y = *next++;
y ^= (y >> 11);