PHP 8 Fix for GameQ -Updated Gameq to V3.1 (the directory is still gameqv2 i will rename it later)

This commit is contained in:
Jan 2023-01-25 14:12:31 +01:00
parent c4f959754d
commit 3419645a60
289 changed files with 7644 additions and 16934 deletions

View File

@ -284,8 +284,10 @@ if (!function_exists('eacchange')) {
// Figure out the class name
$class_name = 'GameQ_Protocols_' . ucfirst(pathinfo($entry, PATHINFO_FILENAME));
// Lets get some info on the class
$reflection = new ReflectionClass($class_name);
if (method_exists($class_name, "get_site_editor_type")) {
$reflection = new \ReflectionClass( $class_name );
// Check to make sure we can actually load the class
try {
@ -307,8 +309,11 @@ if (!function_exists('eacchange')) {
} catch (ReflectionException $e) {
$errors['reflection'] = $e->getMessage();
}
}
}
// Close the directory
unset($dir);

View File

@ -262,8 +262,8 @@ class Buffer
*
* If not found, return everything
*
* @param $delims
* @param null $delimfound
* @param $delims
* @param null|string &$delimfound
*
* @return string
* @throws \GameQ\Exception\Protocol
@ -380,25 +380,30 @@ class Buffer
* @return int
* @throws \GameQ\Exception\Protocol
*/
public function readInt32()
public function readInt32($length = 4)
{
// Change the integer type we are looking up
$littleEndian = null;
switch ($this->number_type) {
case self::NUMBER_TYPE_BIGENDIAN:
$type = 'Nint';
$type = 'N';
$littleEndian = false;
break;
case self::NUMBER_TYPE_LITTLEENDIAN:
$type = 'Vint';
$type = 'V';
$littleEndian = true;
break;
default:
$type = 'Lint';
$type = 'L';
}
// read from the buffer and append/prepend empty bytes for shortened int32
$corrected = $this->read($length);
// Unpack the number
$int = unpack($type, $this->read(4));
$int = unpack($type . 'int', self::extendBinaryString($corrected, 4, $littleEndian));
return $int['int'];
}
@ -498,4 +503,24 @@ class Buffer
return $float['float'];
}
private static function extendBinaryString($input, $length = 4, $littleEndian = null)
{
if (is_null($littleEndian)) {
$littleEndian = self::isLittleEndian();
}
$extension = str_repeat(pack($littleEndian ? 'V' : 'N', 0b0000), $length - strlen($input));
if ($littleEndian) {
return $input . $extension;
} else {
return $extension . $input;
}
}
private static function isLittleEndian()
{
return 0x00FF === current(unpack('v', pack('S', 0x00FF)));
}
}

View File

@ -46,6 +46,11 @@ abstract class Base
$this->options = $options;
}
public function getOptions()
{
return $this->options;
}
/**
* Apply the filter to the data
*

View File

@ -67,6 +67,9 @@ class Stripcolors extends Base
case 'source':
array_walk_recursive($result, [$this, 'stripSource']);
break;
case 'gta5m':
array_walk_recursive($result, [$this, 'stripQuake']);
break;
}
/*$data['filtered'][ $server->id() ] = $result;
@ -93,16 +96,6 @@ class Stripcolors extends Base
$string = preg_replace('#(\^.)#', '', $string);
}
/**
* Strip color codes from Unreal based games
*
* @param string $string
*/
protected function stripUnreal(&$string)
{
$string = preg_replace('/\x1b.../', '', $string);
}
/**
* Strip color codes from Source based games
*
@ -112,4 +105,14 @@ class Stripcolors extends Base
{
$string = strip_tags($string);
}
/**
* Strip color codes from Unreal based games
*
* @param string $string
*/
protected function stripUnreal(&$string)
{
$string = preg_replace('/\x1b.../', '', $string);
}
}

View File

