mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Implemented circular chunk sending
This commit is contained in:
parent
7b141b0b73
commit
67f6482c76
@ -668,18 +668,24 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return false;
|
||||
}
|
||||
|
||||
$radiusSquared = $this->viewDistance / M_PI;
|
||||
$radius = ceil(sqrt($radiusSquared));
|
||||
|
||||
$newOrder = [];
|
||||
$lastChunk = $this->usedChunks;
|
||||
$centerX = $this->x >> 4;
|
||||
$centerZ = $this->z >> 4;
|
||||
$startX = $centerX - $this->viewDistance;
|
||||
$startZ = $centerZ - $this->viewDistance;
|
||||
$finalX = $centerX + $this->viewDistance;
|
||||
$finalZ = $centerZ + $this->viewDistance;
|
||||
$startX = $centerX - $radius;
|
||||
$startZ = $centerZ - $radius;
|
||||
$finalX = $centerX + $radius;
|
||||
$finalZ = $centerZ + $radius;
|
||||
$generateQueue = new ReversePriorityQueue();
|
||||
for($X = $startX; $X <= $finalX; ++$X){
|
||||
for($Z = $startZ; $Z <= $finalZ; ++$Z){
|
||||
$distance = abs($X - $centerX) + abs($Z - $centerZ);
|
||||
$distance = ($X * $X) + ($Z * $Z);
|
||||
if($distance > $radiusSquared){
|
||||
continue;
|
||||
}
|
||||
$index = Level::chunkHash($X, $Z);
|
||||
if(!isset($this->usedChunks[$index])){
|
||||
if($this->getLevel()->isChunkPopulated($X, $Z)){
|
||||
@ -693,7 +699,18 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
|
||||
asort($newOrder);
|
||||
$this->loadQueue = $newOrder;
|
||||
if(count($newOrder) > $this->viewDistance){
|
||||
$count = 0;
|
||||
$this->loadQueue = [];
|
||||
foreach($newOrder as $k => $distance){
|
||||
$this->loadQueue[$k] = $distance;
|
||||
if(++$count > $this->viewDistance){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->loadQueue = $newOrder;
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while(count($this->loadQueue) < 3 and $generateQueue->count() > 0 and $i < 16){
|
||||
|
@ -277,7 +277,7 @@ class Server{
|
||||
* @return int
|
||||
*/
|
||||
public function getViewDistance(){
|
||||
return min(11, max($this->getConfigInt("view-distance", 7), 4));
|
||||
return max(56, $this->getProperty("chunk-sending.max-chunks"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1052,8 +1052,8 @@ class Server{
|
||||
}
|
||||
}
|
||||
|
||||
if(($provider = LevelProviderManager::getProviderByName($this->getProperty("level-settings.default-format", "mcregion"))) === null){
|
||||
$provider = LevelProviderManager::getProviderByName("mcregion");
|
||||
if(($provider = LevelProviderManager::getProviderByName($providerName = $this->getProperty("level-settings.default-format", "mcregion"))) === null){
|
||||
$provider = LevelProviderManager::getProviderByName($providerName = "mcregion");
|
||||
}
|
||||
|
||||
$path = $this->getDataPath() . "worlds/" . $name . "/";
|
||||
@ -1405,7 +1405,6 @@ class Server{
|
||||
"white-list" => false,
|
||||
"announce-player-achievements" => true,
|
||||
"spawn-protection" => 16,
|
||||
"view-distance" => 8,
|
||||
"max-players" => 20,
|
||||
"allow-flight" => false,
|
||||
"spawn-animals" => true,
|
||||
|
@ -34,6 +34,9 @@ chunk-sending:
|
||||
per-tick: 4
|
||||
#Compression level used when sending chunks. Higher = more CPU, less bandwidth usage
|
||||
compression-level: 7
|
||||
#Amount of chunks loaded around a player by the server, min. 56 as MC: PE 0.9.5
|
||||
#Increasing this more than 96 (as of MC: PE 0.9.5) can cause issues with the client ignoring chunks
|
||||
max-chunks: 96
|
||||
|
||||
chunk-ticking:
|
||||
#Max amount of chunks processed each tick
|
||||
|
Loading…
x
Reference in New Issue
Block a user