mtu size increased, block updates queue sequences are now added into recoveryQueue, small change to how lost packets are calculated, replaced switch cases to create packet with match

This commit is contained in:
GameHerobrine 2025-04-13 06:37:55 +03:00
parent 24269bc359
commit 66bc178238
6 changed files with 73 additions and 180 deletions

View file

@ -95,7 +95,7 @@ class Player{
*/
public function __construct($clientID, $ip, $port, $MTU){
$this->bigCnt = 0;
$this->MTU = min($MTU, 1100);
$this->MTU = min($MTU, 1492);
$this->server = ServerAPI::request();
$this->lastBreak = microtime(true);
$this->clientID = $clientID;
@ -353,14 +353,14 @@ class Player{
if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY){
return;
}
$packet->encode();
$len = strlen($packet->buffer) + 1;
$MTU = $this->MTU - 24;
if($len > $MTU){
return $this->directBigRawPacket($packet);
}
if(($this->bufferLen + $len) >= $MTU){
$this->sendBuffer();
}
@ -1265,6 +1265,8 @@ class Player{
public function sendBlockUpdateQueue(){
if($this->blockUpdateQueueLength > 0 && $this->blockUpdateQueue instanceof RakNetPacket){
$this->blockUpdateQueue->seqNumber = $this->counter[0]++;
$this->recoveryQueue[$this->blockUpdateQueue->seqNumber] = $this->blockUpdateQueue;
$this->blockUpdateQueue->sendtime = microtime(true);
$this->send($this->blockUpdateQueue);
}
$this->blockUpdateQueueLength = 0;
@ -2793,13 +2795,13 @@ class Player{
switch($packet->pid()){
case RakNetInfo::NACK:
foreach($packet->packets as $count){
if(isset($this->recoveryQueue[$count])){
$this->resendQueue[$count] =& $this->recoveryQueue[$count];
$this->lag[] = $time - $this->recoveryQueue[$count]->sendtime;
unset($this->recoveryQueue[$count]);
}else{
++$this->packetStats[1]; //lost and wont be recovered
}
++$this->packetStats[1];
}
break;