@ -160,6 +160,16 @@ class GameQ
return true;
}
public function getServers()
{
return $this->servers;
}
public function getOptions()
{
return $this->options;
}
/**
* Chainable call to __set, uses set as the actual setter
*

View File

@ -1,5 +1,4 @@
<?php
/**
* This file is part of GameQ.
*
@ -19,15 +18,68 @@
namespace GameQ\Protocols;
use GameQ\Buffer;
use GameQ\Result;
/**
* Class Dayzmod
* Class Armed Assault 3
*
* Rules protocol reference: https://community.bistudio.com/wiki/Arma_3_ServerBrowserProtocol2
*
* @package GameQ\Protocols
* @author Marcel Bößendörfer <m.boessendoerfer@marbis.net>
* @author Austin Bischoff <austin@codebeard.com>
* @author Memphis017 <https://github.com/Memphis017>
*/
class Arma3 extends Armedassault2oa
class Arma3 extends Source
{
// Base DLC names
const BASE_DLC_KART = 'Karts';
const BASE_DLC_MARKSMEN = 'Marksmen';
const BASE_DLC_HELI = 'Helicopters';
const BASE_DLC_CURATOR = 'Curator';
const BASE_DLC_EXPANSION = 'Expansion';
const BASE_DLC_JETS = 'Jets';
const BASE_DLC_ORANGE = 'Laws of War';
const BASE_DLC_ARGO = 'Malden';
const BASE_DLC_TACOPS = 'Tac-Ops';
const BASE_DLC_TANKS = 'Tanks';
const BASE_DLC_CONTACT = 'Contact';
const BASE_DLC_ENOCH = 'Contact (Platform)';
// Special
const BASE_DLC_AOW = 'Art of War';
// Creator DLC names
const CREATOR_DLC_GM = 'Global Mobilization';
const CREATOR_DLC_VN = 'S.O.G. Prairie Fire';
const CREATOR_DLC_CSLA = 'ČSLA - Iron Curtain';
const CREATOR_DLC_WS = 'Western Sahara';
/**
* DLC Flags/Bits as defined in the documentation.
*
* @see https://community.bistudio.com/wiki/Arma_3:_ServerBrowserProtocol3
*
* @var array
*/
protected $dlcFlags = [
0b0000000000000001 => self::BASE_DLC_KART,
0b0000000000000010 => self::BASE_DLC_MARKSMEN,
0b0000000000000100 => self::BASE_DLC_HELI,
0b0000000000001000 => self::BASE_DLC_CURATOR,
0b0000000000010000 => self::BASE_DLC_EXPANSION,
0b0000000000100000 => self::BASE_DLC_JETS,
0b0000000001000000 => self::BASE_DLC_ORANGE,
0b0000000010000000 => self::BASE_DLC_ARGO,
0b0000000100000000 => self::BASE_DLC_TACOPS,
0b0000001000000000 => self::BASE_DLC_TANKS,
0b0000010000000000 => self::BASE_DLC_CONTACT,
0b0000100000000000 => self::BASE_DLC_ENOCH,
0b0001000000000000 => self::BASE_DLC_AOW,
0b0010000000000000 => 'Unknown',
0b0100000000000000 => 'Unknown',
0b1000000000000000 => 'Unknown',
];
/**
* String name of this protocol class
@ -42,4 +94,128 @@ class Arma3 extends Armedassault2oa
* @type string
*/
protected $name_long = "Arma3";
/**
* Query port = client_port + 1
*
* @type int
*/
protected $port_diff = 1;
/**
* Process the rules since Arma3 changed their response for rules
*
* @param Buffer $buffer
*
* @return array
* @throws \GameQ\Exception\Protocol
*/
protected function processRules(Buffer $buffer)
{
// Total number of packets, burn it
$buffer->readInt16();
// Will hold the data string
$data = '';
// Loop until we run out of strings
while ($buffer->getLength()) {
// Burn the delimiters (i.e. \x01\x04\x00)
$buffer->readString();
// Add the data to the string, we are reassembling it
$data .= $buffer->readString();
}
// Restore escaped sequences
$data = str_replace(["\x01\x01", "\x01\x02", "\x01\x03"], ["\x01", "\x00", "\xFF"], $data);
// Make a new buffer with the reassembled data
$responseBuffer = new Buffer($data);
// Kill the old buffer, should be empty
unset($buffer, $data);
// Set the result to a new result instance
$result = new Result();
// Get results
$result->add('rules_protocol_version', $responseBuffer->readInt8()); // read protocol version
$result->add('overflow', $responseBuffer->readInt8()); // Read overflow flags
$dlcByte = $responseBuffer->readInt8(); // Grab DLC byte 1 and use it later
$dlcByte2 = $responseBuffer->readInt8(); // Grab DLC byte 2 and use it later
$dlcBits = ($dlcByte2 << 8) | $dlcByte; // concatenate DLC bits to 16 Bit int
// Grab difficulty so we can man handle it...
$difficulty = $responseBuffer->readInt8();
// Process difficulty
$result->add('3rd_person', $difficulty >> 7);
$result->add('advanced_flight_mode', ($difficulty >> 6) & 1);
$result->add('difficulty_ai', ($difficulty >> 3) & 3);
$result->add('difficulty_level', $difficulty & 3);
unset($difficulty);
// Crosshair
$result->add('crosshair', $responseBuffer->readInt8());
// Loop over the base DLC bits so we can pull in the info for the DLC (if enabled)
foreach ($this->dlcFlags as $dlcFlag => $dlcName) {
// Check that the DLC bit is enabled
if (($dlcBits & $dlcFlag) === $dlcFlag) {
// Add the DLC to the list
$result->addSub('dlcs', 'name', $dlcName);
$result->addSub('dlcs', 'hash', dechex($responseBuffer->readInt32()));
}
}
// Read the mount of mods, these include DLC as well as Creator DLC and custom modifications
$modCount = $responseBuffer->readInt8();
// Add mod count
$result->add('mod_count', $modCount);
// Loop over the mods
while ($modCount) {
// Read the mods hash
$result->addSub('mods', 'hash', dechex($responseBuffer->readInt32()));
// Get the information byte containing DLC flag and steamId length
$infoByte = $responseBuffer->readInt8();
// Determine isDLC by flag, first bit in upper nibble
$result->addSub('mods', 'dlc', ($infoByte & 0b00010000) === 0b00010000);
// Read the steam id of the mod/CDLC (might be less than 4 bytes)
$result->addSub('mods', 'steam_id', $responseBuffer->readInt32($infoByte & 0x0F));
// Read the name of the mod
$result->addSub('mods', 'name', $responseBuffer->readPascalString(0, true) ?: 'Unknown');
--$modCount;
}
// No longer needed
unset($dlcByte, $dlcByte2, $dlcBits);
// Get the signatures count
$signatureCount = $responseBuffer->readInt8();
$result->add('signature_count', $signatureCount);
// Make signatures array
$signatures = [];
// Loop until we run out of signatures
for ($x = 0; $x < $signatureCount; $x++) {
$signatures[] = $responseBuffer->readPascalString(0, true);
}
// Add as a simple array
$result->add('signatures', $signatures);
unset($responseBuffer, $signatureCount, $signatures, $x);
return $result->fetch();
}
}

