本文整理汇总了PHP中pocketmine\utils\Binary::readShort方法的典型用法代码示例。如果您正苦于以下问题:PHP Binary::readShort方法的具体用法?PHP Binary::readShort怎么用?PHP Binary::readShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\utils\Binary
的用法示例。
在下文中一共展示了Binary::readShort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readPacket
protected function readPacket()
{
if (strlen($packet = $this->thread->readMainToThreadPacket()) > 0) {
$pid = ord($packet[0]);
$offset = 1;
if ($pid === self::PACKET_REQUEST_CHUNK) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$chunkX = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$chunkZ = Binary::readInt(substr($packet, $offset, 4));
$this->enqueueChunk($levelID, $chunkX, $chunkZ);
} elseif ($pid === self::PACKET_SEND_CHUNK) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$len = ord($packet[$offset++]);
/** @var FullChunk $class */
$class = substr($packet, $offset, $len);
$offset += $len;
$chunk = $class::fromBinary(substr($packet, $offset));
$this->receiveChunk($levelID, $chunk);
} elseif ($pid === self::PACKET_OPEN_LEVEL) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$seed = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$len = Binary::readShort(substr($packet, $offset, 2));
$offset += 2;
$class = substr($packet, $offset, $len);
$offset += $len;
$options = unserialize(substr($packet, $offset));
$this->openLevel($levelID, $seed, $class, $options);
} elseif ($pid === self::PACKET_CLOSE_LEVEL) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$this->closeLevel($levelID);
} elseif ($pid === self::PACKET_ADD_NAMESPACE) {
$len = Binary::readShort(substr($packet, $offset, 2));
$offset += 2;
$namespace = substr($packet, $offset, $len);
$offset += $len;
$path = substr($packet, $offset);
$this->loader->addPath($path);
} elseif ($pid === self::PACKET_SHUTDOWN) {
foreach ($this->levels as $level) {
$level->shutdown();
}
$this->levels = [];
$this->shutdown = true;
}
} elseif (count($this->thread->getInternalQueue()) === 0) {
$this->thread->synchronized(function () {
$this->thread->wait(50000);
});
}
}
示例2: getShort
public function getShort()
{
return Binary::readShort($this->get(2));
}
示例3: readShort
public function readShort($signed = true)
{
return Binary::readShort($this->read(2), $signed);
}
示例4: getShort
public function getShort()
{
return $this->endianness === self::BIG_ENDIAN ? Binary::readShort($this->get(2)) : Binary::readLShort($this->get(2));
}
示例5: upgrade_From0_To1
private function upgrade_From0_To1()
{
MainLogger::getLogger()->notice("Old PMF Level format version #0 detected, upgrading to version #1");
for ($index = 0; $index < 256; ++$index) {
$X = $index & 0xf;
$Z = $index >> 4;
$bitflags = Binary::readShort($this->read(2));
$oldPath = dirname($this->file) . "/chunks/" . $Z . "." . $X . ".pmc";
$chunkOld = gzopen($oldPath, "rb");
$newPath = dirname($this->file) . "/chunks/" . (($X ^ $Z) & 0xff) . "/" . $Z . "." . $X . ".pmc";
@mkdir(dirname($newPath));
$chunkNew = gzopen($newPath, "wb1");
gzwrite($chunkNew, chr($bitflags) . "");
while (gzeof($chunkOld) === false) {
gzwrite($chunkNew, gzread($chunkOld, 65535));
}
gzclose($chunkNew);
gzclose($chunkOld);
@unlink($oldPath);
}
$this->levelData["version"] = 1;
$this->levelData["generator"] = "default";
$this->levelData["generatorSettings"] = "";
}
示例6: getShort
protected function getShort($signed = true)
{
return $signed ? Binary::readSignedShort($this->get(2)) : Binary::readShort($this->get(2));
}
示例7: getShort
protected function getShort($signed = true)
{
return Binary::readShort($this->get(2), $signed);
}