當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Stream::readChar方法代碼示例

本文整理匯總了PHP中Stream::readChar方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stream::readChar方法的具體用法?PHP Stream::readChar怎麽用?PHP Stream::readChar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Stream的用法示例。


在下文中一共展示了Stream::readChar方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: readPostgameData

 /**
  * Extracts post-game data (achievements etc) from the body stream.
  *
  * Post-game data will be set on $this->postgameData.
  *
  * @param Stream $stream Body stream to extract from.
  *
  * @return void
  */
 protected function readPostgameData($stream)
 {
     // Prize for ugliest, most boring method of the project goes to…
     $data = new \stdClass();
     $stream->skip(3);
     $stream->read($scenarioFilename, 32);
     $data->scenarioFilename = rtrim($scenarioFilename);
     $stream->skip(4);
     $stream->readInt($data->duration);
     $stream->readChar($data->allowCheats);
     $stream->readChar($data->complete);
     $stream->skip(14);
     $stream->readChar($data->mapSize);
     $stream->readChar($data->mapId);
     $stream->readChar($data->population);
     $stream->skip(1);
     $stream->readChar($data->victory);
     $stream->readChar($data->startingAge);
     $stream->readChar($data->resources);
     $stream->readChar($data->allTechs);
     $stream->readChar($data->teamTogether);
     $stream->readChar($data->revealMap);
     $stream->skip(3);
     $stream->readChar($data->lockTeams);
     $stream->readChar($data->lockSpeed);
     $stream->skip(1);
     $players = array();
     for ($i = 0; $i < 8; $i++) {
         $playerStats = new \stdClass();
         $stream->read($playerName, 16);
         $playerStats->name = rtrim($playerName);
         $stream->readWord($playerStats->totalScore);
         $totalScores = array();
         for ($j = 0; $j < 8; $j++) {
             $stream->readWord($totalScores[$j]);
         }
         $playerStats->totalScores = $totalScores;
         $stream->readChar($playerStats->victory);
         $stream->readChar($playerStats->civId);
         $stream->readChar($playerStats->colorId);
         $stream->readChar($playerStats->team);
         $stream->skip(2);
         $stream->readChar($playerStats->mvp);
         $stream->skip(3);
         $stream->readChar($playerStats->result);
         $stream->skip(3);
         $militaryStats = new \stdClass();
         $stream->readWord($militaryStats->score);
         $stream->readWord($militaryStats->unitsKilled);
         $stream->readWord($militaryStats->u0);
         $stream->readWord($militaryStats->unitsLost);
         $stream->readWord($militaryStats->buildingsRazed);
         $stream->readWord($militaryStats->u1);
         $stream->readWord($militaryStats->buildingsLost);
         $stream->readWord($militaryStats->unitsConverted);
         $playerStats->militaryStats = $militaryStats;
         $stream->skip(32);
         $economyStats = new \stdClass();
         $stream->readWord($economyStats->score);
         $stream->readWord($economyStats->u0);
         $stream->readInt($economyStats->foodCollected);
         $stream->readInt($economyStats->woodCollected);
         $stream->readInt($economyStats->stoneCollected);
         $stream->readInt($economyStats->goldCollected);
         $stream->readWord($economyStats->tributeSent);
         $stream->readWord($economyStats->tributeReceived);
         $stream->readWord($economyStats->tradeProfit);
         $stream->readWord($economyStats->relicGold);
         $playerStats->economyStats = $economyStats;
         $stream->skip(16);
         $techStats = new \stdClass();
         $stream->readWord($techStats->score);
         $stream->readWord($techStats->u0);
         $stream->readInt($techStats->feudalTime);
         $stream->readInt($techStats->castleTime);
         $stream->readInt($techStats->imperialTime);
         $stream->readChar($techStats->mapExploration);
         $stream->readChar($techStats->researchCount);
         $stream->readChar($techStats->researchPercent);
         $playerStats->techStats = $techStats;
         $stream->skip(1);
         $societyStats = new \stdClass();
         $stream->readWord($societyStats->score);
         $stream->readChar($societyStats->totalWonders);
         $stream->readChar($societyStats->totalCastles);
         $stream->readChar($societyStats->relicsCaptured);
         $stream->readChar($societyStats->u0);
         $stream->readWord($societyStats->villagerHigh);
         $playerStats->societyStats = $societyStats;
         $stream->skip(84);
         $players[] = $playerStats;
//.........這裏部分代碼省略.........
開發者ID:jduyon,項目名稱:recanalyst,代碼行數:101,代碼來源:RecAnalyst.php


注:本文中的Stream::readChar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。