Skip to content

Commit

Permalink
Revert "Merge branch 'master' into version_1_14_60"
Browse files Browse the repository at this point in the history
This reverts commit d9130f6, reversing
changes made to 6a28588.
  • Loading branch information
alleskos committed Mar 31, 2020
1 parent bfe26fb commit 96f29db
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 1,160 deletions.
24 changes: 7 additions & 17 deletions src/pocketmine/ChunkMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@
use raklib\protocol\EncapsulatedPacket;
use raklib\RakLib;
use pocketmine\network\protocol\DataPacket;
use pocketmine\network\ProxyInterface;

class ChunkMaker extends Thread {

protected $classLoader;
protected $shutdown;
protected $internalQueue;
protected $raklib;
protected $proxy;

public function __construct(\ClassLoader $loader, $raklib, $proxy) {
public function __construct(\ClassLoader $loader, $raklib) {
$this->internalQueue = new \Threaded;
$this->shutdown = false;
$this->classLoader = $loader;
$this->raklib = $raklib;
$this->proxy = $proxy;
$this->start(PTHREADS_INHERIT_CONSTANTS);
}

Expand All @@ -41,19 +38,12 @@ public function run() {
new ChunkStorage($this);
}

public function sendData($data, $buffer) {
if (!is_null($this->proxy) && !empty($data['proxySessionId']) && !empty($data['proxyId'])) {
$infoData = pack('N', $data['proxySessionId']) . chr(ProxyInterface::STANDART_PACKET_ID) . $buffer;
$info = chr(strlen($data['proxyId'])) . $data['proxyId'] . $infoData;
$this->proxy->writeToProxyServer($info);
} elseif(!is_null($this->raklib)) {
$identifier = $data['identifier'];
$pk = new EncapsulatedPacket();
$pk->buffer = $buffer;
$pk->reliability = 3;
$enBuffer = chr(RakLib::PACKET_ENCAPSULATED) . chr(strlen($identifier)) . $identifier . chr(RakLib::PRIORITY_NORMAL) . $pk->toBinary(true);
$this->raklib->pushMainToThreadPacket($enBuffer);
}
public function sendData($identifier, $buffer) {
$pk = new EncapsulatedPacket();
$pk->buffer = $buffer;
$pk->reliability = 3;
$enBuffer = chr(RakLib::PACKET_ENCAPSULATED) . chr(strlen($identifier)) . $identifier . chr(RakLib::PRIORITY_NORMAL) . $pk->toBinary(true);
$this->raklib->pushMainToThreadPacket($enBuffer);
}

public function pushMainToThreadPacket($data) {
Expand Down
4 changes: 2 additions & 2 deletions src/pocketmine/ChunkStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function clearChunkCache($data) {

protected function sendFromCache($data) {
$buffer = $this->getCache(Level::chunkHash($data['chunkX'], $data['chunkZ']), ($data['protocol'] << 4) | $data['subClientId']);
$this->server->sendData($data, $buffer);
$this->server->sendData($data['identifier'], $buffer);
}

protected function doChunk($data) {
Expand Down Expand Up @@ -103,7 +103,7 @@ protected function doChunk($data) {
$buffer = $pk->getBuffer();
$decodedBuffer = Binary::writeVarInt(strlen($buffer)) . $buffer;
$buffer = zlib_encode($decodedBuffer, ZLIB_ENCODING_DEFLATE, 7);
$this->server->sendData($data, $buffer);
$this->server->sendData($data['identifier'], $buffer);
$this->setCache(Level::chunkHash($data['chunkX'], $data['chunkZ']), ($protocol << 4) | $subClientId, $buffer);
}

Expand Down
26 changes: 8 additions & 18 deletions src/pocketmine/PacketMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@
use pocketmine\network\protocol\MoveEntityPacket;
use pocketmine\network\protocol\SetEntityMotionPacket;
use pocketmine\network\protocol\MovePlayerPacket;
use pocketmine\network\proxylib\ProxyServer;
use pocketmine\network\ProxyInterface;

class PacketMaker extends Thread {

protected $classLoader;
protected $shutdown;
protected $internalQueue;
protected $raklib;
protected $proxy;

public function __construct(\ClassLoader $loader, $raklib, $proxy) {
public function __construct(\ClassLoader $loader, $raklib) {
$this->internalQueue = new \Threaded;
$this->shutdown = false;
$this->classLoader = $loader;
$this->raklib = $raklib;
$this->proxy = $proxy;
$this->start(PTHREADS_INHERIT_CONSTANTS);
}

Expand Down Expand Up @@ -110,23 +106,17 @@ protected function checkPacket($data) {
}
if (!empty($moveStr)) {
$buffer = zlib_encode($moveStr, ZLIB_ENCODING_DEFLATE, 7);
$this->sendData($identifier, $buffer, $playerData);
$this->sendData($identifier, $buffer);
}
}
}

protected function sendData($identifier, $buffer, $data) {
if (!is_null($this->proxy) && !empty($data['proxySessionId']) && !empty($data['proxyId'])) {
$infoData = pack('N', $data['proxySessionId']) . chr(ProxyInterface::STANDART_PACKET_ID) . $buffer;
$info = chr(strlen($data['proxyId'])) . $data['proxyId'] . $infoData;
$this->proxy->writeToProxyServer($info);
} elseif(!is_null($this->raklib)) {
$pk = new EncapsulatedPacket();
$pk->buffer = $buffer;
$pk->reliability = 3;
$enBuffer = chr(RakLib::PACKET_ENCAPSULATED) . chr(strlen($identifier)) . $identifier . chr(RakLib::PRIORITY_NORMAL) . $pk->toBinary(true);
$this->raklib->pushMainToThreadPacket($enBuffer);
}
protected function sendData($identifier, $buffer) {
$pk = new EncapsulatedPacket();
$pk->buffer = $buffer;
$pk->reliability = 3;
$enBuffer = chr(RakLib::PACKET_ENCAPSULATED) . chr(strlen($identifier)) . $identifier . chr(RakLib::PRIORITY_NORMAL) . $pk->toBinary(true);
$this->raklib->pushMainToThreadPacket($enBuffer);
}

}
Loading

0 comments on commit 96f29db

Please sign in to comment.