diff --git a/src/Player.php b/src/Player.php index 4809011ee..d58c1dc54 100644 --- a/src/Player.php +++ b/src/Player.php @@ -529,46 +529,26 @@ class Player{ $this->timeout = microtime(true) + 20; switch($pid){ case 0xa0: //NACK - if(isset($this->recovery[$data[2]])){ - $this->directDataPacket($this->recovery[$data[2]]["id"], $this->recovery[$data[2]], $data[2]); - } - if(isset($data[3])){ - if(isset($this->recovery[$data[3]])){ - $this->directDataPacket($this->recovery[$data[3]]["id"], $this->recovery[$data[3]], $data[3]); + foreach($data[0] as $count){ + if(isset($this->recovery[$count])){ + $this->directDataPacket($this->recovery[$count]["id"], $this->recovery[$count], $count); } } break; case 0xc0: //ACK - /*$diff = $data[2] - $this->counter[2]; - if($diff > 8){ //Packet recovery - $this->directDataPacket($this->recovery[$this->counter[2]]["id"], $this->recovery[$this->counter[2]]); - }*/ - if($data[2] > $this->counter[2]){ - $this->counter[2] = $data[2]; - } - $this->recovery[$data[2]] = null; - unset($this->recovery[$data[2]]); - if(isset($data[3])){ - /*$diff = $data[3] - $this->counter[2]; - if($diff > 8){ //Packet recovery - $this->directDataPacket($this->recovery[$this->counter[2]]["id"], $this->recovery[$this->counter[2]]); - }*/ - if($data[3] > $this->counter[2]){ - $this->counter[2] = $data[3]; + foreach($data[0] as $count){ + if($count > $this->counter[2]){ + $this->counter[2] = $count; } - $this->recovery[$data[3]] = null; - unset($this->recovery[$data[3]]); + $this->recovery[$count] = null; + unset($this->recovery[$count]); } - - $cnt = 0; - $limit = microtime(true) - 0.5; //max lag + $limit = microtime(true) - 1; //max lag foreach($this->recovery as $count => $d){ $diff = $this->counter[2] - $count; - if($diff > 16 and $cnt < 16 and $d["sendtime"] < $limit){ + if($diff > 16 and $d["sendtime"] < $limit){ ++$cnt; $this->directDataPacket($d["id"], $d, $count); - }else{ - break; } } break; diff --git a/src/constants/ProtocolInfo.php b/src/constants/ProtocolInfo.php index a0321cb45..83d6fde47 100644 --- a/src/constants/ProtocolInfo.php +++ b/src/constants/ProtocolInfo.php @@ -329,16 +329,10 @@ class Protocol{ 0xa0 => array( - "short", - "bool", - "itriad", "special1", ), 0xc0 => array( - "short", - "bool", - "itriad", "special1", ), diff --git a/src/network/Packet.php b/src/network/Packet.php index 11405e326..5cf82f7c2 100644 --- a/src/network/Packet.php +++ b/src/network/Packet.php @@ -61,8 +61,18 @@ class Packet{ switch($this->pid){ case 0xc0: case 0xa0: - if($this->data[1] === false){ - $this->addRaw(strrev(Utils::writeTriad($this->data[$field]))); + $cnt = 0; + $this->addRaw(Utils::writeShort(floor(count($this->data[$field]) / 2))); + foreach($this->data[$field] as $i => $count){ + if(($cnt % 2) === 0){ + if(count($this->data[$field]) > 1){ + $this->addRaw(Utils::writeBool(false)); + }else{ + $this->addRaw(Utils::writeBool(true)); + } + } + $this->addRaw(strrev(Utils::writeTriad($count))); + unset($this->data[$field][$i]); } break; case 0x05: @@ -173,8 +183,13 @@ class Packet{ switch($this->pid){ case 0xc0: case 0xa0: - if($this->data[1] === false){ - $this->data[] = Utils::readTriad(strrev($this->get(3))); + $cnt = Utils::readShort($this->get(2), false); + $this->data[$field] = array(); + for($i = 0; $i < $cnt; ++$i){ + if(Utils::readBool($this->get(1)) === false){ + $this->data[$field][] = Utils::readTriad(strrev($this->get(3))); + } + $this->data[$field][] = Utils::readTriad(strrev($this->get(3))); } break; case 0x05: