mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Data packet handling!!!
This commit is contained in:
parent
668994b5a4
commit
aae04b8dfd
11 changed files with 184 additions and 54 deletions
|
|
@ -280,7 +280,7 @@ class Utils{
|
|||
return substr(pack("N", $value), 1);
|
||||
}
|
||||
|
||||
public static function readDataArray($str, $len = 10){
|
||||
public static function readDataArray($str, $len = 10, &$offset = null){
|
||||
$data = array();
|
||||
$offset = 0;
|
||||
for($i = 1; $i <= $len; ++$i){
|
||||
|
|
@ -292,6 +292,15 @@ class Utils{
|
|||
return $data;
|
||||
}
|
||||
|
||||
public static function writeDataArray($data){
|
||||
$raw = "";
|
||||
foreach($data as $v){
|
||||
$raw .= Utils::writeTriad(strlen($v));
|
||||
$raw .= $v;
|
||||
}
|
||||
return $raw;
|
||||
}
|
||||
|
||||
public static function readInt($str){
|
||||
list(,$unpacked) = unpack("N", $str);
|
||||
return (int) $unpacked;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue