. * * $Id: silverback.php,v 1.1 2007/07/11 09:12:31 tombuskens Exp $ */ [silverback] status = "\x9e\x4c\x23\x00\x00\xcePiNG" require_once GAMEQ_BASE . 'Protocol.php'; /** * Silverback Engine Protocol * (Savage) * * @author Tom Buskens * @version $Revision: 1.1 $ */ class GameQ_Protocol_silverback extends GameQ_Protocol { /* * status packet */ public function status() { while ($this->p->getLength()) { $var = $this->p->readString("\xFE"); if ($var == 'players') break; $this->r->add($var, $this->p->readString("\xFF")); } $this->players(); } /* * player / team data */ public function players() { $team = ''; $players = 0; while ($this->p->getLength()) { if ($this->p->lookAhead() == "\x20") { $this->p->skip(); $this->r->addPlayer('name', $this->p->readString("\x0a")); $this->r->addPlayer('team', $team); ++$players; } else { $team = $this->p->readString("\x0a"); if ($team != '--empty--') { $this->r->addTeam('name', $team); } } } } /* * Merge packets */ public function preprocess($packets) { // Cut off headers and join packets $return = ''; foreach ($packets as $packet) { $return .= substr($packet, 12, strlen($packet) - 13); } return $return; } } ?>