mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +00:00
Fixed #204 Packet recovery algorithm can recover unsent chunks [gh#204]
This commit is contained in:
parent
929aebc1bf
commit
03062c4e54
@ -140,6 +140,7 @@ class Player{
|
|||||||
if($this->connected === false){
|
if($this->connected === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$c = key($this->chunksOrder);
|
$c = key($this->chunksOrder);
|
||||||
$d = @$this->chunksOrder[$c];
|
$d = @$this->chunksOrder[$c];
|
||||||
if($c === null or $d > $this->server->api->getProperty("view-distance")){
|
if($c === null or $d > $this->server->api->getProperty("view-distance")){
|
||||||
@ -178,6 +179,7 @@ class Player{
|
|||||||
$this->server->api->tileentity->spawnTo($tile["ID"], $this);
|
$this->server->api->tileentity->spawnTo($tile["ID"], $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($repeat === false){
|
if($repeat === false){
|
||||||
$this->getNextChunk(true);
|
$this->getNextChunk(true);
|
||||||
}
|
}
|
||||||
@ -699,7 +701,7 @@ class Player{
|
|||||||
case 0xa0: //NACK
|
case 0xa0: //NACK
|
||||||
foreach($data[0] as $count){
|
foreach($data[0] as $count){
|
||||||
if(isset($this->recovery[$count])){
|
if(isset($this->recovery[$count])){
|
||||||
$this->directDataPacket($this->recovery[$count]["id"], $this->recovery[$count], $count);
|
$this->directDataPacket($this->recovery[$count]["id"], $this->recovery[$count], $count, $this->recovery[$count]["pid"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -715,7 +717,7 @@ class Player{
|
|||||||
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 $d["sendtime"] < $limit){
|
if($diff > 16 and $d["sendtime"] < $limit){
|
||||||
$this->directDataPacket($d["id"], $d, $count);
|
$this->directDataPacket($d["id"], $d, $count, $d["pid"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1360,6 +1362,7 @@ class Player{
|
|||||||
}
|
}
|
||||||
$data = array(
|
$data = array(
|
||||||
"id" => false,
|
"id" => false,
|
||||||
|
"pid" => 0x10,
|
||||||
"sendtime" => microtime(true),
|
"sendtime" => microtime(true),
|
||||||
"raw" => "",
|
"raw" => "",
|
||||||
);
|
);
|
||||||
@ -1386,11 +1389,12 @@ class Player{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function directDataPacket($id, $data = array(), $count = false){
|
public function directDataPacket($id, $data = array(), $count = false, $pid = 0x00){
|
||||||
if($this->connected === false){
|
if($this->connected === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$data["id"] = $id;
|
$data["id"] = $id;
|
||||||
|
$data["pid"] = $pid;
|
||||||
$data["sendtime"] = microtime(true);
|
$data["sendtime"] = microtime(true);
|
||||||
if($count === false){
|
if($count === false){
|
||||||
$count = $this->counter[0]++;
|
$count = $this->counter[0]++;
|
||||||
@ -1401,11 +1405,11 @@ class Player{
|
|||||||
unset($this->recovery[$k]);
|
unset($this->recovery[$k]);
|
||||||
end($this->recovery);
|
end($this->recovery);
|
||||||
}
|
}
|
||||||
|
$this->recovery[$count] = $data;
|
||||||
}
|
}
|
||||||
$this->recovery[$count] = $data;
|
|
||||||
$this->send(0x80, array(
|
$this->send(0x80, array(
|
||||||
$count,
|
$count,
|
||||||
0x00,
|
$pid,
|
||||||
$data,
|
$data,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user