mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-09 11:31:49 +00:00
Fixed signed VarInt encoding on 64-bit systems
Numbers represented as hex or binary with the 32nd bit set, for example 0xffffffff, were not considered as signed on 64-bit.
This commit is contained in:
parent
94d78ca554
commit
f8c2eb8c3a
@ -381,7 +381,10 @@ class Binary{
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function writeVarInt($v){
|
public static function writeVarInt($v){
|
||||||
return self::writeUnsignedVarInt(($v << 1) ^ ($v >> (PHP_INT_SIZE === 8 ? 63 : 31)));
|
if(PHP_INT_SIZE === 8){
|
||||||
|
$v = ($v << 32 >> 32);
|
||||||
|
}
|
||||||
|
return self::writeUnsignedVarInt(($v << 1) ^ ($v >> 31));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user