Remove remnants of needACK functionality

this has been broken for a long time and hasn't been used for even longer.
This commit is contained in:
Dylan K. Taylor 2018-07-20 13:07:06 +01:00
parent 0fecb79add
commit 3cd105ff33
4 changed files with 13 additions and 29 deletions

View File

@ -1902,7 +1902,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$pk = new PlayStatusPacket();
$pk->status = $status;
$pk->protocol = $this->protocol;
$this->sendDataPacket($pk, false, $immediate);
$this->sendDataPacket($pk, $immediate);
}
public function onVerifyCompleted(LoginPacket $packet, ?string $error, bool $signedByMojang) : void{
@ -2997,12 +2997,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
/**
* @param DataPacket $packet
* @param bool $needACK
* @param bool $immediate
*
* @return bool|int
* @return bool
*/
public function sendDataPacket(DataPacket $packet, bool $needACK = false, bool $immediate = false){
public function sendDataPacket(DataPacket $packet, bool $immediate = false) : bool{
if(!$this->isConnected()){
return false;
}
@ -3017,22 +3016,20 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
/**
* @param DataPacket $packet
* @param bool $needACK
*
* @return bool|int
* @return bool
*/
public function dataPacket(DataPacket $packet, bool $needACK = false){
return $this->sendDataPacket($packet, $needACK, false);
public function dataPacket(DataPacket $packet) : bool{
return $this->sendDataPacket($packet, false);
}
/**
* @param DataPacket $packet
* @param bool $needACK
*
* @return bool|int
* @return bool
*/
public function directDataPacket(DataPacket $packet, bool $needACK = false){
return $this->sendDataPacket($packet, $needACK, true);
public function directDataPacket(DataPacket $packet) : bool{
return $this->sendDataPacket($packet, true);
}
/**

View File

@ -1893,7 +1893,7 @@ class Server{
*/
public function broadcastPacketsCallback(string $payload, array $players, bool $immediate = false){
foreach($players as $i){
$i->getNetworkSession()->getInterface()->putPacket($i, $payload, false, $immediate);
$i->getNetworkSession()->getInterface()->putPacket($i, $payload, $immediate);
}
}

View File

@ -43,12 +43,9 @@ interface NetworkInterface{
*
* @param Player $player
* @param string $payload
* @param bool $needACK
* @param bool $immediate
*
* @return int|null
*/
public function putPacket(Player $player, string $payload, bool $needACK = false, bool $immediate = true) : ?int;
public function putPacket(Player $player, string $payload, bool $immediate = true) : void;
/**
* Terminates the connection

View File

@ -62,9 +62,6 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
/** @var string[] */
private $identifiers = [];
/** @var int[] */
private $identifiersACK = [];
/** @var ServerHandler */
private $interface;
@ -111,7 +108,6 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
$player = $this->players[$identifier];
unset($this->identifiers[spl_object_hash($player)]);
unset($this->players[$identifier]);
unset($this->identifiersACK[$identifier]);
$player->close($player->getLeaveMessage(), $reason);
}
}
@ -119,7 +115,6 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
public function close(Player $player, string $reason = "unknown reason") : void{
if(isset($this->identifiers[$h = spl_object_hash($player)])){
unset($this->players[$this->identifiers[$h]]);
unset($this->identifiersACK[$this->identifiers[$h]]);
$this->interface->closeSession($this->identifiers[$h], $reason);
unset($this->identifiers[$h]);
}
@ -142,7 +137,6 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
$player = new $class($this, $ev->getAddress(), $ev->getPort());
$this->players[$identifier] = $player;
$this->identifiersACK[$identifier] = 0;
$this->identifiers[spl_object_hash($player)] = $identifier;
$this->server->addPlayer($player);
}
@ -214,21 +208,17 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
}
}
public function putPacket(Player $player, string $payload, bool $needACK = false, bool $immediate = true) : ?int{
public function putPacket(Player $player, string $payload, bool $immediate = true) : void{
if(isset($this->identifiers[$h = spl_object_hash($player)])){
$identifier = $this->identifiers[$h];
$pk = new EncapsulatedPacket();
$pk->identifierACK = $this->identifiersACK[$identifier]++;
$pk->buffer = self::MCPE_RAKNET_PACKET_ID . $payload;
$pk->reliability = PacketReliability::RELIABLE_ORDERED;
$pk->orderChannel = 0;
$this->interface->sendEncapsulated($identifier, $pk, ($needACK ? RakLib::FLAG_NEED_ACK : 0) | ($immediate ? RakLib::PRIORITY_IMMEDIATE : RakLib::PRIORITY_NORMAL));
return $pk->identifierACK;
$this->interface->sendEncapsulated($identifier, $pk, ($immediate ? RakLib::PRIORITY_IMMEDIATE : RakLib::PRIORITY_NORMAL));
}
return null;
}
public function updatePing(string $identifier, int $pingMS) : void{