mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Improved RakNet encapsulated packet encoding
This commit is contained in:
parent
7b17bf416e
commit
4fd5e9ba7d
@ -1636,7 +1636,7 @@ class Server{
|
||||
$this->maxPlayers = $this->getConfigInt("max-players", 20);
|
||||
$this->setAutoSave($this->getConfigBoolean("auto-save", true));
|
||||
|
||||
if($this->getConfigString("memory-limit", -1) !== false){
|
||||
if($this->getConfigString("memory-limit", false) !== false){
|
||||
$this->logger->notice("The memory-limit setting has been deprecated.");
|
||||
$this->logger->notice("There are new memory settings on pocketmine.yml to tune memory and events.");
|
||||
$this->logger->notice("You can also reduce the amount of threads and chunks loaded control the memory usage.");
|
||||
|
@ -48,7 +48,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
/** @var Player[] */
|
||||
private $players = [];
|
||||
|
||||
/** @var \SplObjectStorage */
|
||||
/** @var string[] */
|
||||
private $identifiers;
|
||||
|
||||
/** @var int[] */
|
||||
@ -60,7 +60,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
public function __construct(Server $server){
|
||||
|
||||
$this->server = $server;
|
||||
$this->identifiers = new \SplObjectStorage();
|
||||
$this->identifiers = [];
|
||||
|
||||
$this->rakLib = new RakLibServer($this->server->getLogger(), $this->server->getLoader(), $this->server->getPort(), $this->server->getIp() === "" ? "0.0.0.0" : $this->server->getIp());
|
||||
$this->interface = new ServerHandler($this->rakLib, $this);
|
||||
@ -94,7 +94,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
public function closeSession($identifier, $reason){
|
||||
if(isset($this->players[$identifier])){
|
||||
$player = $this->players[$identifier];
|
||||
$this->identifiers->detach($player);
|
||||
unset($this->identifiers[spl_object_hash($player)]);
|
||||
unset($this->players[$identifier]);
|
||||
unset($this->identifiersACK[$identifier]);
|
||||
$player->close($player->getLeaveMessage(), $reason);
|
||||
@ -102,11 +102,11 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
}
|
||||
|
||||
public function close(Player $player, $reason = "unknown reason"){
|
||||
if(isset($this->identifiers[$player])){
|
||||
unset($this->players[$this->identifiers[$player]]);
|
||||
unset($this->identifiersACK[$this->identifiers[$player]]);
|
||||
$this->interface->closeSession($this->identifiers[$player], $reason);
|
||||
$this->identifiers->detach($player);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
$player = new $class($this, $ev->getClientId(), $ev->getAddress(), $ev->getPort());
|
||||
$this->players[$identifier] = $player;
|
||||
$this->identifiersACK[$identifier] = 0;
|
||||
$this->identifiers->attach($player, $identifier);
|
||||
$this->identifiers[spl_object_hash($player)] = $identifier;
|
||||
$this->server->addPlayer($identifier, $player);
|
||||
}
|
||||
|
||||
@ -196,8 +196,8 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
}
|
||||
|
||||
public function putPacket(Player $player, DataPacket $packet, $needACK = false, $immediate = false){
|
||||
if(isset($this->identifiers[$player])){
|
||||
$identifier = $this->identifiers[$player];
|
||||
if(isset($this->identifiers[$h = spl_object_hash($player)])){
|
||||
$identifier = $this->identifiers[$h];
|
||||
$pk = null;
|
||||
if(!$packet->isEncoded){
|
||||
$packet->encode();
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 88c47ff3eca89dd369c9a4d575d40a777bda4ac8
|
||||
Subproject commit b90c277f1a24fcda49e14510d83a0d956b0ebad7
|
Loading…
x
Reference in New Issue
Block a user