Skip to content

Commit

Permalink
Fix the error for no players.
Browse files Browse the repository at this point in the history
  • Loading branch information
hakre committed Aug 4, 2012
1 parent 0cf5df0 commit 8598f9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions minequery.class.php
Expand Up @@ -63,8 +63,9 @@ public static function query($address, $port = 25566, $timeout = 30) {
$query['maxPlayers'] = $query['maxPlayers'][1];

// Player list
$query['playerList'] = explode(" ", $response[3], 2);
$query['playerList'] = explode(", ", trim($query['playerList'][1], "[]"));
list(, $buffer) = explode(" ", $response[3], 2);
$buffer = trim($buffer, "[] ");
$query['playerList'] = $buffer ? explode(", ", $buffer) : array();

$query['latency'] = $latency;

Expand Down
2 changes: 1 addition & 1 deletion test-failure-no-player-query.php
Expand Up @@ -25,7 +25,7 @@ protected static function read($address, $port, &$errno, &$errstr, $timeout, $wr

Minequery::$classname = 'MinequeryStub';

$query = Minequery::query($host, $port, 3);
$query = Minequery::query($host);
$playerList = $query['playerList'];
$failure = array("");
$fixed = array();
Expand Down

0 comments on commit 8598f9e

Please sign in to comment.