1
0
mirror of https://github.com/xPaw/PHP-Source-Query.git synced 2026-05-18 12:53:34 +02:00

Fix up some type information

This commit is contained in:
Pavel Djundik
2020-06-23 19:44:51 +03:00
parent 1078e47b7e
commit b87c9faab9
5 changed files with 23 additions and 10 deletions
+9 -2
View File
@@ -13,13 +13,15 @@
namespace xPaw\SourceQuery;
use xPaw\SourceQuery\Exception\InvalidPacketException;
use xPaw\SourceQuery\Exception\SocketException;
/**
* Base socket interface
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\InvalidPacketException
* @uses xPaw\SourceQuery\Exception\SocketException
*/
abstract class BaseSocket
{
@@ -58,6 +60,7 @@
$Packets = [];
$IsCompressed = false;
$ReadMore = false;
$PacketChecksum = null;
do
{
@@ -92,6 +95,10 @@
break;
}
default:
{
throw new SocketException( 'Unknown engine.', SocketException::INVALID_ENGINE );
}
}
$Packets[ $PacketNumber ] = $Buffer->Get( );
@@ -113,7 +120,7 @@
$Data = bzdecompress( $Data );
if( CRC32( $Data ) !== $PacketChecksum )
if( !is_string( $Data ) || CRC32( $Data ) !== $PacketChecksum )
{
throw new InvalidPacketException( 'CRC32 checksum mismatch of uncompressed packet data.', InvalidPacketException::CHECKSUM_MISMATCH );
}
@@ -17,4 +17,5 @@
const COULD_NOT_CREATE_SOCKET = 1;
const NOT_CONNECTED = 2;
const CONNECTION_FAILED = 3;
const INVALID_ENGINE = 3;
}
+1 -3
View File
@@ -33,7 +33,6 @@
private $Socket;
private $RconPassword;
private $RconRequestId;
private $RconChallenge;
public function __construct( $Socket )
@@ -44,7 +43,6 @@
public function Close( )
{
$this->RconChallenge = 0;
$this->RconRequestId = 0;
$this->RconPassword = 0;
}
@@ -64,7 +62,7 @@
/**
* @param int $Length
* @throws AuthenticationException
* @return bool
* @return Buffer
*/
public function Read( $Length = 1400 )
{
+10 -3
View File
@@ -70,14 +70,14 @@
/**
* Points to rcon class
*
* @var SourceRcon
* @var SourceRcon|GoldSourceRcon|null
*/
private $Rcon;
/**
* Points to socket class
*
* @var Socket
* @var BaseSocket
*/
private $Socket;
@@ -159,7 +159,7 @@
public function Disconnect( )
{
$this->Connected = false;
$this->Challenge = 0;
$this->Challenge = '';
$this->Socket->Close( );
@@ -212,6 +212,7 @@
$Buffer = $this->Socket->Read( );
$Type = $Buffer->GetByte( );
$Server = [];
// Old GoldSource protocol, HLTV still uses it
if( $Type === self::S2A_INFO_OLD && $this->Socket->Engine === self::GOLDSOURCE )
@@ -237,6 +238,7 @@
if( $Server[ 'IsMod' ] )
{
$Mod = [];
$Mod[ 'Url' ] = $Buffer->GetString( );
$Mod[ 'Download' ] = $Buffer->GetString( );
$Buffer->Get( 1 ); // NULL byte
@@ -391,6 +393,7 @@
while( $Count-- > 0 && $Buffer->Remaining( ) > 0 )
{
$Player = [];
$Player[ 'Id' ] = $Buffer->GetByte( ); // PlayerID, is it just always 0?
$Player[ 'Name' ] = $Buffer->GetString( );
$Player[ 'Frags' ] = $Buffer->GetLong( );
@@ -527,6 +530,10 @@
break;
}
default:
{
throw new SocketException( 'Unknown engine.', SocketException::INVALID_ENGINE );
}
}
$this->Rcon->Open( );