mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
FastChunkSerializer: use machine endianness for pack() (thanks @Frago9876543210)
this is faster due to not having to reverse bytes. Since we don't use this format for persistence, it's OK to use machine byte order for this.
This commit is contained in:
@ -76,7 +76,7 @@ final class FastChunkSerializer{
|
||||
|
||||
$stream->putByte($blocks->getBitsPerBlock());
|
||||
$stream->put($wordArray);
|
||||
$serialPalette = pack("N*", ...$palette);
|
||||
$serialPalette = pack("L*", ...$palette);
|
||||
$stream->putInt(strlen($serialPalette));
|
||||
$stream->put($serialPalette);
|
||||
}
|
||||
@ -90,7 +90,7 @@ final class FastChunkSerializer{
|
||||
//biomes
|
||||
$stream->put($chunk->getBiomeIdArray());
|
||||
if($includeLight){
|
||||
$stream->put(pack("v*", ...$chunk->getHeightMapArray()));
|
||||
$stream->put(pack("S*", ...$chunk->getHeightMapArray()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ final class FastChunkSerializer{
|
||||
for($i = 0, $layerCount = $stream->getByte(); $i < $layerCount; ++$i){
|
||||
$bitsPerBlock = $stream->getByte();
|
||||
$words = $stream->get(PalettedBlockArray::getExpectedWordArraySize($bitsPerBlock));
|
||||
$palette = array_values(unpack("N*", $stream->get($stream->getInt())));
|
||||
$palette = array_values(unpack("L*", $stream->get($stream->getInt())));
|
||||
|
||||
$layers[] = PalettedBlockArray::fromData($bitsPerBlock, $words, $palette);
|
||||
}
|
||||
@ -134,7 +134,7 @@ final class FastChunkSerializer{
|
||||
|
||||
$biomeIds = $stream->get(256);
|
||||
if($lightPopulated){
|
||||
$heightMap = array_values(unpack("v*", $stream->get(512)));
|
||||
$heightMap = array_values(unpack("S*", $stream->get(512)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user