mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 23:59:53 +00:00
hacky things D:
This commit is contained in:
parent
d6f4e77b6c
commit
1d40399b9c
@ -68,9 +68,17 @@ class Random{
|
||||
* @return int
|
||||
*/
|
||||
public function nextSignedInt(){
|
||||
$this->x ^= ($this->x << 16) & INT32_MASK;
|
||||
$this->x ^= ($this->x >> 5) & INT32_MASK;
|
||||
$this->x ^= ($this->x << 1) & INT32_MASK;
|
||||
if(INT32_MASK === -1){ //32 bit, do hacky things to shift sign
|
||||
$this->x ^= $this->x << 16;
|
||||
$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;
|
||||
$this->x = $this->y;
|
||||
|
Loading…
x
Reference in New Issue
Block a user