Beispiel #1
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();
 }