Made the state variable local

This commit is contained in:
arookas 2016-02-01 03:27:16 -05:00
parent 723b8b64c9
commit 4999467b29

View file

@ -5,14 +5,14 @@
* 2016 arookas
\* ================================================= */
var __RAND_NEXT;
var local next;
function srand(seed) {
__RAND_NEXT = seed;
next = seed;
}
function rand() {
// this is exactly the formula used in MSL (and, thus, SMS itself)
__RAND_NEXT = (__RAND_NEXT * 1103515245) + 12345;
return (__RAND_NEXT >> 16) & 0x7FFF;
next = (next * 1103515245) + 12345;
return (next >> 16) & 0x7FFF;
}