View File

@ -1,5 +1,4 @@
<?php
/**
* This file is part of GameQ.
*

View File

@ -35,7 +35,7 @@ class Killingfloor extends Unreal2
*
* @type string
*/
protected $name = 'killingfloor';
protected $name = 'killing floor';
/**
* Longer string name of this protocol class

View File

@ -32,7 +32,7 @@ class Killingfloor2 extends Source
*
* @type string
*/
protected $name = 'killingfloor2';
protected $name = 'killing floor 2';
/**
* Longer string name of this protocol class

View File

@ -18,6 +18,8 @@
namespace GameQ\Protocols;
use GameQ\Buffer;
/**
* Class Rust
*
@ -40,4 +42,23 @@ class Rust extends Source
* @type string
*/
protected $name_long = "Rust";
/**
* Overload so we can get max players from mp of keywords and num players from cp keyword
*
* @param Buffer $buffer
*/
protected function processDetails(Buffer $buffer)
{
$results = parent::processDetails($buffer);
if ($results['keywords']) {
//get max players from mp of keywords and num players from cp keyword
preg_match_all('/(mp|cp)([\d]+)/', $results['keywords'], $matches);
$results['max_players'] = intval($matches[2][0]);
$results['num_players'] = intval($matches[2][1]);
}
return $results;
}
}

View File

@ -41,9 +41,9 @@ class Sevendaystodie extends Source
protected $name_long = "7 Days to Die";
/**
* query_port = client_port + 1
* query_port = client_port + 0
*
* @type int
*/
protected $port_diff = 1;
protected $port_diff = 0;
}

View File

@ -1,5 +1,4 @@
<?php
/**
* This file is part of GameQ.
*
@ -123,8 +122,7 @@ class Teamspeak3 extends Protocol
{
// Check to make sure we have a query_port because it is required
if (
!isset($this->options[Server::SERVER_OPTIONS_QUERY_PORT])
if (!isset($this->options[Server::SERVER_OPTIONS_QUERY_PORT])
|| empty($this->options[Server::SERVER_OPTIONS_QUERY_PORT])
) {
throw new Exception(__METHOD__ . " Missing required setting '" . Server::SERVER_OPTIONS_QUERY_PORT . "'.");

View File

@ -19,10 +19,9 @@
namespace GameQ\Protocols;
/**
* Class Valheim
* Valheim Protocol Class
*
* @package GameQ\Protocols
*
*/
class Valheim extends Source
{
@ -32,10 +31,18 @@ class Valheim extends Source
* @type string
*/
protected $name = 'valheim';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Valheim";
/**
* query_port = client_port + 1
*
* @type int
*/
protected $port_diff = 1;
}

View File

