From a223d1cbf3e8a9143383b6497f4d2d5d7ab3202a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 26 Mar 2021 22:00:42 +0000 Subject: [PATCH] NetworkSession: allow Player to handle its own business in chunk sending these checks should appear consistently in all of these async callbacks. --- src/network/mcpe/NetworkSession.php | 5 ----- src/player/Player.php | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 7d329d0674..c0ff2c91f8 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -916,11 +916,6 @@ class NetworkSession{ if(!$this->isConnected()){ 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(); try{ $this->queueCompressed($promise); diff --git a/src/player/Player.php b/src/player/Player.php index d371423fa3..66087c66df 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -727,7 +727,11 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ unset($this->loadQueue[$index]); $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(); if($this->spawnChunkLoadCount === -1){ $this->spawnEntitiesOnChunk($chunkX, $chunkZ);