public function parse($path) { $mpq = new MPQFile($path, true, false); $init = $mpq->getState(); if (!$init) { return false; } $r = $mpq->parseReplay(); if (!$r) { return false; } $this->r_infos['version'] = $mpq->getVersionString(); $this->r_infos['realm'] = $r->getRealm(); $this->r_infos['speed'] = $r->getGameSpeed(); $this->r_infos['winner_known'] = $r->isWinnerKnown(); $this->r_infos['type'] = $r->getTeamSize(); $this->r_infos['length'] = $r->getGameLength(); $this->r_infos['real_length'] = (int) ($this->r_infos['length'] * 60) / 83.5; $this->r_infos['map'] = $r->getMapName(); $this->r_infos['map_hash'] = $r->getMapHash(); $this->r_infos['players'] = $r->getPlayers(); foreach ($this->r_infos['players'] as $k => &$player) { if ($player['isObs']) { $this->r_infos['obs'][] = $this->r_infos['players'][$k]; unset($this->r_infos['players'][$k]); continue; } $player['army'] = $player['race']; $player['bnet_id'] = (int) $player['uid']; } $this->computeAPM(); $this->_computeMessages($r); $this->_computeWinner(); return true; }
$scores[$i]['sColor'] = $player['sColor']; $scores[$i]['APM'] = $player['team'] > 0 ? round($player['apmtotal'] / ($b->getGameLength() / 60)) : 0; $i++; } } $nbr_players = $i; //var_dump($match); //var_dump($scores); } else { $error_str .= '<li>Error</li>'; } if ($error_str != '') { $text .= '<p style="color:red">' . EB_SUBMITREPLAY_L2; $text .= '<ul style="color:red">' . $error_str . '</ul></p>'; $text .= '<table class="eb_table table_left"><tbody>'; $text .= '<td class="eb_td eb_tdc1">Version</td><td class="eb_td2">' . $a->getVersionString(); $text .= '<tr><td class="eb_td eb_tdc1">Map name</td><td class="eb_td2">' . $b->getMapName() . '</td></tr>'; $text .= '<tr><td class="eb_td eb_tdc1">Game length</td><td class="eb_td2">' . $b->getFormattedGameLength() . '</td></tr>'; $text .= '<tr><td class="eb_td eb_tdc1">Team size</td><td class="eb_td2">' . $b->getTeamSize() . '</td></tr>'; $text .= '<tr><td class="eb_td eb_tdc1">Game speed</td><td class="eb_td2">' . $b->getGameSpeedText() . '</td></tr>'; $text .= '<tr><td class="eb_td eb_tdc1">Real team size</td><td class="eb_td2">' . $b->getRealTeamSize() . '</td></tr>'; $text .= '<tr><td class="eb_td eb_tdc1">Realm</td><td class="eb_td2">' . $b->getRealm() . '</td></tr>'; $text .= '<tr><td class="eb_td eb_tdc1">Date and time played</td><td class="eb_td2">' . date('jS \\of F Y \\a\\t H:i', $b->getCtime()) . '</td></tr>'; if ($recorder != null) { $text .= '<tr><td class="eb_td eb_tdc1">Replay recorded by</td><td class="eb_td2">' . $recorder['name'] . '</td></tr>'; } $text .= '</tbody></table>'; $apmString = "<b>APM graphs</b><br />\n"; $obsString = ""; $obsCount = 0; $text .= '<br />';
//$a = new MPQFile("testfile.SC2Replay", true, 2); $byte = 0; $b = new SC2Replay($a); $b->setDebug(true); $tmp = $b->parseDetailsValue($a->readFile("replay.details"), $byte); echo "<pre>"; var_dump($tmp); echo "</pre>"; die; } } if ($init == false) { echo "Error parsing uploaded file, make sure it is a valid MPQ archive!<br />\n"; } else { if ($a->getFileType() == "SC2replay") { echo sprintf("Version: %s<br />\n", $a->getVersionString()); $b = $a->parseReplay(); $parseDurationString .= sprintf("Parsed replay in %d ms.<br />\n", (microtime_float() - $start) * 1000); $players = $b->getPlayers(); $recorder = $b->getRecorder(); echo sprintf("Map name: %s, Game length: %s<br />\n", $b->getMapName(), $b->getFormattedGameLength()); echo sprintf("Team size: %s, Game speed: %s<br />\n", $b->getTeamSize(), $b->getGameSpeedText()); echo sprintf("Real team size: %s<br />\n", $b->getRealTeamSize()); echo sprintf("Realm: %s<br />\n", $b->getRealm()); echo sprintf("Game type: %s<br />\n", SC2Replay::$gameTypes[$b->getGameType()]); echo sprintf("Date and time played: %s<br />\n", date('jS \\of F Y \\a\\t H:i', $b->getCtime())); if ($recorder != null) { echo sprintf("Replay recorded by: %s (EXPERIMENTAL!)<br />\n", $recorder['name']); } $apmString = "<b>APM graphs</b><br />\n"; $obsString = "";