mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
faster packet decode using pure-PHP functions instead of core-PHP ones :P. WTF PHP
This commit is contained in:
parent
9c38ead76d
commit
b00da18f41
@ -108,6 +108,7 @@ foreach($inc as $s){
|
||||
$sha1sum ^= sha1_file($s, true);
|
||||
}
|
||||
/***REM_END***/
|
||||
ini_set("opcache.mmap_base", bin2hex(Utils::getRandomBytes(8, false))); //Fix OPCache address errors
|
||||
define("SOURCE_SHA1SUM", bin2hex($sha1sum));
|
||||
|
||||
/***REM_START***/
|
||||
|
@ -56,12 +56,15 @@ abstract class RakNetDataPacket extends stdClass{
|
||||
if($len <= 0){
|
||||
$this->offset = strlen($this->buffer) - 1;
|
||||
return "";
|
||||
}
|
||||
if($len === true){
|
||||
}elseif($len === true){
|
||||
return substr($this->buffer, $this->offset);
|
||||
}
|
||||
$this->offset += $len;
|
||||
return substr($this->buffer, $this->offset - $len, $len);
|
||||
|
||||
$buffer = b"";
|
||||
for(; $len > 0; --$len, ++$this->offset){
|
||||
$buffer .= $this->buffer{$this->offset};
|
||||
}
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
protected function put($str){
|
||||
@ -118,7 +121,7 @@ abstract class RakNetDataPacket extends stdClass{
|
||||
}
|
||||
|
||||
protected function getByte(){
|
||||
return ord($this->get(1));
|
||||
return ord($this->buffer{$this->offset++});
|
||||
}
|
||||
|
||||
protected function putByte($v){
|
||||
|
@ -31,17 +31,20 @@ class RakNetPacket extends Packet{
|
||||
public function pid(){
|
||||
return $this->packetID;
|
||||
}
|
||||
|
||||
private function get($len){
|
||||
|
||||
protected function get($len){
|
||||
if($len <= 0){
|
||||
$this->offset = strlen($this->buffer) - 1;
|
||||
return "";
|
||||
}
|
||||
if($len === true){
|
||||
}elseif($len === true){
|
||||
return substr($this->buffer, $this->offset);
|
||||
}
|
||||
$this->offset += $len;
|
||||
return substr($this->buffer, $this->offset - $len, $len);
|
||||
|
||||
$buffer = b"";
|
||||
for(; $len > 0; --$len, ++$this->offset){
|
||||
$buffer .= $this->buffer{$this->offset};
|
||||
}
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
private function getLong($unsigned = false){
|
||||
@ -61,7 +64,7 @@ class RakNetPacket extends Packet{
|
||||
}
|
||||
|
||||
private function getByte(){
|
||||
return ord($this->get(1));
|
||||
return ord($this->buffer{$this->offset++});
|
||||
}
|
||||
|
||||
private function feof(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user