mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
New ACK/NACK structure & Packet multiple ressend issue
This commit is contained in:
parent
c68b4ebda6
commit
f1a28f23ae
@ -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;
|
||||
|
@ -329,16 +329,10 @@ class Protocol{
|
||||
|
||||
|
||||
0xa0 => array(
|
||||
"short",
|
||||
"bool",
|
||||
"itriad",
|
||||
"special1",
|
||||
),
|
||||
|
||||
0xc0 => array(
|
||||
"short",
|
||||
"bool",
|
||||
"itriad",
|
||||
"special1",
|
||||
),
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user