mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 08:39:53 +00:00
hacky things D:
This commit is contained in:
parent
d6f4e77b6c
commit
1d40399b9c
@ -68,9 +68,17 @@ class Random{
|
|||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function nextSignedInt(){
|
public function nextSignedInt(){
|
||||||
$this->x ^= ($this->x << 16) & INT32_MASK;
|
if(INT32_MASK === -1){ //32 bit, do hacky things to shift sign
|
||||||
$this->x ^= ($this->x >> 5) & INT32_MASK;
|
$this->x ^= $this->x << 16;
|
||||||
$this->x ^= ($this->x << 1) & INT32_MASK;
|
$hasBit = $this->x < 1;
|
||||||
|
$t = ($hasBit === true ? $this->x ^ ~0x7fffffff : $this->x) >> 5;
|
||||||
|
$this->x ^= ($hasBit === true ? $t ^ ~0x7fffffff : $t);
|
||||||
|
$this->x ^= $this->x << 1;
|
||||||
|
}else{ //64 bit
|
||||||
|
$this->x ^= ($this->x << 16) & INT32_MASK;
|
||||||
|
$this->x ^= $this->x >> 5;
|
||||||
|
$this->x ^= ($this->x << 1) & INT32_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
$t = $this->x;
|
$t = $this->x;
|
||||||
$this->x = $this->y;
|
$this->x = $this->y;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user