diff --git a/SourceQuery/BaseSocket.php b/SourceQuery/BaseSocket.php index 331d791..ce19744 100644 --- a/SourceQuery/BaseSocket.php +++ b/SourceQuery/BaseSocket.php @@ -26,7 +26,7 @@ public $Socket; public $Engine; - public $Ip; + public $Address; public $Port; public $Timeout; @@ -36,7 +36,7 @@ } abstract public function Close( ); - abstract public function Open( $Ip, $Port, $Timeout, $Engine ); + abstract public function Open( $Address, $Port, $Timeout, $Engine ); abstract public function Write( $Header, $String = '' ); abstract public function Read( $Length = 1400 ); diff --git a/SourceQuery/Socket.php b/SourceQuery/Socket.php index 3df7f4b..5ceb21d 100644 --- a/SourceQuery/Socket.php +++ b/SourceQuery/Socket.php @@ -35,14 +35,14 @@ } } - public function Open( $Ip, $Port, $Timeout, $Engine ) + public function Open( $Address, $Port, $Timeout, $Engine ) { $this->Timeout = $Timeout; $this->Engine = $Engine; $this->Port = $Port; - $this->Ip = $Ip; + $this->Address = $Address; - $this->Socket = @FSockOpen( 'udp://' . $Ip, $Port, $ErrNo, $ErrStr, $Timeout ); + $this->Socket = @FSockOpen( 'udp://' . $Address, $Port, $ErrNo, $ErrStr, $Timeout ); if( $ErrNo || $this->Socket === false ) { diff --git a/SourceQuery/SourceQuery.php b/SourceQuery/SourceQuery.php index 5ce30f0..80d7f84 100644 --- a/SourceQuery/SourceQuery.php +++ b/SourceQuery/SourceQuery.php @@ -122,7 +122,7 @@ /** * Opens connection to server * - * @param string $Ip Server ip + * @param string $Address Server ip * @param int $Port Server port * @param int $Timeout Timeout period * @param int $Engine Engine the server runs on (goldsource, source) @@ -130,7 +130,7 @@ * @throws InvalidArgumentException * @throws SocketException */ - public function Connect( $Ip, $Port, $Timeout = 3, $Engine = self::SOURCE ) + public function Connect( $Address, $Port, $Timeout = 3, $Engine = self::SOURCE ) { $this->Disconnect( ); @@ -139,7 +139,7 @@ throw new InvalidArgumentException( 'Timeout must be an integer.', InvalidArgumentException::TIMEOUT_NOT_INTEGER ); } - $this->Socket->Open( $Ip, (int)$Port, $Timeout, (int)$Engine ); + $this->Socket->Open( $Address, (int)$Port, $Timeout, (int)$Engine ); $this->Connected = true; } @@ -309,18 +309,17 @@ // You can use https://github.com/xPaw/SteamID.php if( $Flags & 0x10 ) { - $a = $Buffer->GetUnsignedLong( ); - $b = $Buffer->GetUnsignedLong( ); + $SteamIDLower = $Buffer->GetUnsignedLong( ); + $SteamIDInstance = $Buffer->GetUnsignedLong( ); // This gets shifted by 32 bits, which should be steamid instance $SteamID = 0; if( PHP_INT_SIZE === 4 ) { if( extension_loaded( 'gmp' ) ) { - $a = gmp_abs( $a ); - $b = gmp_abs( $b ); - - $SteamID = gmp_strval( gmp_or( $a, gmp_mul( $b, gmp_pow( 2, 32 ) ) ) ); + $SteamIDLower = gmp_abs( $SteamIDLower ); + $SteamIDInstance = gmp_abs( $SteamIDInstance ); + $SteamID = gmp_strval( gmp_or( $SteamIDLower, gmp_mul( $SteamIDInstance, gmp_pow( 2, 32 ) ) ) ); } else { @@ -329,12 +328,12 @@ } else { - $SteamID = $a | ( $b << 32 ); + $SteamID = $SteamIDLower | ( $SteamIDInstance << 32 ); } $Server[ 'SteamID' ] = $SteamID; - unset( $a, $b, $SteamID ); + unset( $SteamIDLower, $SteamIDInstance, $SteamID ); } // The spectator port and then the spectator server name diff --git a/SourceQuery/SourceRcon.php b/SourceQuery/SourceRcon.php index 0ef7edf..2e722f2 100644 --- a/SourceQuery/SourceRcon.php +++ b/SourceQuery/SourceRcon.php @@ -58,7 +58,7 @@ { if( !$this->RconSocket ) { - $this->RconSocket = @FSockOpen( $this->Socket->Ip, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout ); + $this->RconSocket = @FSockOpen( $this->Socket->Address, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout ); if( $ErrNo || !$this->RconSocket ) { diff --git a/Tests/Tests.php b/Tests/Tests.php index f2864fc..de983fb 100644 --- a/Tests/Tests.php +++ b/Tests/Tests.php @@ -25,7 +25,7 @@ // } - public function Open( $Ip, $Port, $Timeout, $Engine ) + public function Open( $Address, $Port, $Timeout, $Engine ) { // } @@ -37,11 +37,6 @@ public function Read( $Length = 1400 ) { - if( $this->PacketQueue->Count === 0 ) - { - throw new InvalidPacketException( 'Buffer is empty', InvalidPacketException::BUFFER_EMPTY ); - } - $Buffer = new Buffer( ); $Buffer->Set( $this->PacketQueue->pop() );