mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 01:16:15 +00:00
Revert "Chunk: added modification counter"
This reverts commit a5418a019d
.
The more I assessed this, the more I realized that this implementation
doesn't actually offer any value. Since modcounters don't persist after
chunk unload + reload, they can't be reliably used to detect changes in
chunks without additional event subscriptions.
For the purpose I actually intended to use them for (population task
cancellation) there's a) another solution, and b) modcounts are
unreliable for that too, because of the aforementioned potential for
chunks to get unloaded and reloaded.
For the case of detecting dirty chunks within PopulationTask itself,
they are also unnecessary, since the dirty flags are sufficient within
there, since FastChunkSerializer doesn't copy dirty flags.
In conclusion, this was a misbegotten addition with little real value,
but does impact performance in hot paths.
This commit is contained in:
@ -51,8 +51,6 @@ final class FastChunkSerializer{
|
||||
*/
|
||||
public static function serializeTerrain(Chunk $chunk) : string{
|
||||
$stream = new BinaryStream();
|
||||
$stream->putLong($chunk->getModificationCount());
|
||||
|
||||
$stream->putByte(
|
||||
($chunk->isPopulated() ? self::FLAG_POPULATED : 0)
|
||||
);
|
||||
@ -90,7 +88,6 @@ final class FastChunkSerializer{
|
||||
*/
|
||||
public static function deserializeTerrain(string $data) : Chunk{
|
||||
$stream = new BinaryStream($data);
|
||||
$modificationCounter = $stream->getLong();
|
||||
|
||||
$flags = $stream->getByte();
|
||||
$terrainPopulated = (bool) ($flags & self::FLAG_POPULATED);
|
||||
@ -118,6 +115,6 @@ final class FastChunkSerializer{
|
||||
|
||||
$biomeIds = new BiomeArray($stream->get(256));
|
||||
|
||||
return new Chunk($subChunks, $biomeIds, $terrainPopulated, $modificationCounter);
|
||||
return new Chunk($subChunks, $biomeIds, $terrainPopulated);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user