@ -119,6 +119,31 @@ abstract class Core
$this->blocking = false;
}
public function getTransport()
{
return $this->transport;
}
public function getIp()
{
return $this->ip;
}
public function getPort()
{
return $this->port;
}
public function getTimeout()
{
return $this->timeout;
}
public function getBlocking()
{
return $this->blocking;
}
/**
* Create a new socket
*

View File

@ -27,7 +27,6 @@ use GameQ\Exception\Server as Exception;
*/
class Server
{
/*
* Server array keys
*/
@ -203,13 +202,18 @@ class Server
);
}
// Validate the IPv4 value, if FALSE is not a valid IP, maybe a hostname. Try to resolve
if (!filter_var($this->ip, FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV4,])
&& $this->ip === gethostbyname($this->ip)
) {
// Validate the IPv4 value, if FALSE is not a valid IP, maybe a hostname.
if (! filter_var($this->ip, FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV4,])) {
// Try to resolve the hostname to IPv4
$resolved = gethostbyname($this->ip);
// When gethostbyname() fails it returns the original string
// so if ip and the result from gethostbyname() are equal this failed.
throw new Exception("Unable to resolve the host '{$this->ip}' to an IP address.");
if ($this->ip === $resolved) {
// so if ip and the result from gethostbyname() are equal this failed.
throw new Exception("Unable to resolve the host '{$this->ip}' to an IP address.");
} else {
$this->ip = $resolved;
}
}
}
}
@ -258,6 +262,11 @@ class Server
return (array_key_exists($key, $this->options)) ? $this->options[$key] : null;
}
public function getOptions()
{
return $this->options;
}
/**
* Get the ID for this server
*

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -3,84 +3,107 @@
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace GameQ;
use GameQ\Exception\Protocol as Exception;
/**
* Provide an interface for easy manipulation of a server response
* Class Buffer
*
* @author Aidan Lister <aidan@php.net>
* @author Tom Buskens <t.buskens@deviation.nl>
* @version $Revision: 1.4 $
* Read specific byte sequences from a provided string or Buffer
*
* @package GameQ
*
* @author Austin Bischoff <austin@codebeard.com>
* @author Aidan Lister <aidan@php.net>
* @author Tom Buskens <t.buskens@deviation.nl>
*/
class GameQ_Buffer
class Buffer
{
/**
* Constants for the byte code types we need to read as
*/
const NUMBER_TYPE_BIGENDIAN = 'be',
NUMBER_TYPE_LITTLEENDIAN = 'le',
NUMBER_TYPE_MACHINE = 'm';
/**
* The number type we use for reading integers. Defaults to little endian
*
* @type string
*/
private $number_type = self::NUMBER_TYPE_LITTLEENDIAN;
/**
* The original data
*
* @var string
* @access public
* @type string
*/
private $data;
/**
* The original data
*
* @var string
* @access public
* @type int
*/
private $length;
/**
* Position of pointer
*
* @var string
* @access public
* @type int
*/
private $index = 0;
/**
* Constructor
*
* @param string|array $response The data
* @param string $data
* @param string $number_type
*/
public function __construct($data)
public function __construct($data, $number_type = self::NUMBER_TYPE_LITTLEENDIAN)
{
$this->data = $data;
$this->number_type = $number_type;
$this->data = $data;
$this->length = strlen($data);
}
/**
* Return all the data
*
* @return string|array The data
* @return string The data
*/
public function getData()
{
return $this->data;
}
/**
* Return data currently in the buffer
*
* @return string|array The data currently in the buffer
* @return string The data currently in the buffer
*/
public function getBuffer()
{
return substr($this->data, $this->index);
}
@ -91,19 +114,23 @@ class GameQ_Buffer
*/
public function getLength()
{
return max($this->length - $this->index, 0);
}
/**
* Read from the buffer
*
* @param int $length Length of data to read
* @return string The data read
* @param int $length
*
* @return string
* @throws \GameQ\Exception\Protocol
*/
public function read($length = 1)
{
if (($length + $this->index) > $this->length) {
throw new GameQ_ProtocolsException('Unable to read length={$length} from buffer. Bad protocol format or return?');
throw new Exception("Unable to read length={$length} from buffer. Bad protocol format or return?");
}
$string = substr($this->data, $this->index, $length);
@ -118,13 +145,14 @@ class GameQ_Buffer
* Unlike the other read functions, this function actually removes
* the character from the buffer.
*
* @return string The data read
* @return string
*/
public function readLast()
{
$len = strlen($this->data);
$string = $this->data{strlen($this->data) - 1};
$this->data = substr($this->data, 0, $len - 1);
$len = strlen($this->data);
$string = $this->data[strlen($this->data) - 1];
$this->data = substr($this->data, 0, $len - 1);
$this->length -= 1;
return $string;
@ -133,24 +161,24 @@ class GameQ_Buffer
/**
* Look at the buffer, but don't remove
*
* @param int $length Length of data to read
* @return string The data read
* @param int $length
*
* @return string
*/
public function lookAhead($length = 1)
{
$string = substr($this->data, $this->index, $length);
return $string;
return substr($this->data, $this->index, $length);
}
/**
* Skip forward in the buffer
*
* @param int $length Length of data to skip
* @return void
* @param int $length
*/
public function skip($length = 1)
{
$this->index += $length;
}
@ -158,21 +186,22 @@ class GameQ_Buffer
* Jump to a specific position in the buffer,
* will not jump past end of buffer
*
* @param int $index Position to go to
* @return void
* @param $index
*/
public function jumpto($index)
{
$this->index = min($index, $this->length - 1);
}
/**
* Get the current pointer position
*
* @return int The current pointer position
* @return int
*/
public function getPosition()
{
return $this->index;
}
@ -181,11 +210,14 @@ class GameQ_Buffer
*
* If not found, return everything
*
* @param string $delim Read until this character is reached
* @return string The data read
* @param string $delim
*
* @return string
* @throws \GameQ\Exception\Protocol
*/
public function readString($delim = "\x00")
{
// Get position of delimiter
$len = strpos($this->data, $delim, min($this->index, $this->length));
@ -204,13 +236,15 @@ class GameQ_Buffer
/**
* Reads a pascal string from the buffer
*
* @paran int $offset Number of bits to cut off the end
* @param bool $read_offset True if the data after the offset is
* to be read
* @return string The data read
* @param int $offset Number of bits to cut off the end
* @param bool $read_offset True if the data after the offset is to be read
*
* @return string
* @throws \GameQ\Exception\Protocol
*/
public function readPascalString($offset = 0, $read_offset = false)
{
// Get the proper offset
$len = $this->readInt8();
$offset = max($len - $offset, 0);
@ -218,8 +252,7 @@ class GameQ_Buffer
// Read the data
if ($read_offset) {
return $this->read($offset);
}
else {
} else {
return substr($this->read($len), 0, $offset);
}
}
@ -229,16 +262,22 @@ class GameQ_Buffer
*
* If not found, return everything
*
* @param array $delims Read until these characters are reached
* @return string The data read
* @param $delims
* @param null|string &$delimfound
*
* @return string
* @throws \GameQ\Exception\Protocol
*
* @todo: Check to see if this is even used anymore
*/
public function readStringMulti($delims, &$delimfound = null)
{
// Get position of delimiters
$pos = array();
$pos = [];
foreach ($delims as $delim) {
if ($p = strpos($this->data, $delim, min($this->index, $this->length))) {
$pos[] = $p;
if ($index = strpos($this->data, $delim, min($this->index, $this->length))) {
$pos[] = $index;
}
}
@ -256,141 +295,232 @@ class GameQ_Buffer
}
/**
* Read a 32-bit unsigned integer
* Read an 8-bit unsigned integer
*
* @return int
* @throws \GameQ\Exception\Protocol
*/
public function readInt32()
public function readInt8()
{
$int = unpack('Lint', $this->read(4));
$int = unpack('Cint', $this->read(1));
return $int['int'];
}
/**
* Read a 32-bit signed integer
* Read and 8-bit signed integer
*
* @return int
* @throws \GameQ\Exception\Protocol
*/
public function readInt32Signed()
public function readInt8Signed()
{
$int = unpack('lint', $this->read(4));
$int = unpack('cint', $this->read(1));
return $int['int'];
}
/**
* Read a 16-bit unsigned integer
*
* @return int
* @throws \GameQ\Exception\Protocol
*/
public function readInt16()
{
$int = unpack('Sint', $this->read(2));
// Change the integer type we are looking up
switch ($this->number_type) {
case self::NUMBER_TYPE_BIGENDIAN:
$type = 'nint';
break;
case self::NUMBER_TYPE_LITTLEENDIAN:
$type = 'vint';
break;
default:
$type = 'Sint';
}
$int = unpack($type, $this->read(2));
return $int['int'];
}
/**
* Read a 16-bit signed integer
*
* @return int
* @throws \GameQ\Exception\Protocol
*/
public function readInt16Signed()
{
$int = unpack('sint', $this->read(2));
return $int['int'];
}
/**
* Read a 16-bit unsigned little endian integer
*/
public function readInt16LE()
{
$int = unpack('vint', $this->read(2));
return $int['int'];
}
// Read the data into a string
$string = $this->read(2);
/**
* Read a 16-bit unsigned big endian integer
*/
public function readInt16BE()
{
$int = unpack('nint', $this->read(2));
return $int['int'];
}
/**
* Read an int8 from the buffer
*
* @return int The data read
*/
public function readInt8()
{
return ord($this->read(1));
}
/**
* Read an float32 from the buffer
*
* @return int The data read
*/
public function readFloat32()
{
$float = unpack('ffloat', $this->read(4));
return $float['float'];
}
/**
* Conversion to float
*
* @access public
* @param string $string String to convert
* @return float 32 bit float
*/
public function toFloat($string)
{
// Check length
if (strlen($string) !== 4) {
return false;
// For big endian we need to reverse the bytes
if ($this->number_type == self::NUMBER_TYPE_BIGENDIAN) {
$string = strrev($string);
}
// Convert
$float = unpack('ffloat', $string);
return $float['float'];
$int = unpack('sint', $string);
unset($string);
return $int['int'];
}
/**
* Conversion to integer
* Read a 32-bit unsigned integer
*
* @access public
* @param string $string String to convert
* @param int $bits Number of bits
* @return int Integer according to type
* @return int
* @throws \GameQ\Exception\Protocol
*/
public function toInt($string, $bits = 8)
public function readInt32($length = 4)
{
// Check length
if (strlen($string) !== ($bits / 8)) {
return false;
}
// Convert
switch($bits) {
// 8 bit unsigned
case 8:
$int = ord($string);
// Change the integer type we are looking up
$littleEndian = null;
switch ($this->number_type) {
case self::NUMBER_TYPE_BIGENDIAN:
$type = 'N';
$littleEndian = false;
break;
// 16 bit unsigned
case 16:
$int = unpack('Sint', $string);
$int = $int['int'];
case self::NUMBER_TYPE_LITTLEENDIAN:
$type = 'V';
$littleEndian = true;
break;
// 32 bit unsigned
case 32:
$int = unpack('Lint', $string);
$int = $int['int'];
break;
// Invalid type
default:
$int = false;
break;
$type = 'L';
}
// read from the buffer and append/prepend empty bytes for shortened int32
$corrected = $this->read($length);
// Unpack the number
$int = unpack($type . 'int', self::extendBinaryString($corrected, 4, $littleEndian));
return $int['int'];
}
/**
* Read a 32-bit signed integer
*
* @return int
* @throws \GameQ\Exception\Protocol
*/
public function readInt32Signed()
{
// Read the data into a string
$string = $this->read(4);
// For big endian we need to reverse the bytes
if ($this->number_type == self::NUMBER_TYPE_BIGENDIAN) {
$string = strrev($string);
}
$int = unpack('lint', $string);
unset($string);
return $int['int'];
}
/**
* Read a 64-bit unsigned integer
*
* @return int
* @throws \GameQ\Exception\Protocol
*/
public function readInt64()
{
// We have the pack 64-bit codes available. See: http://php.net/manual/en/function.pack.php
if (version_compare(PHP_VERSION, '5.6.3') >= 0 && PHP_INT_SIZE == 8) {
// Change the integer type we are looking up
switch ($this->number_type) {
case self::NUMBER_TYPE_BIGENDIAN:
$type = 'Jint';
break;
case self::NUMBER_TYPE_LITTLEENDIAN:
$type = 'Pint';
break;
default:
$type = 'Qint';
}
$int64 = unpack($type, $this->read(8));
$int = $int64['int'];
unset($int64);
} else {
if ($this->number_type == self::NUMBER_TYPE_BIGENDIAN) {
$high = $this->readInt32();
$low = $this->readInt32();
} else {
$low = $this->readInt32();
$high = $this->readInt32();
}
// We have to determine the number via bitwise
$int = ($high << 32) | $low;
unset($low, $high);
}
return $int;
}
/**
* Read a 32-bit float
*
* @return float
* @throws \GameQ\Exception\Protocol
*/
public function readFloat32()
{
// Read the data into a string
$string = $this->read(4);
// For big endian we need to reverse the bytes
if ($this->number_type == self::NUMBER_TYPE_BIGENDIAN) {
$string = strrev($string);
}
$float = unpack('ffloat', $string);
unset($string);
return $float['float'];
}
private static function extendBinaryString($input, $length = 4, $littleEndian = null)
{
if (is_null($littleEndian)) {
$littleEndian = self::isLittleEndian();
}
$extension = str_repeat(pack($littleEndian ? 'V' : 'N', 0b0000), $length - strlen($input));
if ($littleEndian) {
return $input . $extension;
} else {
return $extension . $input;
}
}
private static function isLittleEndian()
{
return 0x00FF === current(unpack('v', pack('S', 0x00FF)));
}
}

View File

@ -1,34 +0,0 @@
<?php
/**
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Generic function to make extending shorter
*
* @author Austin Bischoff <austin@codebeard.com>
*/
abstract class GameQ_Filters extends GameQ_Filters_Core {}
/**
* GameQ Filters Exception
*
* Allows for a level of exception handling incase there is an issue/error within
* a filter or a required dependency has not been met.
*
* @author Austin Bischoff <austin@codebeard.com>
*/
class GameQ_FiltersException extends Exception {}

View File

@ -1,55 +0,0 @@
<?php
/**
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Abstract class which all filters must inherit
*
* @author Austin Bischoff <austin@codebeard.com>
*/
abstract class GameQ_Filters_Core
{
protected $params = array();
/**
* Constructor, receives parameters
*
* @param array $params Filter parameters
*/
function __construct($params)
{
if(is_array($params))
{
foreach ($params as $key => $param)
{
$this->params[$key] = $param;
}
}
else
{
$this->params = $params;
}
}
/**
* Actually apply the filter to the passed results
*
* @param array $results
* @param GameQ_Protocols_Core $protocol_instance
*/
abstract public function filter($results, GameQ_Protocols_Core $protocol_instance);
}

View File

@ -1,193 +0,0 @@
<?php
/**
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* This filter makes sure a fixed set of properties (i.e. gq_) is always available regardless of protocol
*
* @author Austin Bischoff <austin@codebeard.com>
*/
class GameQ_Filters_Normalise extends GameQ_Filters
{
/**
* Default normalization items. Can be overwritten on a protocol basis.
*
* @var array
*/
protected $normalize = array(
// General
'general' => array(
// target => source
'dedicated' => array('listenserver', 'dedic', 'bf2dedicated', 'netserverdedicated', 'bf2142dedicated'),
'gametype' => array('ggametype', 'sigametype', 'matchtype'),
'hostname' => array('svhostname', 'servername', 'siname', 'name'),
'mapname' => array('map', 'simap'),
'maxplayers' => array('svmaxclients', 'simaxplayers', 'maxclients'),
'mod' => array('game', 'gamedir', 'gamevariant'),
'numplayers' => array('clients', 'sinumplayers'),
'password' => array('protected', 'siusepass', 'sineedpass', 'pswrd', 'gneedpass', 'auth'),
'players' => array('players'),
'teams' => array('team'),
),
// Indvidual
'player' => array(
'name' => array('nick', 'player', 'playername', 'name'),
'kills' => array('kills'),
'deaths' => array('deaths'),
'score' => array('kills', 'frags', 'skill', 'score'),
'ping' => array('ping'),
),
// Team
'team' => array(
'name' => array('name', 'teamname', 'team_t'),
'score' => array('score', 'score_t'),
),
);
/**
* Normalize the server data
* @see GameQ_Filters_Core::filter()
*/
public function filter($data, GameQ_Protocols_Core $protocol_instance)
{
$result = array();
// No data passed so something bad happened
if(empty($data))
{
return $result;
}
// Here we check to see if we override these defaults.
if(($normalize = $protocol_instance->getNormalize()) !== FALSE)
{
// Merge this stuff in
$this->normalize = array_merge_recursive($this->normalize, $normalize);
}
// normalize the general items
$result = $this->normalize($data, 'general');
// normalize players
if (isset($result['gq_players']) && is_array($result['gq_players']))
{
// Don't rename the players array
$result['players'] = $result['gq_players'];
foreach ($result['players'] as $key => $player)
{
$result['players'][$key] = array_merge($player, $this->normalize($player, 'player'));
}
$result['gq_numplayers'] = count($result['players']);
}
else
{
$result['players'] = array();
}
// normalize teams
if (isset($result['gq_teams']) && is_array($result['gq_teams']))
{
// Don't rename the teams array
$result['teams'] = $result['gq_teams'];
foreach ($result['teams'] as $key => $team)
{
$result['teams'][$key] = array_merge($team, $this->normalize($team, 'team'));
}
$result['gq_numteams'] = count($result['teams']);
}
else
{
$result['teams'] = array();
}
unset($result['gq_players'], $result['gq_teams']);
// Merge and sort array
$result = (array_merge($data, $result));
ksort($result);
return $result;
}
/**
* normalize an array
*
* @param array $data The data to normalize
* @param array $properties The properties we want to normalize
* @return array A normalized array
*/
private function normalize($data, $properties)
{
// Make sure this is not empty
if(!isset($this->normalize[$properties]))
{
// We just return empty array
return array();
}
$props = $this->normalize[$properties];
// Create a new array, with all the specified variables
$new = $this->fill($props);
foreach ($data as $var => $value)
{
// normalize values
$stripped = strtolower(str_replace('_', '', $var));
foreach ($props as $target => $sources)
{
if ($target == $stripped or in_array($stripped, $sources))
{
$new['gq_' . $target] = $value;
//unset($vars[$target]);
break;
}
}
}
return $new;
}
/**
* Fill array with array keys
*
* @param array $vars The array keys
* @param mixed $val Value of each key
* @return array An array filled with keys
*/
private function fill($vars, $val = false)
{
$data = array();
foreach ($vars as $target => $source)
{
$data['gq_' . $target] = $val;
}
return $data;
}
}

View File

@ -1,76 +0,0 @@
<?php
/**
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Strip color codes from specific protocol types. This code was adapted from the original filter class
*
* @author Austin Bischoff <austin@codebeard.com>
*/
class GameQ_Filters_Stripcolor extends GameQ_Filters
{
/**
* Strip all the color junk from returns
* @see GameQ_Filters_Core::filter()
*/
public function filter($data, GameQ_Protocols_Core $protocol_instance)
{
// Check the type of protocol
switch($protocol_instance->protocol())
{
case 'quake2':
case 'quake3':
case 'doom3':
array_walk_recursive($data, array($this, 'stripQuake'));
break;
case 'unreal2':
case 'ut3':
case 'gamespy3': //not sure if gamespy3 supports ut colors but won't hurt
case 'gamespy2':
array_walk_recursive($data, array($this, 'stripUT'));
break;
default:
break;
}
return $data;
}
/**
* Strips quake color tags
*
* @param $string string String to strip
* @param $key string Array key
*/
protected function stripQuake(&$string, $key)
{
$string = preg_replace('#(\^.)#', '', $string);
}
/**
* Strip UT color tags
*
* @param $string string String to strip
* @param $key string Array key
*/
protected function stripUT(&$string, $key)
{
$string = preg_replace('/\x1b.../', '', $string);
}
}

View File

@ -1,37 +0,0 @@
<?php
/**
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Generic function to make extending shorter
*
* @author Austin Bischoff <austin@codebeard.com>
*/
abstract class GameQ_Protocols extends GameQ_Protocols_Core
{
}
/**
* GameQ Protocol Exception
*
* Allows for another level of exception handling when doing loops. Makes it possible to recover and continue
* when there is an exception within one of the protocol classes.
*
* @author Austin Bischoff <austin@codebeard.com>
*/
class GameQ_ProtocolsException extends Exception {}

View File

@ -1,44 +0,0 @@
<?php
/**
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* 7 Days to Die Protocol Class
*
* @author Austin Bischoff <austin@codebeard.com>
*/
class GameQ_Protocols_7d2d extends GameQ_Protocols_Source
{
protected $name = "7d2d";
protected $name_long = "7 Days to Die";
/**
* Overload for client port
*
* @param string $ip
* @param integer $port
* @param array $options
*/
public function __construct($ip = FALSE, $port = FALSE, $options = array())
{
// Got to do this first
parent::__construct($ip, $port, $options);
// Correct the client port since query_port = client_port + 1
$this->port_client(($this->port_client() - 1));
}
}

View File

@ -19,24 +19,24 @@
namespace GameQ\Protocols;
/**
* Class Dods
* Class Aapg
*
* @package GameQ\Protocols
* @author Austin Bischoff <austin@codebeard.com>
*/
class Dods extends Source
class Aapg extends Aa3
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'dods';
protected $name = 'aapg';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Day of Defeat: Source";
protected $name_long = "America's Army: Proving Grounds";
}

View File

@ -19,27 +19,30 @@
namespace GameQ\Protocols;
/**
* Class Dod
*
* Based off of CS 1.6
* Avorion Protocol Class
*
* @package GameQ\Protocols
* @author Austin Bischoff <austin@codebeard.com>
*/
class Dod extends Cs16
class Avorion extends Source
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'dod';
protected $name = 'avorion';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Day of Defeat";
protected $name_long = "Avorion";
/**
* query_port = client_port + 1
*
* @type int
* protected $port_diff = 1;
*/
}

View File

@ -19,26 +19,26 @@
namespace GameQ\Protocols;
/**
* Class Ns2
* Barotrauma Protocol Class
*
* @package GameQ\Protocols
* @author Austin Bischoff <austin@codebeard.com>
* @author Jesse Lukas <eranio@g-one.org>
*/
class Ns2 extends Source
class Barotrauma extends Source
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'ns2';
protected $name = 'barotrauma';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Natural Selection 2";
protected $name_long = "Barotrauma";
/**
* query_port = client_port + 1

View File

@ -19,25 +19,24 @@
namespace GameQ\Protocols;
/**
* Class Crysis2
* Blackmesa Protocol Class
*
* @package GameQ\Protocols
*
* @author Wilson Jesus <>
* @author Jesse Lukas <eranio@g-one.org>
*/
class Crysis2 extends Gamespy3
class Blackmesa extends Source
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'crysis2';
protected $name = 'blackmesa';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Crysis 2";
protected $name_long = "Black Mesa";
}

View File

@ -19,25 +19,24 @@
namespace GameQ\Protocols;
/**
* Call of Duty Protocol Class
* Citadel Protocol Class
*
* @package GameQ\Protocols
*
* @author Wilson Jesus <>
* @author Jesse Lukas <eranio@g-one.org>
*/
class Cod extends Quake3
class Citadel extends Source
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'cod';
protected $name = 'citadel';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Call of Duty";
protected $name_long = "Citadel";
}

View File

@ -22,74 +22,67 @@ use GameQ\Buffer;
use GameQ\Result;
/**
* Warsow Protocol Class
* Call of Duty: Modern Warfare 2 Protocol Class
*
* @package GameQ\Protocols
* @author Austin Bischoff <austin@codebeard.com>
* @author Wilson Jesus <>
*/
class Warsow extends Quake3
class Codmw2 extends Quake3
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'warsow';
protected $name = 'codmw2';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Warsow";
protected $name_long = "Call of Duty: Modern Warfare 2";
/**
* The client join link
*
* @type string
*/
protected $join_link = "warsow://%s:%d/";
/**
* Handle player info, different than quake3 base
*
* @param Buffer $buffer
*
* @return array
* @throws \GameQ\Exception\Protocol
*/
protected function processPlayers(Buffer $buffer)
{
// Set the result to a new result instance
$result = new Result();
// Temporarily cache players in order to remove last
$players = [];
// Loop until we are out of data
while ($buffer->getLength()) {
// Make a new buffer with this block
$playerInfo = new Buffer($buffer->readString("\x0A"));
// Add player info
$result->addPlayer('frags', $playerInfo->readString("\x20"));
$result->addPlayer('ping', $playerInfo->readString("\x20"));
// Read player info
$player = [
'frags' => $playerInfo->readString("\x20"),
'ping' => $playerInfo->readString("\x20"),
];
// Skip first "
$playerInfo->skip(1);
// Add player name, encoded
$result->addPlayer('name', utf8_encode(trim(($playerInfo->readString('"')))));
$player['name'] = utf8_encode(trim(($playerInfo->readString('"'))));
// Skip space
$playerInfo->skip(1);
// Add team
$result->addPlayer('team', $playerInfo->read());
// Clear
unset($playerInfo);
// Add player
$players[] = $player;
}
// Remove last, empty player
array_pop($players);
// Set the result to a new result instance
$result = new Result();
// Add players
$result->add('players', $players);
// Add Playercount
$result->add('clients', count($players));
// Clear
unset($buffer);
unset($buffer, $players);
return $result->fetch();
}

View File

@ -19,11 +19,11 @@
namespace GameQ\Protocols;
/**
* Unreal Tournament Protocol Class
* Hidden & Dangerous 2 Protocol Class
*
* @author Austin Bischoff <austin@codebeard.com>
* @author Wilson Jesus <>
*/
class Ut extends Gamespy
class Had2 extends Gamespy2
{
/**
@ -31,21 +31,21 @@ class Ut extends Gamespy
*
* @type string
*/
protected $name = 'ut';
protected $name = 'had2';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Unreal Tournament";
protected $name_long = "Hidden & Dangerous 2";
/**
* query_port = client_port + 1
* The difference between the client port and query port
*
* @type int
*/
protected $port_diff = 1;
protected $port_diff = 3;
/**
* Normalize settings for this protocol
@ -56,7 +56,7 @@ class Ut extends Gamespy
// General
'general' => [
// target => source
'dedicated' => 'dedicated',
'dedicated' => 'isdedicated',
'gametype' => 'gametype',
'hostname' => 'hostname',
'mapname' => 'mapname',
@ -66,8 +66,10 @@ class Ut extends Gamespy
],
// Individual
'player' => [
'name' => 'name',
'score' => 'frags',
'name' => 'player',
'score' => 'score',
'deaths' => 'deaths',
'ping' => 'ping',
],
];
}

View File

@ -19,25 +19,24 @@
namespace GameQ\Protocols;
/**
* Class Crysis
* Halo: Combat Evolved Protocol Class
*
* @package GameQ\Protocols
*
* @author Wilson Jesus <>
* @author Wilson Jesus <>
*/
class Crysis extends Gamespy3
class Halo extends Gamespy2
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'crysis';
protected $name = 'halo';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Crysis";
protected $name_long = "Halo: Combat Evolved";
}

View File

@ -19,24 +19,25 @@
namespace GameQ\Protocols;
/**
* Class Css
* Class Hl1
*
* @package GameQ\Protocols
* @author Austin Bischoff <austin@codebeard.com>
* @author Jesse Lukas <eranio@g-one.org>
*/
class Css extends Source
class Hl1 extends Source
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'css';
protected $name = 'hl1';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Counter-Strike: Source";
protected $name_long = "Half Life";
}

View File

@ -19,70 +19,50 @@
namespace GameQ\Protocols;
/**
* Class Battlefield 1942
* Class Hll
*
* @package GameQ\Protocols
* @author Austin Bischoff <austin@codebeard.com>
* @author Wilson Jesus <>
*/
class Bf1942 extends Gamespy
class Hll extends Source
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'bf1942';
protected $name = 'hll';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Battlefield 1942";
protected $name_long = "Hell Let Loose";
/**
* query_port = client_port + 8433
* 23000 = 14567 + 8433
* query_port = client_port + 15
* 64015 = 64000 + 15
*
* @type int
*/
protected $port_diff = 8433;
/**
* The client join link
*
* @type string
*/
protected $join_link = "bf1942://%s:%d";
protected $port_diff = 15;
/**
* Normalize settings for this protocol
*
* @type array
*/
protected $normalize = [
// General
/*protected $normalize = [
'general' => [
// target => source
'dedicated' => 'dedicated',
'gametype' => 'gametype',
'hostname' => 'hostname',
'servername' => 'hostname',
'mapname' => 'mapname',
'maxplayers' => 'maxplayers',
'numplayers' => 'numplayers',
'password' => 'password',
],
// Individual
'player' => [
'name' => 'playername',
'kills' => 'kills',
'deaths' => 'deaths',
'ping' => 'ping',
'score' => 'score',
],
'team' => [
'name' => 'teamname',
],
];
];*/
}

View File

@ -19,25 +19,25 @@
namespace GameQ\Protocols;
/**
* Wolfenstein Enemy Territory Protocol Class
* Kingpin: Life of Crime Protocol Class
*
* @package GameQ\Protocols
*
* @author Wilson Jesus <>
*/
class Et extends Quake3
class Kingpin extends Quake2
{
/**
* String name of this protocol class
*
* @type string
*/
protected $name = 'et';
protected $name = 'kingpin';
/**
* Longer string name of this protocol class
*
* @type string
*/
protected $name_long = "Wolfenstein Enemy Territory";
protected $name_long = "Kingpin: Life of Crime";
}

Some files were not shown because too many files have changed in this diff Show More