Made some changes for 0.12

This commit is contained in:
Shoghi Cervantes
2015-06-26 13:49:38 -07:00
committed by Shoghi Cervantes
parent 0380e9009a
commit 4258e22c02
18 changed files with 227 additions and 108 deletions

View File

@ -74,6 +74,7 @@ use pocketmine\network\protocol\UpdateBlockPacket;
use pocketmine\network\protocol\UseItemPacket;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\utils\Binary;
use pocketmine\utils\MainLogger;
class Network{
@ -219,14 +220,22 @@ class Network{
$offset = 0;
try{
while($offset < $len){
if(($pk = $this->getPacket(ord($str{$offset++}))) !== null){
$pkLen = Binary::readInt(substr($str, $offset, 4));
$offset += 4;
$buf = substr($str, $offset, $pkLen);
$offset += $pkLen;
if(($pk = $this->getPacket(ord($buf{0}))) !== null){
if($pk::NETWORK_ID === Info::BATCH_PACKET){
throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket");
}
$pk->setBuffer($str, $offset);
$pk->setBuffer($buf, 1);
$pk->decode();
$p->handleDataPacket($pk);
$offset += $pk->getOffset();
if($pk->getOffset() <= 0){
return;
}