mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Lots of new things...
This commit is contained in:
parent
14e6fcb24e
commit
668994b5a4
9 changed files with 213 additions and 35 deletions
|
|
@ -271,6 +271,27 @@ class Utils{
|
|||
return pack("n", $value);
|
||||
}
|
||||
|
||||
public static function readTriad($str){
|
||||
list(,$unpacked) = unpack("N", "\x00".$str);
|
||||
return (int) $unpacked;
|
||||
}
|
||||
|
||||
public static function writeTriad($value){
|
||||
return substr(pack("N", $value), 1);
|
||||
}
|
||||
|
||||
public static function readDataArray($str, $len = 10){
|
||||
$data = array();
|
||||
$offset = 0;
|
||||
for($i = 1; $i <= $len; ++$i){
|
||||
$l = Utils::readTriad(substr($str, $offset, 3));
|
||||
$offset += 3;
|
||||
$data[] = substr($str, $offset, $l);
|
||||
$offset += $l;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function readInt($str){
|
||||
list(,$unpacked) = unpack("N", $str);
|
||||
return (int) $unpacked;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue