. * * $Id: tribes2.php,v 1.1 2007/07/07 14:52:01 tombuskens Exp $ */ [tribes2] info = "\x0E\x02\x01\x02\x03\x04" status = "\x12\x02\x01\x02\x03\x04" require_once GAMEQ_BASE . 'Protocol.php'; /** * Tribes 2 protocol * * @author Tom Buskens * @version $Revision: 1.1 $ */ class GameQ_Protocol_tribes2 extends GameQ_Protocol { public function info() { // Header $this->p->skip(6); $this->r->add('version', $this->p->readPascalString()); // TODO: Protocol and build numbers $this->p->skip(12); $this->r->add('hostname', $this->p->readPascalString()); } public function status() { // Header $this->p->skip(6); // Vars $this->r->add('mod', $this->p->readPascalString()); $this->r->add('gametype', $this->p->readPascalString()); $this->r->add('map', $this->p->readPascalString()); $this->readBitflag($this->p->read()); $this->r->add('num_players', $this->p->readInt8()); $this->r->add('max_players', $this->p->readInt8()); $this->r->add('num_bots', $this->p->readInt8()); $this->r->add('cpu', $this->p->readInt16()); $this->r->add('info', $this->p->readPascalString()); $this->p->skip(2); $this->teams(); $this->players(); } private function teams() { $num_teams = $this->p->read(); $this->r->add('num_teams', $num_teams); $this->p->skip(); for ($i = 0; $i < $num_teams; $i++) { $this->r->addTeam('name', $this->p->readString("\x09")); $this->r->addTeam('score', $this->p->readString("\x0a")); } } private function players() { // TODO } private function readBitflag($flag) { $vars = array('dedicated', 'password', 'linux', 'tournament', 'no_alias'); $bit = 1; foreach ($vars as $var) { $value = ($flag & $bit) ? 1 : 0; $this->r->add($var, $value); $bit *= 2; } } } ?>