本文整理汇总了PHP中Stream::readInt方法的典型用法代码示例。如果您正苦于以下问题:PHP Stream::readInt方法的具体用法?PHP Stream::readInt怎么用?PHP Stream::readInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::readInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readCheckType
public static function readCheckType(Stream $reader, $expectedType)
{
if ($reader instanceof IntReader) {
$type = $reader->readInt();
} else {
$type = self::readIntEndian($reader);
}
if ($type != $expectedType) {
throw new IOException("Expected chunk of type 0x" . dechex($expectedType) . ", read 0x" . dechex($type) . ".");
}
}
示例2: 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;
//.........这里部分代码省略.........