World: depopulate neighbourBlockUpdateQueueIndex sooner

this fixes 2 problems:
1) Blocks which set themselves to something else during onNearbyBlockChange() would not receive any block update
2) A memory leak when blocks in unloaded chunks were scheduled for an update.

I'm a little uneasy about this change, because there must have been some reason why I put this at the end of the block and not at the start, but whatever it is, I can't reason about it, and there's reasons not to put it at the end too.
This commit is contained in:
Dylan K. Taylor 2021-09-08 22:10:50 +01:00
parent b9b1ba9526
commit ba2bfe0e11
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -804,6 +804,7 @@ class World implements ChunkManager{
//Normal updates
while($this->neighbourBlockUpdateQueue->count() > 0){
$index = $this->neighbourBlockUpdateQueue->dequeue();
unset($this->neighbourBlockUpdateQueueIndex[$index]);
World::getBlockXYZ($index, $x, $y, $z);
if(!$this->isChunkLoaded($x >> 4, $z >> 4)){
continue;
@ -820,7 +821,6 @@ class World implements ChunkManager{
}
$block->onNearbyBlockChange();
}
unset($this->neighbourBlockUpdateQueueIndex[$index]);
}
$this->timings->scheduledBlockUpdates->stopTiming();