mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 02:38:54 +00:00
Another patch, added INT32_MASK
This commit is contained in:
parent
cb32a95e60
commit
d6f4e77b6c
@ -360,6 +360,7 @@ namespace pocketmine {
|
||||
}
|
||||
|
||||
@define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN));
|
||||
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
|
||||
@ini_set("opcache.mmap_base", bin2hex(Utils::getRandomBytes(8, false))); //Fix OPCache address errors
|
||||
|
||||
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
|
||||
|
@ -48,9 +48,9 @@ class Random{
|
||||
*/
|
||||
public function setSeed($seed){
|
||||
$seed = crc32($seed);
|
||||
$this->x = ($seed ^ 9876543210) % 0x7fffffff;
|
||||
$this->z = ($seed ^ -123456789) % 0x7fffffff;
|
||||
$this->y = ($seed ^ 1122334455) % 0x7fffffff;
|
||||
$this->x = ($seed ^ 1076543210) & INT32_MASK;
|
||||
$this->z = ($seed ^ 0xdeadc0de) & INT32_MASK;
|
||||
$this->y = ($seed ^ 1122334455) & INT32_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,9 +68,9 @@ class Random{
|
||||
* @return int
|
||||
*/
|
||||
public function nextSignedInt(){
|
||||
$this->x ^= ($this->x << 16) & 0xffffffff;
|
||||
$this->x ^= ($this->x >> 5) & 0xffffffff;
|
||||
$this->x ^= ($this->x << 1) & 0xffffffff;
|
||||
$this->x ^= ($this->x << 16) & INT32_MASK;
|
||||
$this->x ^= ($this->x >> 5) & INT32_MASK;
|
||||
$this->x ^= ($this->x << 1) & INT32_MASK;
|
||||
|
||||
$t = $this->x;
|
||||
$this->x = $this->y;
|
||||
@ -82,7 +82,7 @@ class Random{
|
||||
if($t > 2147483647){
|
||||
$t -= 4294967296;
|
||||
}
|
||||
return (int) $t % 0x7fffffff;
|
||||
return (int) $t;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user