BatchPacket, compress any packet depending on the size, really fast threaded chunk sending

This commit is contained in:
Shoghi Cervantes
2015-03-25 23:50:55 +01:00
parent 7d1313c63d
commit 962c28aaca
16 changed files with 658 additions and 233 deletions

View File

@ -34,7 +34,6 @@ class ChunkRequestTask extends AsyncTask{
protected $levelId;
protected $chunkX;
protected $chunkZ;
protected $compressionLevel;
/** @var \pocketmine\level\format\ChunkSection[] */
protected $sections;
@ -69,8 +68,6 @@ class ChunkRequestTask extends AsyncTask{
$this->tiles = $tiles;
$this->compressionLevel = Level::$COMPRESSION_LEVEL;
}
public function onRun(){
@ -102,9 +99,9 @@ class ChunkRequestTask extends AsyncTask{
$biomeColors = pack("N*", ...$this->biomeColors);
$ordered = zlib_encode($orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $this->biomeIds . $biomeColors . $this->tiles, ZLIB_ENCODING_DEFLATE, $this->compressionLevel);
$ordered = $orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $this->biomeIds . $biomeColors . $this->tiles;
$this->setResult($ordered);
$this->setResult($ordered, false);
}
public function getColumn(&$data, $x, $z){

View File

@ -148,15 +148,13 @@ class LevelDB extends BaseLevelProvider{
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
$ordered = zlib_encode(
$chunk->getBlockIdArray() .
$ordered = $chunk->getBlockIdArray() .
$chunk->getBlockDataArray() .
$chunk->getBlockSkyLightArray() .
$chunk->getBlockLightArray() .
$chunk->getBiomeIdArray() .
$biomeColors .
$tiles
, ZLIB_ENCODING_DEFLATE, Level::$COMPRESSION_LEVEL);
$tiles;
$this->getLevel()->chunkRequestCallback($x, $z, $ordered);

View File

@ -129,15 +129,13 @@ class McRegion extends BaseLevelProvider{
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
$ordered = zlib_encode(
$chunk->getBlockIdArray() .
$ordered = $chunk->getBlockIdArray() .
$chunk->getBlockDataArray() .
$chunk->getBlockSkyLightArray() .
$chunk->getBlockLightArray() .
$chunk->getBiomeIdArray() .
$biomeColors .
$tiles
, ZLIB_ENCODING_DEFLATE, Level::$COMPRESSION_LEVEL);
$tiles;
$this->getLevel()->chunkRequestCallback($x, $z, $ordered);