Net_GameServerQuery
[ class tree: Net_GameServerQuery ] [ index: Net_GameServerQuery ] [ all elements ]

Source for file Doom3.php

Documentation is available at Doom3.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP version 4                                                        |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1997-2004 The PHP Group                                |
  6. // +----------------------------------------------------------------------+
  7. // | This source file is subject to version 3.0 of the PHP license,       |
  8. // | that is bundled with this package in the file LICENSE, and is        |
  9. // | available through the world-wide-web at the following url:           |
  10. // | http://www.php.net/license/3_0.txt.                                  |
  11. // | If you did not receive a copy of the PHP license and are unable to   |
  12. // | obtain it through the world-wide-web, please send a note to          |
  13. // | license@php.net so we can mail you a copy immediately.               |
  14. // +----------------------------------------------------------------------+
  15. // | Authors: Aidan Lister <aidan@php.net>                                |
  16. // |          Tom Buskens <ortega@php.net>                                |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Doom3.php,v 1.10 2004/09/14 10:47:40 ortega Exp $
  20.  
  21.  
  22. require_once 'Net\GameServerQuery\Protocol.php';
  23.  
  24.  
  25. /**
  26.  * Doom 3 Protocol
  27.  *
  28.  * @category       Net
  29.  * @package        Net_GameServerQuery
  30.  * @author         Tom Buskens <ortega@php.net>
  31.  * @version        $Revision: 1.10 $
  32.  */
  33. {
  34.     /**
  35.      * Details packet
  36.      *
  37.      * @access    private
  38.      * @return    array      Array containing formatted server response
  39.      */
  40.     protected function _getinfo()
  41.     {
  42.         // Header
  43.         if (!$this->_match("\xff\xffinfoResponse")) {
  44.             throw new Exception('Parsing error');
  45.         }
  46.  
  47.         // Probably a (protocol) version number
  48.         if ($this->_match(".{5}(.).(.)\x00")) {
  49.             $version  $this->toInt($this->_result[1]8'.';
  50.             $version .= $this->toInt($this->_result[2]8);
  51.         }
  52.         else {
  53.             throw new Exception('Parsing error');
  54.         }
  55.  
  56.         // Variable / value pairs
  57.         while ($this->_match("([^\x00]+)\x00([^\x00]*)\x00")) {
  58.             $this->_add($this->_result[1]$this->_result[2]);
  59.         }
  60.  
  61.         // End marker for variables?
  62.         if (!$this->_match("\x00\x00")) {
  63.             throw new Exception('Parsing error');
  64.         }
  65.  
  66.         // Players (ping and score in here somehwere)
  67.         while ($this->_match("(.)(..)(.)(.)(..)([^\x00]+)\x00")) {
  68.  
  69.             $this->_addPlayer('id'$this->toInt($this->_result[1]8));
  70.             $this->_addPlayer('ping'$this->toInt($this->_result[2]16));
  71.  
  72.             // teams, either \x80\x3e or \x50\xc3
  73.             switch ($this->_result[3]{
  74.                 case "\x80":
  75.                     $team = 1;
  76.                     break;
  77.  
  78.                 case "\x50":
  79.                     $team = 2;
  80.                     break;
  81.  
  82.                 default:
  83.                     $team 'unknown';
  84.                     break;
  85.             }
  86.             $this->_addPlayer('team'$team);
  87.  
  88.             // Player name
  89.             $this->_addPlayer('name'$this->_result[6]);
  90.         }
  91.  
  92.         return $this->_output;
  93.     }
  94. }
  95.  
  96. ?>

Documentation generated on Mon, 11 Mar 2019 13:58:55 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.