mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 21:45:35 +00:00
Revert "Revert "Player: do not re-request the same ungenerated chunks multiple times""
This reverts commit 3265d3f6b4d6705276b56fab5f765e2f97b5d992.
This commit is contained in:
parent
96cfdc79b8
commit
bd60e41268
@ -924,7 +924,7 @@ class NetworkSession{
|
|||||||
$this->logger->debug("Tried to send no-longer-active chunk $chunkX $chunkZ in world " . $world->getFolderName());
|
$this->logger->debug("Tried to send no-longer-active chunk $chunkX $chunkZ in world " . $world->getFolderName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!$status->equals(UsedChunkStatus::REQUESTED())){
|
if(!$status->equals(UsedChunkStatus::REQUESTED_SENDING())){
|
||||||
//TODO: make this an error
|
//TODO: make this an error
|
||||||
//this could be triggered due to the shitty way that chunk resends are handled
|
//this could be triggered due to the shitty way that chunk resends are handled
|
||||||
//right now - not because of the spammy re-requesting, but because the chunk status reverts
|
//right now - not because of the spammy re-requesting, but because the chunk status reverts
|
||||||
|
@ -676,7 +676,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
|
|
||||||
++$count;
|
++$count;
|
||||||
|
|
||||||
$this->usedChunks[$index] = UsedChunkStatus::NEEDED();
|
$this->usedChunks[$index] = UsedChunkStatus::REQUESTED_GENERATION();
|
||||||
|
unset($this->loadQueue[$index]);
|
||||||
$this->getWorld()->registerChunkLoader($this->chunkLoader, $X, $Z, true);
|
$this->getWorld()->registerChunkLoader($this->chunkLoader, $X, $Z, true);
|
||||||
$this->getWorld()->registerChunkListener($this, $X, $Z);
|
$this->getWorld()->registerChunkListener($this, $X, $Z);
|
||||||
|
|
||||||
@ -685,15 +686,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
if(!$this->isConnected() || !isset($this->usedChunks[$index]) || $world !== $this->getWorld()){
|
if(!$this->isConnected() || !isset($this->usedChunks[$index]) || $world !== $this->getWorld()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!$this->usedChunks[$index]->equals(UsedChunkStatus::NEEDED())){
|
if(!$this->usedChunks[$index]->equals(UsedChunkStatus::REQUESTED_GENERATION())){
|
||||||
//TODO: make this an error
|
throw new AssumptionFailedError("Used chunk status should not have changed while in REQUESTED_GENERATION mode");
|
||||||
//we may have added multiple completion handlers, since the Player keeps re-requesting chunks
|
|
||||||
//it doesn't have yet (a relic from the old system, but also currently relied on for chunk resends).
|
|
||||||
//in this event, make sure we don't try to send the chunk multiple times.
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
unset($this->loadQueue[$index]);
|
$this->usedChunks[$index] = UsedChunkStatus::REQUESTED_SENDING();
|
||||||
$this->usedChunks[$index] = UsedChunkStatus::REQUESTED();
|
|
||||||
|
|
||||||
$this->getNetworkSession()->startUsingChunk($X, $Z, function() use ($X, $Z, $index) : void{
|
$this->getNetworkSession()->startUsingChunk($X, $Z, function() use ($X, $Z, $index) : void{
|
||||||
$this->usedChunks[$index] = UsedChunkStatus::SENT();
|
$this->usedChunks[$index] = UsedChunkStatus::SENT();
|
||||||
|
@ -32,7 +32,8 @@ use pocketmine\utils\EnumTrait;
|
|||||||
* @generate-registry-docblock
|
* @generate-registry-docblock
|
||||||
*
|
*
|
||||||
* @method static UsedChunkStatus NEEDED()
|
* @method static UsedChunkStatus NEEDED()
|
||||||
* @method static UsedChunkStatus REQUESTED()
|
* @method static UsedChunkStatus REQUESTED_GENERATION()
|
||||||
|
* @method static UsedChunkStatus REQUESTED_SENDING()
|
||||||
* @method static UsedChunkStatus SENT()
|
* @method static UsedChunkStatus SENT()
|
||||||
*/
|
*/
|
||||||
final class UsedChunkStatus{
|
final class UsedChunkStatus{
|
||||||
@ -41,7 +42,8 @@ final class UsedChunkStatus{
|
|||||||
protected static function setup() : void{
|
protected static function setup() : void{
|
||||||
self::registerAll(
|
self::registerAll(
|
||||||
new self("NEEDED"),
|
new self("NEEDED"),
|
||||||
new self("REQUESTED"),
|
new self("REQUESTED_GENERATION"),
|
||||||
|
new self("REQUESTED_SENDING"),
|
||||||
new self("SENT")
|
new self("SENT")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user