check range of valid compression values

zero is not allowed because it's pointless, just raise your compression threshold if you want zero compression.

Chunks will always be compressed regardless of threshold because they are huge. It doesn't make sense to allow uncompressed chunks when even compression level 1 will reduce their size 50x. The point of the last two (reverted) commits was to prevent compression level zero being used on chunks. Probably obvious that I was up late and not thinking very clearly.

Revert "Reduced chunk compression level to 7"

This reverts commit 49ac2555ce3d410c49eba4045ffe8a5138066346.

Revert "Always use best compression for chunks"

This reverts commit 42dd9d6abd4e7a66611cd171abd0f8f7969166c1.
This commit is contained in:
Dylan K. Taylor 2017-10-01 10:48:48 +01:00
parent 49ac2555ce
commit afa37bd2aa
2 changed files with 9 additions and 1 deletions

View File

@ -1515,7 +1515,12 @@ class Server{
}else{
Network::$BATCH_THRESHOLD = -1;
}
$this->networkCompressionLevel = $this->getProperty("network.compression-level", 7);
if($this->networkCompressionLevel < 1 or $this->networkCompressionLevel > 9){
$this->logger->warning("Invalid network compression level $this->networkCompressionLevel set, setting to default 7");
$this->networkCompressionLevel = 7;
}
$this->networkCompressionAsync = $this->getProperty("network.async-compression", true);
$this->autoTickRate = (bool) $this->getProperty("level-settings.auto-tick-rate", true);

View File

@ -42,8 +42,11 @@ class ChunkRequestTask extends AsyncTask{
protected $tiles;
protected $compressionLevel;
public function __construct(Level $level, Chunk $chunk){
$this->levelId = $level->getId();
$this->compressionLevel = $level->getServer()->networkCompressionLevel;
$this->chunk = $chunk->fastSerialize();
$this->chunkX = $chunk->getX();
@ -72,7 +75,7 @@ class ChunkRequestTask extends AsyncTask{
$batch = new BatchPacket();
$batch->addPacket($pk);
$batch->setCompressionLevel(7);
$batch->setCompressionLevel($this->compressionLevel);
$batch->encode();
$this->setResult($batch->buffer, false);