mirror of
https://github.com/easy-wi/developer.git
synced 2025-02-20 11:23:28 +08:00
FIX #1061 Update GameQ
This commit is contained in:
parent
82606c11a5
commit
e37e045877
4
third_party/gameq/GameQ/GameQ.php
vendored
4
third_party/gameq/GameQ/GameQ.php
vendored
@ -597,9 +597,9 @@ class GameQ
|
||||
}
|
||||
|
||||
// Now add some default stuff
|
||||
$results['gq_address'] = $server->ip();
|
||||
$results['gq_address'] = (isset($results['gq_address'])) ? $results['gq_address'] : $server->ip();
|
||||
$results['gq_port_client'] = $server->portClient();
|
||||
$results['gq_port_query'] = $server->portQuery();
|
||||
$results['gq_port_query'] = (isset($results['gq_port_query'])) ? $results['gq_port_query'] : $server->portQuery();
|
||||
$results['gq_protocol'] = $server->protocol()->getProtocol();
|
||||
$results['gq_type'] = (string)$server->protocol();
|
||||
$results['gq_name'] = $server->protocol()->nameLong();
|
||||
|
4
third_party/gameq/GameQ/Protocol.php
vendored
4
third_party/gameq/GameQ/Protocol.php
vendored
@ -71,6 +71,10 @@ abstract class Protocol
|
||||
|
||||
const TRANSPORT_TCP = 'tcp';
|
||||
|
||||
const TRANSPORT_SSL = 'ssl';
|
||||
|
||||
const TRANSPORT_TLS = 'tls';
|
||||
|
||||
/**
|
||||
* Short name of the protocol
|
||||
*
|
||||
|
13
third_party/gameq/GameQ/Protocols/Arma3.php
vendored
13
third_party/gameq/GameQ/Protocols/Arma3.php
vendored
@ -38,7 +38,11 @@ class Arma3 extends Source
|
||||
const DLC_KARTS = 1,
|
||||
DLC_MARKSMEN = 2,
|
||||
DLC_HELICOPTERS = 4,
|
||||
DLC_APEX = 16;
|
||||
DLC_APEX = 16,
|
||||
DLC_JETS = 32,
|
||||
DLC_LAWS = 64,
|
||||
DLC_TACOPS = 128,
|
||||
DLC_TANKS = 256;
|
||||
|
||||
/**
|
||||
* Defines the names for the specific game DLCs
|
||||
@ -50,9 +54,12 @@ class Arma3 extends Source
|
||||
self::DLC_MARKSMEN => 'Marksmen',
|
||||
self::DLC_HELICOPTERS => 'Helicopters',
|
||||
self::DLC_APEX => 'Apex',
|
||||
self::DLC_JETS => 'Jets',
|
||||
self::DLC_LAWS => 'Laws of War',
|
||||
self::DLC_TACOPS => 'Tac-Ops',
|
||||
self::DLC_TANKS => 'Tanks'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
@ -133,7 +140,7 @@ class Arma3 extends Source
|
||||
// Next are the dlc bits so loop over the dlcBit so we can determine which DLC's are running
|
||||
for ($x = 1; $x <= $dlcBit; $x *= 2) {
|
||||
// Enabled, add it to the list
|
||||
if ($x & $dlcBit) {
|
||||
if ($x & $dlcBit && array_key_exists($x, $this->dlcNames)) {
|
||||
$result->addSub('dlcs', 'name', $this->dlcNames[$x]);
|
||||
$result->addSub('dlcs', 'hash', dechex($responseBuffer->readInt32()));
|
||||
}
|
||||
|
42
third_party/gameq/GameQ/Protocols/Conanexiles.php
vendored
Normal file
42
third_party/gameq/GameQ/Protocols/Conanexiles.php
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
/**
|
||||
* Class Conanexiles
|
||||
*
|
||||
* @package GameQ\Protocols
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Conanexiles extends Source
|
||||
{
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name = 'conanexiles';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name_long = "Conan Exiles";
|
||||
}
|
43
third_party/gameq/GameQ/Protocols/Crysiswars.php
vendored
Normal file
43
third_party/gameq/GameQ/Protocols/Crysiswars.php
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
/**
|
||||
* Class Crysiswars
|
||||
*
|
||||
* @package GameQ\Protocols
|
||||
*
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Crysiswars extends Gamespy3
|
||||
{
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name = 'crysiswars';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name_long = "Crysis Wars";
|
||||
}
|
53
third_party/gameq/GameQ/Protocols/Gamespy3.php
vendored
53
third_party/gameq/GameQ/Protocols/Gamespy3.php
vendored
@ -73,6 +73,14 @@ class Gamespy3 extends Protocol
|
||||
*/
|
||||
protected $join_link = null;
|
||||
|
||||
/**
|
||||
* This defines the split between the server info and player/team info.
|
||||
* This value can vary by game. This value is the default split.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $packetSplit = "/\\x00\\x00\\x01/m";
|
||||
|
||||
/**
|
||||
* Parse the challenge response and apply it to all the packet types
|
||||
*
|
||||
@ -83,16 +91,23 @@ class Gamespy3 extends Protocol
|
||||
*/
|
||||
public function challengeParseAndApply(Buffer $challenge_buffer)
|
||||
{
|
||||
|
||||
// Pull out the challenge
|
||||
$challenge = substr(preg_replace("/[^0-9\-]/si", "", $challenge_buffer->getBuffer()), 1);
|
||||
$challenge_result = sprintf(
|
||||
"%c%c%c%c",
|
||||
($challenge >> 24),
|
||||
($challenge >> 16),
|
||||
($challenge >> 8),
|
||||
($challenge >> 0)
|
||||
);
|
||||
|
||||
// By default, no challenge result (see #197)
|
||||
$challenge_result = '';
|
||||
|
||||
// Check for valid challenge (see #197)
|
||||
if ($challenge) {
|
||||
// Encode chellenge result
|
||||
$challenge_result = sprintf(
|
||||
"%c%c%c%c",
|
||||
($challenge >> 24),
|
||||
($challenge >> 16),
|
||||
($challenge >> 8),
|
||||
($challenge >> 0)
|
||||
);
|
||||
}
|
||||
|
||||
// Apply the challenge and return
|
||||
return $this->challengeApply($challenge_result);
|
||||
@ -141,23 +156,23 @@ class Gamespy3 extends Protocol
|
||||
// Offload cleaning up the packets if they happen to be split
|
||||
$packets = $this->cleanPackets(array_values($processed));
|
||||
|
||||
/*
|
||||
* Fix: when server name contains string "\u0000" - query fails. "\u0000" also separates properties from
|
||||
* server, so we are replacing double "\u0000" in server response.
|
||||
*/
|
||||
$packets = preg_replace("/(\\x00){2,}gametype/", "\x00gametype", implode('', $packets));
|
||||
|
||||
// Create a new buffer
|
||||
$buffer = new Buffer($packets, Buffer::NUMBER_TYPE_BIGENDIAN);
|
||||
// Split the packets by type general and the rest (i.e. players & teams)
|
||||
$split = preg_split($this->packetSplit, implode('', $packets));
|
||||
|
||||
// Create a new result
|
||||
$result = new Result();
|
||||
|
||||
// Parse the server details
|
||||
// Assign variable due to pass by reference in PHP 7+
|
||||
$buffer = new Buffer($split[0], Buffer::NUMBER_TYPE_BIGENDIAN);
|
||||
|
||||
// First key should be server details and rules
|
||||
$this->processDetails($buffer, $result);
|
||||
|
||||
// Parse the player and team information
|
||||
$this->processPlayersAndTeams($buffer, $result);
|
||||
// The rest should be the player and team information, if it exists
|
||||
if (array_key_exists(1, $split)) {
|
||||
$buffer = new Buffer($split[1], Buffer::NUMBER_TYPE_BIGENDIAN);
|
||||
$this->processPlayersAndTeams($buffer, $result);
|
||||
}
|
||||
|
||||
unset($buffer);
|
||||
|
||||
|
34
third_party/gameq/GameQ/Protocols/Gamespy4.php
vendored
Normal file
34
third_party/gameq/GameQ/Protocols/Gamespy4.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
/**
|
||||
* GameSpy4 Protocol Class
|
||||
*
|
||||
* By all accounts GameSpy 4 seems to be GameSpy 3.
|
||||
*
|
||||
* References:
|
||||
* http://www.deletedscreen.com/?p=951
|
||||
* http://pastebin.com/2zZFDuTd
|
||||
*
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Gamespy4 extends Gamespy3
|
||||
{
|
||||
}
|
173
third_party/gameq/GameQ/Protocols/Gta5m.php
vendored
Normal file
173
third_party/gameq/GameQ/Protocols/Gta5m.php
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
use GameQ\Buffer;
|
||||
use GameQ\Exception\Protocol as Exception;
|
||||
use GameQ\Protocol;
|
||||
use GameQ\Result;
|
||||
|
||||
/**
|
||||
* GTA Five M Protocol Class
|
||||
*
|
||||
* Server base can be found at https://fivem.net/
|
||||
*
|
||||
* Based on code found at https://github.com/LiquidObsidian/fivereborn-query
|
||||
*
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Gta5m extends Protocol
|
||||
{
|
||||
|
||||
/**
|
||||
* Array of packets we want to look up.
|
||||
* Each key should correspond to a defined method in this or a parent class
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $packets = [
|
||||
self::PACKET_STATUS => "\xFF\xFF\xFF\xFFgetinfo xxx",
|
||||
];
|
||||
|
||||
/**
|
||||
* Use the response flag to figure out what method to run
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $responses = [
|
||||
"\xFF\xFF\xFF\xFFinfoResponse" => "processStatus",
|
||||
];
|
||||
|
||||
/**
|
||||
* The query protocol used to make the call
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $protocol = 'gta5m';
|
||||
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name = 'gta5m';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name_long = "GTA Five M";
|
||||
|
||||
/**
|
||||
* Normalize settings for this protocol
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $normalize = [
|
||||
// General
|
||||
'general' => [
|
||||
// target => source
|
||||
'gametype' => 'gametype',
|
||||
'hostname' => 'hostname',
|
||||
'mapname' => 'mapname',
|
||||
'maxplayers' => 'sv_maxclients',
|
||||
'mod' => 'gamename',
|
||||
'numplayers' => 'clients',
|
||||
'password' => 'privateClients',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Process the response
|
||||
*
|
||||
* @return array
|
||||
* @throws \GameQ\Exception\Protocol
|
||||
*/
|
||||
public function processResponse()
|
||||
{
|
||||
// In case it comes back as multiple packets (it shouldn't)
|
||||
$buffer = new Buffer(implode('', $this->packets_response));
|
||||
|
||||
// Figure out what packet response this is for
|
||||
$response_type = $buffer->readString(PHP_EOL);
|
||||
|
||||
// Figure out which packet response this is
|
||||
if (empty($response_type) || !array_key_exists($response_type, $this->responses)) {
|
||||
throw new Exception(__METHOD__ . " response type '{$response_type}' is not valid");
|
||||
}
|
||||
|
||||
// Offload the call
|
||||
$results = call_user_func_array([$this, $this->responses[$response_type]], [$buffer]);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle processing the status response
|
||||
*
|
||||
* @param Buffer $buffer
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function processStatus(Buffer $buffer)
|
||||
{
|
||||
// Set the result to a new result instance
|
||||
$result = new Result();
|
||||
|
||||
// Lets peek and see if the data starts with a \
|
||||
if ($buffer->lookAhead(1) == '\\') {
|
||||
// Burn the first one
|
||||
$buffer->skip(1);
|
||||
}
|
||||
|
||||
// Explode the data
|
||||
$data = explode('\\', $buffer->getBuffer());
|
||||
|
||||
// No longer needed
|
||||
unset($buffer);
|
||||
|
||||
$itemCount = count($data);
|
||||
|
||||
// Now lets loop the array
|
||||
for ($x = 0; $x < $itemCount; $x += 2) {
|
||||
// Set some local vars
|
||||
$key = $data[$x];
|
||||
$val = $data[$x + 1];
|
||||
|
||||
if (in_array($key, ['challenge'])) {
|
||||
continue; // skip
|
||||
}
|
||||
|
||||
// Regular variable so just add the value.
|
||||
$result->add($key, $val);
|
||||
}
|
||||
|
||||
/*var_dump($data);
|
||||
var_dump($result->fetch());
|
||||
|
||||
exit;*/
|
||||
|
||||
return $result->fetch();
|
||||
}
|
||||
}
|
163
third_party/gameq/GameQ/Protocols/Gtan.php
vendored
Normal file
163
third_party/gameq/GameQ/Protocols/Gtan.php
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
use GameQ\Exception\Protocol as Exception;
|
||||
use GameQ\Result;
|
||||
use GameQ\Server;
|
||||
|
||||
/**
|
||||
* Grand Theft Auto Network Protocol Class
|
||||
* https://stats.gtanet.work/
|
||||
*
|
||||
* Result from this call should be a header + JSON response
|
||||
*
|
||||
* References:
|
||||
* - https://master.gtanet.work/apiservers
|
||||
*
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Gtan extends Http
|
||||
{
|
||||
/**
|
||||
* Packets to send
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $packets = [
|
||||
//self::PACKET_STATUS => "GET /apiservers HTTP/1.0\r\nHost: master.gtanet.work\r\nAccept: */*\r\n\r\n",
|
||||
self::PACKET_STATUS => "GET /gtan/api.php?ip=%s&raw HTTP/1.0\r\nHost: multiplayerhosting.info\r\nAccept: */*\r\n\r\n",
|
||||
];
|
||||
|
||||
/**
|
||||
* Http protocol is SSL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $transport = self::TRANSPORT_SSL;
|
||||
|
||||
/**
|
||||
* The protocol being used
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $protocol = 'gtan';
|
||||
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'gtan';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name_long = "Grand Theft Auto Network";
|
||||
|
||||
/**
|
||||
* Holds the real ip so we can overwrite it back
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $realIp = null;
|
||||
|
||||
protected $realPortQuery = null;
|
||||
|
||||
/**
|
||||
* Normalize some items
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $normalize = [
|
||||
// General
|
||||
'general' => [
|
||||
// target => source
|
||||
'dedicated' => 'dedicated',
|
||||
'hostname' => 'hostname',
|
||||
'mapname' => 'map',
|
||||
'mod' => 'mod',
|
||||
'maxplayers' => 'maxplayers',
|
||||
'numplayers' => 'numplayers',
|
||||
'password' => 'password',
|
||||
],
|
||||
];
|
||||
|
||||
public function beforeSend(Server $server)
|
||||
{
|
||||
// Loop over the packets and update them
|
||||
foreach ($this->packets as $packetType => $packet) {
|
||||
// Fill out the packet with the server info
|
||||
$this->packets[$packetType] = sprintf($packet, $server->ip . ':' . $server->port_query);
|
||||
}
|
||||
|
||||
$this->realIp = $server->ip;
|
||||
$this->realPortQuery = $server->port_query;
|
||||
|
||||
// Override the existing settings
|
||||
//$server->ip = 'master.gtanet.work';
|
||||
$server->ip = 'multiplayerhosting.info';
|
||||
$server->port_query = 443;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the response
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processResponse()
|
||||
{
|
||||
// No response, assume offline
|
||||
if (empty($this->packets_response)) {
|
||||
return [
|
||||
'gq_address' => $this->realIp,
|
||||
'gq_port_query' => $this->realPortQuery,
|
||||
];
|
||||
}
|
||||
|
||||
// Implode and rip out the JSON
|
||||
preg_match('/\{(.*)\}/ms', implode('', $this->packets_response), $matches);
|
||||
|
||||
// Return should be JSON, let's validate
|
||||
if (!isset($matches[0]) || ($json = json_decode($matches[0])) === null) {
|
||||
throw new Exception("JSON response from Gtan protocol is invalid.");
|
||||
}
|
||||
|
||||
$result = new Result();
|
||||
|
||||
// Server is always dedicated
|
||||
$result->add('dedicated', 1);
|
||||
|
||||
$result->add('gq_address', $this->realIp);
|
||||
$result->add('gq_port_query', $this->realPortQuery);
|
||||
|
||||
// Add server items
|
||||
$result->add('hostname', $json->ServerName);
|
||||
$result->add('serverversion', $json->ServerVersion);
|
||||
$result->add('map', ((!empty($json->Map)) ? $json->Map : 'Los Santos/Blaine Country'));
|
||||
$result->add('mod', $json->Gamemode);
|
||||
$result->add('password', (int)$json->Passworded);
|
||||
$result->add('numplayers', $json->CurrentPlayers);
|
||||
$result->add('maxplayers', $json->MaxPlayers);
|
||||
|
||||
return $result->fetch();
|
||||
}
|
||||
}
|
42
third_party/gameq/GameQ/Protocols/Jediacademy.php
vendored
Normal file
42
third_party/gameq/GameQ/Protocols/Jediacademy.php
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
/**
|
||||
* Jedi Academy Protocol Class
|
||||
*
|
||||
* @package GameQ\Protocols
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Jediacademy extends Quake3
|
||||
{
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name = 'jediacademy';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name_long = "Star Wars Jedi Knight: Jedi Academy";
|
||||
}
|
42
third_party/gameq/GameQ/Protocols/Jedioutcast.php
vendored
Normal file
42
third_party/gameq/GameQ/Protocols/Jedioutcast.php
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
/**
|
||||
* Jedi Outcast Protocol Class
|
||||
*
|
||||
* @package GameQ\Protocols
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Jedioutcast extends Quake3
|
||||
{
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name = 'jedioutcast';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name_long = "Star Wars Jedi Knight II: Jedi Outcast";
|
||||
}
|
127
third_party/gameq/GameQ/Protocols/Justcause2.php
vendored
Normal file
127
third_party/gameq/GameQ/Protocols/Justcause2.php
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
use GameQ\Buffer;
|
||||
use GameQ\Result;
|
||||
|
||||
/**
|
||||
* Just Cause 2 Multiplayer Protocol Class
|
||||
*
|
||||
* Special thanks to Woet for some insight on packing
|
||||
*
|
||||
* @package GameQ\Protocols
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Justcause2 extends Gamespy4
|
||||
{
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name = 'justcause2';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name_long = "Just Cause 2 Multiplayer";
|
||||
|
||||
/**
|
||||
* The client join link
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $join_link = "steam://connect/%s:%d/";
|
||||
|
||||
/**
|
||||
* Change the packets used
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $packets = [
|
||||
self::PACKET_CHALLENGE => "\xFE\xFD\x09\x10\x20\x30\x40",
|
||||
self::PACKET_ALL => "\xFE\xFD\x00\x10\x20\x30\x40%s\xFF\xFF\xFF\x02",
|
||||
];
|
||||
|
||||
/**
|
||||
* Override the packet split
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $packetSplit = "/\\x00\\x00\\x00/m";
|
||||
|
||||
/**
|
||||
* Normalize settings for this protocol
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $normalize = [
|
||||
'general' => [
|
||||
// target => source
|
||||
'dedicated' => 'dedicated',
|
||||
'gametype' => 'gametype',
|
||||
'hostname' => 'hostname',
|
||||
'mapname' => 'mapname',
|
||||
'maxplayers' => 'maxplayers',
|
||||
'numplayers' => 'numplayers',
|
||||
'password' => 'password',
|
||||
],
|
||||
// Individual
|
||||
'player' => [
|
||||
'name' => 'name',
|
||||
'ping' => 'ping',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Overload so we can add in some static data points
|
||||
*
|
||||
* @param Buffer $buffer
|
||||
* @param Result $result
|
||||
*/
|
||||
protected function processDetails(Buffer &$buffer, Result &$result)
|
||||
{
|
||||
parent::processDetails($buffer, $result);
|
||||
|
||||
// Add in map
|
||||
$result->add('mapname', 'Panau');
|
||||
$result->add('dedicated', 'true');
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the parent, this protocol is returned differently
|
||||
*
|
||||
* @param Buffer $buffer
|
||||
* @param Result $result
|
||||
*
|
||||
* @see Gamespy3::processPlayersAndTeams()
|
||||
*/
|
||||
protected function processPlayersAndTeams(Buffer &$buffer, Result &$result)
|
||||
{
|
||||
// Loop until we run out of data
|
||||
while ($buffer->getLength()) {
|
||||
$result->addPlayer('name', $buffer->readString());
|
||||
$result->addPlayer('steamid', $buffer->readString());
|
||||
$result->addPlayer('ping', $buffer->readInt16());
|
||||
}
|
||||
}
|
||||
}
|
50
third_party/gameq/GameQ/Protocols/Justcause3.php
vendored
Normal file
50
third_party/gameq/GameQ/Protocols/Justcause3.php
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
/**
|
||||
* Class Just Cause 3
|
||||
*
|
||||
* @package GameQ\Protocols
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Justcause3 extends Source
|
||||
{
|
||||
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name = 'justcause3';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name_long = "Just Cause 3";
|
||||
|
||||
/**
|
||||
* Query port = client_port + 1
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $port_diff = 1;
|
||||
}
|
55
third_party/gameq/GameQ/Protocols/Risingstorm2.php
vendored
Normal file
55
third_party/gameq/GameQ/Protocols/Risingstorm2.php
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<?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 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 Lesser General Public License for more details.
|
||||
*
|
||||
* 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\Protocols;
|
||||
|
||||
/**
|
||||
* Class Rising Storm 2
|
||||
*
|
||||
* @package GameQ\Protocols
|
||||
* @author Austin Bischoff <austin@codebeard.com>
|
||||
*/
|
||||
class Risingstorm2 extends Source
|
||||
{
|
||||
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name = 'rising storm 2';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name_long = "Rising Storm 2";
|
||||
|
||||
/**
|
||||
* Query port is always 27015
|
||||
*
|
||||
* @param int $clientPort
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function findQueryPort($clientPort)
|
||||
{
|
||||
return 27015;
|
||||
}
|
||||
}
|
6
third_party/gameq/GameQ/Protocols/Tshock.php
vendored
6
third_party/gameq/GameQ/Protocols/Tshock.php
vendored
@ -96,11 +96,15 @@ class Tshock extends Http
|
||||
*/
|
||||
public function processResponse()
|
||||
{
|
||||
if (empty($this->packets_response)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Implode and rip out the JSON
|
||||
preg_match('/\{(.*)\}/ms', implode('', $this->packets_response), $matches);
|
||||
|
||||
// Return should be JSON, let's validate
|
||||
if (($json = json_decode($matches[0])) === null) {
|
||||
if (!isset($matches[0]) || ($json = json_decode($matches[0])) === null) {
|
||||
throw new Exception("JSON response from Tshock protocol is invalid.");
|
||||
}
|
||||
|
||||
|
12
third_party/gameq/GameQ/Query/Native.php
vendored
12
third_party/gameq/GameQ/Query/Native.php
vendored
@ -128,6 +128,7 @@ class Native extends Core
|
||||
* Pull the responses out of the stream
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*
|
||||
* @param array $sockets
|
||||
* @param int $timeout
|
||||
@ -182,8 +183,8 @@ class Native extends Core
|
||||
// Now lets listen for some streams, but do not cross the streams!
|
||||
$streams = stream_select($read, $write, $except, 0, $stream_timeout);
|
||||
|
||||
// We had error or no streams left, kill the loop
|
||||
if ($streams === false || ($streams <= 0)) {
|
||||
// We had error, kill the loop
|
||||
if ($streams === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -192,7 +193,7 @@ class Native extends Core
|
||||
/* @var $socket resource */
|
||||
|
||||
// See if we have a response
|
||||
if (($response = stream_socket_recvfrom($socket, 8192)) === false) {
|
||||
if (($response = fread($socket, 8192)) === false) {
|
||||
continue; // No response yet so lets continue.
|
||||
}
|
||||
|
||||
@ -207,6 +208,11 @@ class Native extends Core
|
||||
$responses[(int)$socket][] = $response;
|
||||
}
|
||||
|
||||
// If we have data from all sockets, break
|
||||
if (count($responses) == count($sockets)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Because stream_select modifies read we need to reset it each time to the original array of sockets
|
||||
$read = $sockets_tmp;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user