mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 14:05:35 +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;
|
$this->timeout = microtime(true) + 20;
|
||||||
switch($pid){
|
switch($pid){
|
||||||
case 0xa0: //NACK
|
case 0xa0: //NACK
|
||||||
if(isset($this->recovery[$data[2]])){
|
foreach($data[0] as $count){
|
||||||
$this->directDataPacket($this->recovery[$data[2]]["id"], $this->recovery[$data[2]], $data[2]);
|
if(isset($this->recovery[$count])){
|
||||||
}
|
$this->directDataPacket($this->recovery[$count]["id"], $this->recovery[$count], $count);
|
||||||
if(isset($data[3])){
|
|
||||||
if(isset($this->recovery[$data[3]])){
|
|
||||||
$this->directDataPacket($this->recovery[$data[3]]["id"], $this->recovery[$data[3]], $data[3]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0xc0: //ACK
|
case 0xc0: //ACK
|
||||||
/*$diff = $data[2] - $this->counter[2];
|
foreach($data[0] as $count){
|
||||||
if($diff > 8){ //Packet recovery
|
if($count > $this->counter[2]){
|
||||||
$this->directDataPacket($this->recovery[$this->counter[2]]["id"], $this->recovery[$this->counter[2]]);
|
$this->counter[2] = $count;
|
||||||
}*/
|
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
$this->recovery[$data[3]] = null;
|
$this->recovery[$count] = null;
|
||||||
unset($this->recovery[$data[3]]);
|
unset($this->recovery[$count]);
|
||||||
}
|
}
|
||||||
|
$limit = microtime(true) - 1; //max lag
|
||||||
$cnt = 0;
|
|
||||||
$limit = microtime(true) - 0.5; //max lag
|
|
||||||
foreach($this->recovery as $count => $d){
|
foreach($this->recovery as $count => $d){
|
||||||
$diff = $this->counter[2] - $count;
|
$diff = $this->counter[2] - $count;
|
||||||
if($diff > 16 and $cnt < 16 and $d["sendtime"] < $limit){
|
if($diff > 16 and $d["sendtime"] < $limit){
|
||||||
++$cnt;
|
++$cnt;
|
||||||
$this->directDataPacket($d["id"], $d, $count);
|
$this->directDataPacket($d["id"], $d, $count);
|
||||||
}else{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -329,16 +329,10 @@ class Protocol{
|
|||||||
|
|
||||||
|
|
||||||
0xa0 => array(
|
0xa0 => array(
|
||||||
"short",
|
|
||||||
"bool",
|
|
||||||
"itriad",
|
|
||||||
"special1",
|
"special1",
|
||||||
),
|
),
|
||||||
|
|
||||||
0xc0 => array(
|
0xc0 => array(
|
||||||
"short",
|
|
||||||
"bool",
|
|
||||||
"itriad",
|
|
||||||
"special1",
|
"special1",
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -61,8 +61,18 @@ class Packet{
|
|||||||
switch($this->pid){
|
switch($this->pid){
|
||||||
case 0xc0:
|
case 0xc0:
|
||||||
case 0xa0:
|
case 0xa0:
|
||||||
if($this->data[1] === false){
|
$cnt = 0;
|
||||||
$this->addRaw(strrev(Utils::writeTriad($this->data[$field])));
|
$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;
|
break;
|
||||||
case 0x05:
|
case 0x05:
|
||||||
@ -173,8 +183,13 @@ class Packet{
|
|||||||
switch($this->pid){
|
switch($this->pid){
|
||||||
case 0xc0:
|
case 0xc0:
|
||||||
case 0xa0:
|
case 0xa0:
|
||||||
if($this->data[1] === false){
|
$cnt = Utils::readShort($this->get(2), false);
|
||||||
$this->data[] = Utils::readTriad(strrev($this->get(3)));
|
$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;
|
break;
|
||||||
case 0x05:
|
case 0x05:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user