mirror of
https://github.com/xPaw/PHP-Source-Query.git
synced 2026-05-18 12:53:34 +02:00
Add support for games that use old method for getting challenges
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
const A2S_INFO = 0x54;
|
||||
const A2S_PLAYER = 0x55;
|
||||
const A2S_RULES = 0x56;
|
||||
const A2S_SERVERQUERY_GETCHALLENGE = 0x57;
|
||||
|
||||
/**
|
||||
* Packets received
|
||||
@@ -103,6 +104,13 @@
|
||||
*/
|
||||
private $Challenge;
|
||||
|
||||
/**
|
||||
* Use old method for getting challenge number
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $UseOldGetChallengeMethod;
|
||||
|
||||
public function __construct( )
|
||||
{
|
||||
$this->Buffer = new SourceQueryBuffer( );
|
||||
@@ -158,6 +166,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces GetChallenge to use old method for challenge retrieval because some games use outdated protocol (e.g Starbound)
|
||||
*
|
||||
* @param bool $Value Set to true to force old method
|
||||
*
|
||||
* @returns bool Previous value
|
||||
*/
|
||||
public function SetUseOldGetChallengeMethod( $Value )
|
||||
{
|
||||
$Previous = $this->UseOldGetChallengeMethod;
|
||||
|
||||
$this->UseOldGetChallengeMethod = $Value === true;
|
||||
|
||||
return $Previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes all open connections
|
||||
*/
|
||||
@@ -464,6 +488,11 @@
|
||||
return self :: GETCHALLENGE_ALL_CLEAR;
|
||||
}
|
||||
|
||||
if( $this->UseOldGetChallengeMethod )
|
||||
{
|
||||
$Header = self :: A2S_SERVERQUERY_GETCHALLENGE;
|
||||
}
|
||||
|
||||
$this->Socket->Write( $Header, 0xFFFFFFFF );
|
||||
$this->Socket->Read( );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user