Initial spawn on 0.16

This commit is contained in:
Dylan K. Taylor
2016-10-04 12:29:26 +01:00
parent bb9ab525b6
commit dd0c5efb56
10 changed files with 239 additions and 117 deletions

View File

@ -81,6 +81,7 @@ use pocketmine\network\protocol\UseItemPacket;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\utils\Binary;
use pocketmine\utils\BinaryStream;
class Network{
@ -209,17 +210,19 @@ class Network{
public function processBatch(BatchPacket $packet, Player $p){
$str = zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB
$len = strlen($str);
$offset = 0;
try{
while($offset < $len){
$pkLen = Binary::readInt(substr($str, $offset, 4));
$offset += 4;
$len = strlen($str);
$buf = substr($str, $offset, $pkLen);
$offset += $pkLen;
if($len === 0){
throw new \InvalidStateException("Empty or invalid BatchPacket received");
}
if(($pk = $this->getPacket(ord($buf{0}))) !== null){ // #blameshoghi
$stream = new BinaryStream($str);
while($stream->offset < $len){
$buf = $stream->getString();
if(($pk = $this->getPacket(ord($buf{0}))) !== null){
if($pk::NETWORK_ID === Info::BATCH_PACKET){
throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket");
}
@ -228,10 +231,6 @@ class Network{
$pk->decode();
$p->handleDataPacket($pk);
if($pk->getOffset() <= 0){
return;
}
}
}
}catch(\Throwable $e){