mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 23:59:53 +00:00
parent
55216ae65b
commit
a5efe15030
@ -121,7 +121,7 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function readTriad($str){
|
public static function readTriad($str){
|
||||||
list(,$unpacked) = unpack("N", "\x00".$str);
|
list(,$unpacked) = @unpack("N", "\x00".$str);
|
||||||
return $unpacked;
|
return $unpacked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,7 +457,7 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function readShort($str, $signed = true){
|
public static function readShort($str, $signed = true){
|
||||||
list(,$unpacked) = unpack("n", $str);
|
list(,$unpacked) = @unpack("n", $str);
|
||||||
if($unpacked > 0x7fff and $signed === true){
|
if($unpacked > 0x7fff and $signed === true){
|
||||||
$unpacked -= 0x10000; // Convert unsigned short to signed short
|
$unpacked -= 0x10000; // Convert unsigned short to signed short
|
||||||
}
|
}
|
||||||
@ -472,7 +472,7 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function readLShort($str, $signed = true){
|
public static function readLShort($str, $signed = true){
|
||||||
list(,$unpacked) = unpack("v", $str);
|
list(,$unpacked) = @unpack("v", $str);
|
||||||
if($unpacked > 0x7fff and $signed === true){
|
if($unpacked > 0x7fff and $signed === true){
|
||||||
$unpacked -= 0x10000; // Convert unsigned short to signed short
|
$unpacked -= 0x10000; // Convert unsigned short to signed short
|
||||||
}
|
}
|
||||||
@ -487,7 +487,7 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function readInt($str){
|
public static function readInt($str){
|
||||||
list(,$unpacked) = unpack("N", $str);
|
list(,$unpacked) = @unpack("N", $str);
|
||||||
if($unpacked >= 2147483648){
|
if($unpacked >= 2147483648){
|
||||||
$unpacked -= 4294967296;
|
$unpacked -= 4294967296;
|
||||||
}
|
}
|
||||||
@ -502,7 +502,7 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function readLInt($str){
|
public static function readLInt($str){
|
||||||
list(,$unpacked) = unpack("V", $str);
|
list(,$unpacked) = @unpack("V", $str);
|
||||||
if($unpacked >= 2147483648){
|
if($unpacked >= 2147483648){
|
||||||
$unpacked -= 4294967296;
|
$unpacked -= 4294967296;
|
||||||
}
|
}
|
||||||
@ -517,7 +517,7 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function readFloat($str){
|
public static function readFloat($str){
|
||||||
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("f", $str):unpack("f", strrev($str));
|
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("f", $str):@unpack("f", strrev($str));
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,7 +526,7 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function readLFloat($str){
|
public static function readLFloat($str){
|
||||||
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("f", strrev($str)):unpack("f", $str);
|
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("f", strrev($str)):@unpack("f", $str);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +539,7 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function readDouble($str){
|
public static function readDouble($str){
|
||||||
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("d", $str):unpack("d", strrev($str));
|
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("d", $str):@unpack("d", strrev($str));
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,7 +548,7 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function readLDouble($str){
|
public static function readLDouble($str){
|
||||||
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("d", strrev($str)):unpack("d", $str);
|
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("d", strrev($str)):@unpack("d", $str);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user