Patched... again

This commit is contained in:
Shoghi Cervantes 2014-04-08 15:46:32 +02:00
parent 4c973ce625
commit 29ab53a46f

View File

@ -47,9 +47,9 @@ class Random{
* @param int $seed Integer to be used as seed. * @param int $seed Integer to be used as seed.
*/ */
public function setSeed($seed){ public function setSeed($seed){
$seed = 0xffffffff & crc32($seed); $seed = crc32($seed) % 0x7fffffff;
$this->x = $seed ^ 0x0badc0de; $this->x = $seed ^ 0x0badc0de;
$this->z = $seed ^ 0xdeadbeef; $this->z = $seed ^ -123456789;
$this->y = $seed ^ 0x12345678; $this->y = $seed ^ 0x12345678;
} }
@ -59,7 +59,7 @@ class Random{
* @return int * @return int
*/ */
public function nextInt(){ public function nextInt(){
return $this->nextSignedInt() & 0x7FFFFFFF; return $this->nextSignedInt() & 0x7fffffff;
} }
/** /**
@ -68,9 +68,9 @@ class Random{
* @return int * @return int
*/ */
public function nextSignedInt(){ public function nextSignedInt(){
$this->x ^= ($this->x << 16); $this->x ^= ($this->x << 16) & 0xffffffff;
$this->x ^= ($this->x >> 5); $this->x ^= ($this->x >> 5) & 0xffffffff;
$this->x ^= ($this->x << 1); $this->x ^= ($this->x << 1) & 0xffffffff;
$t = $this->x; $t = $this->x;
$this->x = $this->y; $this->x = $this->y;