mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-19 04:05:31 +00:00
Level: minor de-spaghettification of chunk requesting
Now the Level tells the player to request chunks on tick, instead of the server doing it.
This commit is contained in:
parent
e57dd3e8ba
commit
1144620f2b
@ -1140,6 +1140,20 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
Timings::$playerChunkOrderTimer->stopTiming();
|
||||
}
|
||||
|
||||
public function doChunkRequests(){
|
||||
if(!$this->isOnline()){
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->nextChunkOrderRun-- <= 0){
|
||||
$this->orderChunks();
|
||||
}
|
||||
|
||||
if(count($this->loadQueue) > 0){
|
||||
$this->sendNextChunk();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Position
|
||||
*/
|
||||
@ -1774,20 +1788,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
|
||||
public function checkNetwork(){
|
||||
if(!$this->isOnline()){
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->nextChunkOrderRun-- <= 0){
|
||||
$this->orderChunks();
|
||||
}
|
||||
|
||||
if(count($this->loadQueue) > 0){
|
||||
$this->sendNextChunk();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the player can interact with the specified position. This checks distance and direction.
|
||||
*
|
||||
|
@ -2511,10 +2511,6 @@ class Server{
|
||||
|
||||
$this->checkTickUpdates($this->tickCounter, $tickTime);
|
||||
|
||||
foreach($this->players as $player){
|
||||
$player->checkNetwork();
|
||||
}
|
||||
|
||||
if(($this->tickCounter % 20) === 0){
|
||||
if($this->doTitleTick){
|
||||
$this->titleTick();
|
||||
|
@ -787,7 +787,10 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
}
|
||||
|
||||
$this->processChunkRequest();
|
||||
foreach($this->players as $p){
|
||||
$p->doChunkRequests();
|
||||
}
|
||||
$this->processChunkRequests();
|
||||
|
||||
if($this->sleepTicks > 0 and --$this->sleepTicks <= 0){
|
||||
$this->checkSleep();
|
||||
@ -2464,7 +2467,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
private function processChunkRequest(){
|
||||
private function processChunkRequests(){
|
||||
if(count($this->chunkSendQueue) > 0){
|
||||
$this->timings->syncChunkSendTimer->startTiming();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user