当前位置: 首页>>代码示例>>PHP>>正文


PHP Binary::readShort方法代码示例

本文整理汇总了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);
         });
     }
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:55,代码来源:GenerationManager.php

示例2: getShort

 public function getShort()
 {
     return Binary::readShort($this->get(2));
 }
开发者ID:Cecil107,项目名称:PocketMine-0.13.0,代码行数:4,代码来源:BinaryStream.php

示例3: readShort

 public function readShort($signed = true)
 {
     return Binary::readShort($this->read(2), $signed);
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:4,代码来源:StringReader.php

示例4: getShort

 public function getShort()
 {
     return $this->endianness === self::BIG_ENDIAN ? Binary::readShort($this->get(2)) : Binary::readLShort($this->get(2));
 }
开发者ID:ianju,项目名称:PocketMine-MP,代码行数:4,代码来源:NBT.php

示例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"] = "";
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:24,代码来源:LevelFormat.php

示例6: getShort

 protected function getShort($signed = true)
 {
     return $signed ? Binary::readSignedShort($this->get(2)) : Binary::readShort($this->get(2));
 }
开发者ID:mattiasaxelsson,项目名称:PocketMine-MP,代码行数:4,代码来源:DataPacket.php

示例7: getShort

 protected function getShort($signed = true)
 {
     return Binary::readShort($this->get(2), $signed);
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:4,代码来源:DataPacket.php


注:本文中的pocketmine\utils\Binary::readShort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。