From 16972bf9a5121fc73dbe5e533aef54f25edb6fd0 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 31 Mar 2017 18:59:40 +0100 Subject: [PATCH] Fix issues with writing negative numbers as non-zigzag varints, close #493 --- src/pocketmine/utils/Binary.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pocketmine/utils/Binary.php b/src/pocketmine/utils/Binary.php index e2ab3737d..60099b7c4 100644 --- a/src/pocketmine/utils/Binary.php +++ b/src/pocketmine/utils/Binary.php @@ -395,6 +395,7 @@ class Binary{ */ public static function writeUnsignedVarInt($value){ $buf = ""; + $value &= 0xffffffff; for($i = 0; $i < 5; ++$i){ if(($value >> 7) !== 0){ $buf .= chr($value | 0x80); //Let chr() take the last byte of this, it's faster than adding another & 0x7f.