MCPcopy Create free account
hub / github.com/assaultcube/AC / randomMT

Function randomMT

source/src/crypto.cpp:354–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352}
353
354uint randomMT()
355{
356 int nxt = (mt_next + 1) % MT_N, cur = (nxt + MT_N -1) % MT_N;
357 if(mt_next >= MT_N) seedMT(5489U + time(NULL));
358 mt_next = nxt;
359 uint y = (mt_state[cur] & 0x80000000U) | (mt_state[nxt] & 0x7FFFFFFFU);
360 mt_state[cur] = y = mt_state[cur < MT_N - MT_M ? cur + MT_M : cur + MT_M - MT_N] ^ (y >> 1) ^ (-int(y & 1U) & MT_K);
361 y ^= (y >> 11);
362 y ^= (y << 7) & 0x9D2C5680U;
363 y ^= (y << 15) & 0xEFC60000U;
364 y ^= (y >> 18);
365 return y;
366}
367
368void popMT() // undo last seedMT()
369{

Callers

nothing calls this directly

Calls 1

seedMTFunction · 0.85

Tested by

no test coverage detected