Beispiel #1
0
 /**
  * Handles processing the rules data into a usable format
  *
  * @param \GameQ\Buffer $buffer
  *
  * @return array
  */
 protected function processRules(Buffer $buffer)
 {
     // Set the result to a new result instance
     $result = new Result();
     // Number of rules
     $result->add('num_rules', $buffer->readInt16());
     // Run until we run out of buffer
     while ($buffer->getLength()) {
         $result->add($buffer->readPascalString(), $buffer->readPascalString());
     }
     unset($buffer);
     return $result->fetch();
 }
Beispiel #2
0
 /**
  * Handles processing the player data into a usable format
  *
  * @param Buffer $buffer
  *
  * @return array
  */
 protected function processPlayers(Buffer $buffer)
 {
     // Set the result to a new result instance
     $result = new Result();
     // Get the number of players
     $result->add('numplayers', $buffer->readInt16());
     // Parse players
     while ($buffer->getLength()) {
         // Player id
         if (($id = $buffer->readInt16()) !== 0) {
             // Add the results
             $result->addPlayer('id', $id);
             $result->addPlayer('name', utf8_encode($buffer->readPascalString()));
         }
     }
     unset($buffer, $id);
     return $result->fetch();
 }
Beispiel #3
0
 /**
  * Handles processing the details data into a usable format
  *
  * @param \GameQ\Buffer $buffer
  *
  * @return mixed
  * @throws \GameQ\Exception\Protocol
  */
 protected function processDetails(Buffer $buffer)
 {
     // Set the result to a new result instance
     $result = new Result();
     $result->add('protocol', $buffer->readInt8());
     $result->add('hostname', $buffer->readString());
     $result->add('map', $buffer->readString());
     $result->add('game_dir', $buffer->readString());
     $result->add('game_descr', $buffer->readString());
     $result->add('steamappid', $buffer->readInt16());
     $result->add('num_players', $buffer->readInt8());
     $result->add('max_players', $buffer->readInt8());
     $result->add('num_bots', $buffer->readInt8());
     $result->add('dedicated', $buffer->read());
     $result->add('os', $buffer->read());
     $result->add('password', $buffer->readInt8());
     $result->add('secure', $buffer->readInt8());
     // Special result for The Ship only (appid=2400)
     if ($result->get('steamappid') == 2400) {
         $result->add('game_mode', $buffer->readInt8());
         $result->add('witness_count', $buffer->readInt8());
         $result->add('witness_time', $buffer->readInt8());
     }
     $result->add('version', $buffer->readString());
     // Extra data flag
     if ($buffer->lookAhead(1) !== false) {
         $edf = $buffer->readInt8();
         if ($edf & 0x80) {
             $result->add('port', $buffer->readInt16Signed());
         }
         if ($edf & 0x10) {
             $result->add('steam_id', $buffer->readInt64());
         }
         if ($edf & 0x40) {
             $result->add('sourcetv_port', $buffer->readInt16Signed());
             $result->add('sourcetv_name', $buffer->readString());
         }
         if ($edf & 0x20) {
             $result->add('keywords', $buffer->readString());
         }
         if ($edf & 0x1) {
             $result->add('game_id', $buffer->readInt64());
         }
         unset($edf);
     }
     unset($buffer);
     return $result->fetch();
 }