mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 12:48:32 +00:00
NetworkSession: allow Player to handle its own business in chunk sending
these checks should appear consistently in all of these async callbacks.
This commit is contained in:
parent
f047ecfd2d
commit
a223d1cbf3
@ -916,11 +916,6 @@ class NetworkSession{
|
|||||||
if(!$this->isConnected()){
|
if(!$this->isConnected()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$currentWorld = $this->player->getLocation()->getWorld();
|
|
||||||
if($world !== $currentWorld or !$this->player->isUsingChunk($chunkX, $chunkZ)){
|
|
||||||
$this->logger->debug("Tried to send no-longer-active chunk $chunkX $chunkZ in world " . $world->getFolderName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$currentWorld->timings->syncChunkSend->startTiming();
|
$currentWorld->timings->syncChunkSend->startTiming();
|
||||||
try{
|
try{
|
||||||
$this->queueCompressed($promise);
|
$this->queueCompressed($promise);
|
||||||
|
@ -727,7 +727,11 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
unset($this->loadQueue[$index]);
|
unset($this->loadQueue[$index]);
|
||||||
$this->usedChunks[$index] = UsedChunkStatus::REQUESTED();
|
$this->usedChunks[$index] = UsedChunkStatus::REQUESTED();
|
||||||
|
|
||||||
$this->getNetworkSession()->startUsingChunk($X, $Z, function(int $chunkX, int $chunkZ) use ($index) : void{
|
$this->getNetworkSession()->startUsingChunk($X, $Z, function(int $chunkX, int $chunkZ) use ($index, $world) : void{
|
||||||
|
if(!isset($this->usedChunks[$index]) || $world !== $this->getWorld()){
|
||||||
|
$this->logger->debug("Tried to send no-longer-active chunk $chunkX $chunkZ in world " . $world->getFolderName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->usedChunks[$index] = UsedChunkStatus::SENT();
|
$this->usedChunks[$index] = UsedChunkStatus::SENT();
|
||||||
if($this->spawnChunkLoadCount === -1){
|
if($this->spawnChunkLoadCount === -1){
|
||||||
$this->spawnEntitiesOnChunk($chunkX, $chunkZ);
|
$this->spawnEntitiesOnChunk($chunkX, $chunkZ);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user