mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$radiusSquared = $this->viewDistance / M_PI;
|
||||||
|
$radius = ceil(sqrt($radiusSquared));
|
||||||
|
|
||||||
$newOrder = [];
|
$newOrder = [];
|
||||||
$lastChunk = $this->usedChunks;
|
$lastChunk = $this->usedChunks;
|
||||||
$centerX = $this->x >> 4;
|
$centerX = $this->x >> 4;
|
||||||
$centerZ = $this->z >> 4;
|
$centerZ = $this->z >> 4;
|
||||||
$startX = $centerX - $this->viewDistance;
|
$startX = $centerX - $radius;
|
||||||
$startZ = $centerZ - $this->viewDistance;
|
$startZ = $centerZ - $radius;
|
||||||
$finalX = $centerX + $this->viewDistance;
|
$finalX = $centerX + $radius;
|
||||||
$finalZ = $centerZ + $this->viewDistance;
|
$finalZ = $centerZ + $radius;
|
||||||
$generateQueue = new ReversePriorityQueue();
|
$generateQueue = new ReversePriorityQueue();
|
||||||
for($X = $startX; $X <= $finalX; ++$X){
|
for($X = $startX; $X <= $finalX; ++$X){
|
||||||
for($Z = $startZ; $Z <= $finalZ; ++$Z){
|
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);
|
$index = Level::chunkHash($X, $Z);
|
||||||
if(!isset($this->usedChunks[$index])){
|
if(!isset($this->usedChunks[$index])){
|
||||||
if($this->getLevel()->isChunkPopulated($X, $Z)){
|
if($this->getLevel()->isChunkPopulated($X, $Z)){
|
||||||
@ -693,7 +699,18 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
asort($newOrder);
|
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;
|
$i = 0;
|
||||||
while(count($this->loadQueue) < 3 and $generateQueue->count() > 0 and $i < 16){
|
while(count($this->loadQueue) < 3 and $generateQueue->count() > 0 and $i < 16){
|
||||||
|
@ -277,7 +277,7 @@ class Server{
|
|||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getViewDistance(){
|
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){
|
if(($provider = LevelProviderManager::getProviderByName($providerName = $this->getProperty("level-settings.default-format", "mcregion"))) === null){
|
||||||
$provider = LevelProviderManager::getProviderByName("mcregion");
|
$provider = LevelProviderManager::getProviderByName($providerName = "mcregion");
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $this->getDataPath() . "worlds/" . $name . "/";
|
$path = $this->getDataPath() . "worlds/" . $name . "/";
|
||||||
@ -1405,7 +1405,6 @@ class Server{
|
|||||||
"white-list" => false,
|
"white-list" => false,
|
||||||
"announce-player-achievements" => true,
|
"announce-player-achievements" => true,
|
||||||
"spawn-protection" => 16,
|
"spawn-protection" => 16,
|
||||||
"view-distance" => 8,
|
|
||||||
"max-players" => 20,
|
"max-players" => 20,
|
||||||
"allow-flight" => false,
|
"allow-flight" => false,
|
||||||
"spawn-animals" => true,
|
"spawn-animals" => true,
|
||||||
|
@ -34,6 +34,9 @@ chunk-sending:
|
|||||||
per-tick: 4
|
per-tick: 4
|
||||||
#Compression level used when sending chunks. Higher = more CPU, less bandwidth usage
|
#Compression level used when sending chunks. Higher = more CPU, less bandwidth usage
|
||||||
compression-level: 7
|
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:
|
chunk-ticking:
|
||||||
#Max amount of chunks processed each tick
|
#Max amount of chunks processed each tick
|
||||||
|
Loading…
x
Reference in New Issue
Block a user